manlio Posted January 16, 2015 Share Posted January 16, 2015 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 More sharing options...
manlio Posted January 17, 2015 Author Share Posted January 17, 2015 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 . 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now