Frank Vèssia Posted October 7, 2013 Posted October 7, 2013 I'm facing a strange behavior in my website. When switch from default language (it) to english, only the fields are displayed correctly in english, not the texts in my template files. I have severals files loaded in the translation admin, all translated, but the text remains in it. Where i'm wrong?
arjen Posted October 7, 2013 Posted October 7, 2013 Could you be so kind to show us what code you are using? Are the translation files available in your language? 1
Frank Vèssia Posted October 7, 2013 Author Posted October 7, 2013 For switch language i use this code <?php $user->language = $languages->get("default"); list($languageName) = explode('.', $config->httpHost); $languageName = $sanitizer->pageName($languageName); switch($languageName){ case 'en': $user->language = $languages->get("en"); setlocale(LC_ALL,'en_EN'); break; default: $user->language = $languages->get("default"); setlocale(LC_ALL,'it_IT'); } inside my template, for example home.inc i simply echo this <?php $l_search = $this->_("Search"); ?> <div><?=$l_search?></div>
apeisa Posted October 7, 2013 Posted October 7, 2013 try without $this and with two underscores. __("like this") 3
Frank Vèssia Posted October 7, 2013 Author Posted October 7, 2013 Apeisa, it works! But why? I mean, using $this should work also...before making a massive find/replace is there a way to make it works with $this?
Wanze Posted October 7, 2013 Posted October 7, 2013 Apeisa, it works! But why? I mean, using $this should work also...before making a massive find/replace is there a way to make it works with $this? $this->_() does only work in modules (inside classes). In templates (site/templates) you must use __('string');
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