maba Posted May 30, 2013 Share Posted May 30, 2013 Hi, in a site with 3 languages (IT - default -, EN and FR) I have date written in english. So I translate C in /wire/modules/LanguageSupport/LanguageSupport.module for each language but now date are written in IT for EN and FR pages also, logged or guest user. To change language I use this snippet (with a little problem): foreach($languages as $language) { if(!$page->viewable($language)) continue; // language marked not available $url = $page->localUrl($language); echo "<a href='$url'>$language->title</a>"; } Not possible? Processwire 2.3 dev Thanks, Marco Link to comment Share on other sites More sharing options...
Soma Posted May 30, 2013 Share Posted May 30, 2013 Never ever edit anything in wire folder. You can set that locale in the translation file for the particular language. The file is: wire--modules--languagesupport--languagesupport-module Link to comment Share on other sites More sharing options...
maba Posted May 30, 2013 Author Share Posted May 30, 2013 I not edited core file. I set locale as you suggest, for each language. Only one locale is setted (of the default language) so I have text in english but date in italian, text in french but date in italian and so on. If I change C for IT, eg. fr_FR, I have italian text and french date, english text and french date and so on. Seems that PW cannot set locale dynamically, like it does for the translated strings, urls, ... Link to comment Share on other sites More sharing options...
Soma Posted May 30, 2013 Share Posted May 30, 2013 so I have text in english but date in italian I don't understand. What you mean with I have? front-end or backend? If you are in backend it will display date in the language your user is set to. Link to comment Share on other sites More sharing options...
maba Posted May 30, 2013 Author Share Posted May 30, 2013 URL: site.com/eventi (default language is ITA) The month (JUN) in correct: GIU then I change the page from switch language menu: URL: site.com/en/events The month (JUN) is wrong: it remains GIU but text is translated. Link to comment Share on other sites More sharing options...
Soma Posted May 30, 2013 Share Posted May 30, 2013 There seems to be an issue with this how or where this locale gets set. It doesn't seem to recognize the langauge on front end. It always uses the user language set on user profile. Link to comment Share on other sites More sharing options...
maba Posted May 30, 2013 Author Share Posted May 30, 2013 In your opinion.. How can I test this? Link to comment Share on other sites More sharing options...
Soma Posted May 30, 2013 Share Posted May 30, 2013 Well change the language of you user and it will take that locale regardless of the front end language set. This is more for Ryan to checkout. I have no clue how to make it behave. Link to comment Share on other sites More sharing options...
ryan Posted June 2, 2013 Share Posted June 2, 2013 I'll look into this. But something you can always do as a workaround is just perform your own setLocale call from your template file. Link to comment Share on other sites More sharing options...
maba Posted June 2, 2013 Author Share Posted June 2, 2013 Thanks Ryan. At the moment I use if (($user->language) == $languages->get("en")) setlocale(LC_ALL, 'en_GB'); I have only IT and EN enabled for now. Link to comment Share on other sites More sharing options...
ryan Posted June 5, 2013 Share Posted June 5, 2013 It looks like you have some unnecessary comparison in there (including a == full object comparison), I recommend this instead: if('en' == $user->language->name) setlocale(LC_ALL, 'en_GB'); Generally when comparing one page to another in ProcessWire, you want to compare the IDs: $page1->id == $page2->id; or if you want to compare the objects then use 3 equals so that it's comparing the instance rather than all the properties (per the way PHP works): $page1 === $page2; But in the case above, it wasn't even necessary to compare any objects since all you needed to compare was the name to the string 'en'. 1 Link to comment Share on other sites More sharing options...
maba Posted June 5, 2013 Author Share Posted June 5, 2013 Changed Thanks Ryan.. 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