superskyman100 Posted April 19, 2019 Share Posted April 19, 2019 (edited) Hello, I'm using prestashop 1.7.5.1 I already made lots of translations with my shop, but i finally had to add one language (australian). Problem is that i'd like to reorganize the flags order in the frontend (i'd like the australian language to be just below the english language), and there is no solution througout backend (except erasing all, and re-create in good order id., which would ruin all my previous translations works). Any simple idea ? Thanks Edited January 24, 2020 by superskyman100 (see edit history) Link to comment Share on other sites More sharing options...
prestamonste Posted April 19, 2019 Share Posted April 19, 2019 Hi there, The language table doesn't support the position field. So, you cannot change the language position from your back office. In your case, you can override function getLanguages of class Language (Language.php) , sort (change) position of the language in this array. Thanks, Quang Link to comment Share on other sites More sharing options...
superskyman100 Posted April 19, 2019 Author Share Posted April 19, 2019 Sorry i understand absolutely nothing...... some guys told me to modify this section in ps_languageselector.php foreach ($languages as &$lang) { $lang['name_simple'] = $this->getNameSimple($lang['name']); } and ordering the languages here by id...... But NO IDEA how i should do that i know nothing about programming Link to comment Share on other sites More sharing options...
prestamonste Posted April 19, 2019 Share Posted April 19, 2019 Hi there, Yes, you can change in the file ps_languageselector.php. But if you change in there, you only use for this block. If you change in the function getLanguages, you will override anywhere. You can change the class getLanguages the same image. Thanks, Quang Link to comment Share on other sites More sharing options...
superskyman100 Posted April 19, 2019 Author Share Posted April 19, 2019 hey thank you very much for your help.... but where is this file ??? There is thousands of php files, i made a research with my FTP but it takes ages..... Link to comment Share on other sites More sharing options...
prestamonste Posted April 19, 2019 Share Posted April 19, 2019 Hi, Like in the prev message, you need to override function getLanguages in the class Language (Language.php) and put it in the folder: public_html/override/classes/Language.php. Please let me know your PS version. I will help you to create the file override. Thanks, Quang Link to comment Share on other sites More sharing options...
superskyman100 Posted April 19, 2019 Author Share Posted April 19, 2019 Thanks a lot Prestamonster for your help, my PS is 1.7.5.1 in my point of view this sounds really complicated... for instance i also have (the search is still on) 2 language.php files (at least) in my prestashop (inside the symphony folder)... Honestly i only need to change the language position in the language block on the front end, and nothing else... this is just for design / coherency purpose Wouldn't it be simplier (and less risky) to make some little modifs in the ps_languageselector.php ?? Link to comment Share on other sites More sharing options...
superskyman100 Posted April 19, 2019 Author Share Posted April 19, 2019 In case i just wanna the simple solution in ps_languageselector.php, should i code like that ?????..... foreach ($languages as &$lang) { $lang['name_simple'] = $this->getNameSimple($lang['name']); $lang_en = array(); $lang_au = array(); $lang_other = array();} honestly i'm completey dumb about programming, i can just understand the general logics..... Link to comment Share on other sites More sharing options...
prestamonste Posted April 19, 2019 Share Posted April 19, 2019 Hi there, There are 2 ways: 1. override function getWidgetVariables() in the file ps_languageselector.php of module ps_languageselector public function getWidgetVariables($hookName = null, array $configuration = []) { $languages = Language::getLanguages(true, $this->context->shop->id); $lang_en = array(); $lang_au = array(); $lang_other = array(); foreach ($languages as &$lang) { $lang['name_simple'] = $this->getNameSimple($lang['name']); if ($language['iso_code'] == 'en') { $lang_en[] = $lang; } else if ($language['iso_code'] == 'gb') { $lang_au[] = $lang; } else { $lang_other[] = $lang; } } $languages = array_merge($lang_en, $lang_au, $lang_other); return array( 'languages' => $languages, 'current_language' => array( 'id_lang' => $this->context->language->id, 'name' => $this->context->language->name, 'name_simple' => $this->getNameSimple($this->context->language->name) ) ); } 2. Override function getLanguages of class getLanguage unzip file attachment >> upload (via ftp, or cpanel) >> put it in public_html/override/classes/ For case 1: this code will be overriden if you upgrade module. For case 2: It works fine in the case upgrade PS Thanks, Language.zip 1 Link to comment Share on other sites More sharing options...
superskyman100 Posted April 19, 2019 Author Share Posted April 19, 2019 Whouaaaaaa !!!!! 😁 It works so great (i used the case 2 which is much better) ... Thank you very much Prestamonster, you're an ace, i owe u one beer !! :)) Link to comment Share on other sites More sharing options...
prestamonste Posted April 19, 2019 Share Posted April 19, 2019 Thank you for your confirmation. Have a nice weekend! Link to comment Share on other sites More sharing options...
Yankee Store Posted November 14, 2019 Share Posted November 14, 2019 hello i am using over 20 languages and would like the language selector file to sort by language name in alpha order How can i do this ? Thank you in advance for any help Link to comment Share on other sites More sharing options...
popescu.laurentiu Posted August 13 Share Posted August 13 A little late, but there is an easy way of doing just this without the need to change the code. Jost go into you database, "ps_lang" and change the ID of the languages in the order you prefer. You may need to change flag pictures...but is as simple as this Link to comment Share on other sites More sharing options...
Nickz Posted August 13 Share Posted August 13 12 minutes ago, popescu.laurentiu said: You may need to change flag pictures...but is as simple as this simple in your version of prestashop ?????? The thread is 4 years old. 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