Post by nudylady » Wed Mar 11, 2020 1:36 am

I added a language pack. But country and state list are not translated. How to translate them?

New member

Posts

Joined
Sun Feb 19, 2012 12:14 am

Post by Quino » Wed Mar 11, 2020 1:47 am

default you cannot as those are stored in the database, not files, and those tables do not come with a language_id.

New member

Posts

Joined
Fri Feb 28, 2020 1:19 am

Post by nudylady » Wed Mar 11, 2020 7:33 am

is there any extension or instruction can do this?

New member

Posts

Joined
Sun Feb 19, 2012 12:14 am

Post by sw!tch » Wed Mar 11, 2020 8:58 am

Admin ->System -> Localisation -> Countries
Admin ->System -> Localisation -> Zones

As mentioned they are not language dependent so keep that in mind.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by letxobnav » Wed Mar 11, 2020 5:25 pm

depends on how many languages you have now and in the future.

I only have two so I just added a column to the country and zone tables for those names and changed the original name column to name_en.
name_en and name_zh, using the _language-code appendix.
If you have many languages, it would become more economical to put the name in a separate table.


then in model localization country I altered the queries (to select that name field based on language code) from

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$country_id . "' AND status = '1'");
to

Code: Select all

$query = $this->db->query("SELECT country_id,name_".$this->language->data['code']." as name,iso_code_2,iso_code_3,address_format,postcode_required, status FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$country_id . "' AND status = '1'");
and

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE status = '1' ORDER BY name ASC");
to

Code: Select all

$query = $this->db->query("SELECT country_id,name_".$this->language->data['code']." as name,iso_code_2,iso_code_3,address_format,postcode_required, status FROM " . DB_PREFIX . "country WHERE status = '1' ORDER BY name DESC");
so the rest of the code remains the same, the queries just return the name in english or chinese depending on the current language code.

same principle for the zones
You just have to remember that if you add a language, you also have to add a column with the name+language code appendix to those tables or you will get an sql error.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 12 guests