Jump to content

Month names Multilanguage website


manlio
 Share

Recommended Posts

Hi, I have some questions about month date in different languages.

I have a multilanguage website with only two languages running on PW 2.5.3 and I would like to know if it is possibile to translate month names in frontend directly in translation files.

Now I'm using something like:

if ($user->language == "1061") { //***CHECK IF THE USER LANGUAGE IS ITALIAN
setlocale(LC_ALL, array('it_IT.UTF-8','it_IT@euro','it_IT','italian'));
echo strftime('%d %B %Y', $page->getUnformatted('mydate'));} 

else {echo $page->mydate;} //*** PASTE "STANDARD" DATE

Is this a good approach or there is an easier one?

Which is the Windows 8 alternative for command "local -a" on Unix system? I wanna know exactly how my server calls my language.

Thank you.

Link to comment
Share on other sites

In the meanwhile I wrote a simple function that I put in an myfunctions.inc file that I can include whenever I need.

Then I can call the correct date in this way 

<?=rightdate($page,"datainizio");?> //** rightdate is the name of the function that you can find below

Here the function:

function rightdate($rightselector,$mydate) {
    $user = wire('user');
    $page = wire('page');
    if ($user->language == "1061") //** here you have to insert the id of your language
 {setlocale(LC_ALL, array('it_IT.UTF-8','it_IT@euro','it_IT','italian')); //** you can to whatever language you need
 return strftime('%d %B %Y', $rightselector->getUnformatted($mydate));
 } else {return $rightselector->$mydate;}} 

I'm a newbie and for sure this is not an excellent method but maybe this could help someone else that is learning like me  :) .

  • Like 1
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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