Actuna Posted July 18, 2018 Share Posted July 18, 2018 Prepares the shop on PrestaShop 1.6.1.20 and I have encountered the problem that the country name languages are not in the correct language. In my case they were in the Polish default language for EN and DE, to be able to be in English and German. On the internet I found a PHP script that prepares the appropriate change from the database (gives ready SQL queries for manual execution). Source: https://gist.github.com/twesolowski/14bb2bf3e00872915a03 <?php /* * example usage: php parse.php --file="de\data\country.xml" --lang=de --prefix=ps_ * generates imports country translations in DE lang */ $options = getopt(null, array( "file:", // Required "prefix::", // Optional "lang::" // Required )); $file = isset($options['file']) or die("No file"); $lang = isset($options['lang']) or die("No lang"); $file = $options['file']; $lang = $options['lang']; $prefix = isset($options['prefix']) ? $options['prefix'] : "ps_"; file_exists($file) or die("File $file doesn't exist"); $xml=simplexml_load_file($file) or die("Error: Cannot create object"); //var_dump($xml); foreach($xml as $element){ echo 'REPLACE INTO '.$prefix.'country_lang SET id_country= (SELECT id_country FROM '.$prefix.'country WHERE iso_code="'.$element->attributes()->id.'"), id_lang=(SELECT id_lang FROM '.$prefix.'lang WHERE iso_code="'.$lang.'"), name="'.$element->name.'"; '; echo "\n"; } We download XML files from our PrestaShop installation package (for example for EN: prestashop / install / langs / en / data / country.xml) We run the script under the console. The result of the script execution is: (it's just a fragment) (...) REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="NC"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="New Caledonia"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="NI"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Nicaragua"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="NE"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Niger"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="NU"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Niue"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="NF"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Norfolk Island"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="MP"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Northern Mariana Islands"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="OM"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Oman"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PK"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Pakistan"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PW"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Palau"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PS"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Palestinian Territories"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PA"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Panama"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PG"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Papua New Guinea"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PY"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Paraguay"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PE"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Peru"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PH"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Philippines"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PN"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Pitcairn"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="PR"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Puerto Rico"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="QA"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Qatar"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="RE"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Reunion Island"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="RU"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Russian Federation"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="RW"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Rwanda"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="BL"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Saint Barthelemy"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="KN"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Saint Kitts and Nevis"; REPLACE INTO ps_country_lang SET id_country= (SELECT id_country FROM ps_country WHERE iso_code="LC"), id_lang=(SELECT id_lang FROM ps_lang WHERE iso_code="en"), name="Saint Lucia"; (...) and then we only use, for example, PhpMyAdmin to apply changes to the database. I recommend that you make a copy of the database beforehand. 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