Aurelien Quadran Posted April 16, 2018 Share Posted April 16, 2018 Hi everybody, I am currently developping a dashboard module. I was wondering if there were a simple way to get the language that the user selected in his profile. I've found this : Configuration::get('PS_LANG_DEFAULT'); but it just return the id of the language. Is there a built-in method that does it ? Link to comment Share on other sites More sharing options...
Aurelien Quadran Posted April 17, 2018 Author Share Posted April 17, 2018 This works fine : $this->context->language->iso_code; Link to comment Share on other sites More sharing options...
Murat Kezli Posted July 14, 2022 Share Posted July 14, 2022 If you fetch the language object, you will get output similar to the following. Here's the way to use what you need: $this->context->language->id or $this->context->language->name etc. Language Object ( [id] => 2 [name] => Türkçe (Turkish) [iso_code] => tr [locale] => tr-TR [language_code] => tr-tr [date_format_lite] => Y-m-d [date_format_full] => Y-m-d H:i:s [is_rtl] => 0 [active] => 1 [webserviceParameters:protected] => Array ( [objectNodeName] => language [objectsNodeName] => languages ) [translationsFilesAndVars:protected] => Array ( [fields] => _FIELDS [errors] => _ERRORS [admin] => _LANGADM [pdf] => _LANGPDF [tabs] => tabs ) [id_lang:protected] => [id_shop:protected] => 1 [id_shop_list] => Array ( ) [get_shop_from_context:protected] => 1 [table:protected] => lang [identifier:protected] => id_lang [fieldsRequired:protected] => Array ( [0] => name [1] => iso_code [2] => date_format_lite [3] => date_format_full ) [fieldsSize:protected] => Array ( [name] => 32 [iso_code] => 2 [locale] => 5 [language_code] => 5 [date_format_lite] => 32 [date_format_full] => 32 ) [fieldsValidate:protected] => Array ( [name] => isGenericName [iso_code] => isLanguageIsoCode [locale] => isLocale [language_code] => isLanguageCode [active] => isBool [is_rtl] => isBool [date_format_lite] => isPhpDateFormat [date_format_full] => isPhpDateFormat ) [fieldsRequiredLang:protected] => Array ( ) [fieldsSizeLang:protected] => Array ( ) [fieldsValidateLang:protected] => Array ( ) [tables:protected] => Array ( ) [image_dir:protected] => [image_format:protected] => jpg [translator:protected] => [def:protected] => Array ( [table] => lang [primary] => id_lang [fields] => Array ( [name] => Array ( [type] => 3 [validate] => isGenericName [required] => 1 [size] => 32 ) [iso_code] => Array ( [type] => 3 [validate] => isLanguageIsoCode [required] => 1 [size] => 2 ) [locale] => Array ( [type] => 3 [validate] => isLocale [size] => 5 ) [language_code] => Array ( [type] => 3 [validate] => isLanguageCode [size] => 5 ) [active] => Array ( [type] => 2 [validate] => isBool ) [is_rtl] => Array ( [type] => 2 [validate] => isBool ) [date_format_lite] => Array ( [type] => 3 [validate] => isPhpDateFormat [required] => 1 [size] => 32 ) [date_format_full] => Array ( [type] => 3 [validate] => isPhpDateFormat [required] => 1 [size] => 32 ) ) [classname] => Language ) [update_fields:protected] => [force_id] => ) 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