Jump to content

Localisation of the $todaysdate template variable


yrochon

Recommended Posts

We have WHMCS set up to be multilingual; french and english. However, even if the client area display in french, the date shows in english, which is does not look professional. Is there any way to resolve this?

 

For example :

 

Bienvenue, user4029247. Aujourd'hui, le Tuesday, 28th June 2011

 

should be (something like)

 

Bienvenue, user4029247. Aujourd'hui, mardi le 28 juin 2011
Link to comment
Share on other sites

Here is a dirty solution. something more elegant would be preferable, but it will do for now.

 

1. Change translations like so :

 

# French.txt
$_LANG["todayis"] = "Aujourd'hui, %s le %s";

# English.txt
$_LANG["todayis"] = "Today is %s, %s";

 

2. in the template file (ie. clientareahome.tpl) where today's date needs to be output

 

{php}
   $lang = $this->get_template_vars('LANG');
   if ($this->get_template_vars('language') == 'French') {
       setlocale(LC_ALL, 'fr_FR');
       $this->assign('todayis', sprintf($lang['todayis'], strftime("%A"), strftime("%e %B %Y")));
   } else {
       setlocale(LC_ALL, 'en_GB');
       $this->assign('todayis', sprintf($lang['todayis'], strftime("%A"), date("jS F Y")));
   }
{/php}

 

3. use the variable

 

{$todayis}

Link to comment
Share on other sites

  • 3 weeks later...

Actually, step 2 should have been

 

{php}
   $lang = $this->get_template_vars('LANG');
   if ($this->get_template_vars('language') == 'French') {
       setlocale(LC_ALL, 'fr_FR');
       $this->assign('todayis', sprintf($lang['todayis'], strftime("%A"), strftime("%e %B %Y")));
   } else {
       setlocale(LC_ALL, 'en_GB');
       $this->assign('todayis', sprintf($lang['todayis'], strftime("%A"), date("F j Y")));
   }
{/php}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated