Pau111111 Posted March 16, 2017 Share Posted March 16, 2017 (edited) I want to write a code in different languages using an if (language = en || lenguage=es) { // code } (For example) in a tpl file. How can I know what language the user is using? Thanks! Im using prestashop 1.6.1.8 Edited March 16, 2017 by Pau111111 (see edit history) Link to comment Share on other sites More sharing options...
prosci8 Posted March 16, 2017 Share Posted March 16, 2017 Use the context object : http://doc.prestashop.com/display/PS16/Using+the+Context+Object $this->context->language->id; 1 Link to comment Share on other sites More sharing options...
Pau111111 Posted March 17, 2017 Author Share Posted March 17, 2017 Use the context object : http://doc.prestashop.com/display/PS16/Using+the+Context+Object $this->context->language->id; I'm trying this in a TPL file but doesn't works: $id_idioma = $this->context->language->id; {if $id_idioma==3} //code {/if} Im almost sure that is my problem but I don't know how to do it. Thanks for helping me. Link to comment Share on other sites More sharing options...
prosci8 Posted March 18, 2017 Share Posted March 18, 2017 In template you have to use {} for code/variables. Here are few other examples: {$languages} The various available languages {$lang_iso} ISO code for the current language {$this->context->language->id} current language id 2 Link to comment Share on other sites More sharing options...
vikramdhanjal Posted May 30, 2019 Share Posted May 30, 2019 For PS 1.7.5.1 its very simple. You can use following to detect currently selected language on product details page or any tpl.{$language.id} 1 Link to comment Share on other sites More sharing options...
maldor Posted December 21, 2020 Share Posted December 21, 2020 (edited) Use this to get current language {$language.iso_code} with ISO code (like en, fr, de, ...) Edited December 21, 2020 by maldor (see edit history) 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