Jump to content

[SOLVED] Translating month in a module front office


cedricfontaine

Recommended Posts

Hello,

 

I try to display a birthday date in text in a module. As it's a parameter, I'm unable to make it translatable in smarty, neither in the module php file.

 

I tried this very complicated syntax at last, but he doesn't work...

$months=array('01'=>$this->l('January'),'02'=>$this->l('February'),'03'=>$this->l('March'),'04'=>$this->l('April'),'05'=>$this->l('May'),'06'=>$this->l('June'),'07'=>$this->l('July'),'08'=>$this->l('August'),'09'=>$this->l('September'),'10'=>$this->l('October'),'11'=>$this->l('November'),'12'=>$this->l('December'));
		$mois=explode('-',$this->context->customer->birthday);
		$mois=$mois[1];
		$mois=$months[$mois];

I keep displaying the month in english, even it appears in the translation of my module in the back office, but it keeps displaying the english version...

Link to comment
Share on other sites

take a look how it looks in authentication.tpl file, there is a comment with months:

	{*
						  {l s='January'}
						  {l s='February'}
						  {l s='March'}
						  {l s='April'}
						  {l s='May'}
						  {l s='June'}
						  {l s='July'}
						  {l s='August'}
						  {l s='September'}
						  {l s='October'}
						  {l s='November'}
						  {l s='December'}
					  *}

and these translations (!) are used in foreach loop:

{foreach from=$months key=k item=month}
<option value="{$k}" {if ($sl_month == $k)} selected="selected"{/if}>{l s=$month} </option>
{/foreach}

Try the same method, paste this in .tpl file

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...