Magento 2 Training : Unit 6 – Lesson D

Change FO language

You choose the store language during Magento installation.
If you want to change it, you have to change the following configuration : Store > Settings > Configuration

change language store

Choose the language you want, I chose “french”.
If you check the select element html, you will see the value “fr_FR”

I give you the list of all countries with their code :

af_ZA => Afrikaans (Suid-Afrika) / Afrikaans (South Africa)
az_Latn_AZ => Azərbaycan (Azərbaycan) / Azerbaijani (Azerbaijan)
id_ID => Bahasa Indonesia (Indonesia) / Indonesian (Indonesia)
ms_Latn_MY => Bahasa Melayu (Malaysia) / Malay (Malaysia)
bs_Latn_BA => Bosanski (Bosna i Hercegovina) / Bosnian (Bosnia and Herzegovina)
ca_ES => Català (Espanya) / Catalan (Spain)
cy_GB => Cymraeg (Y Deyrnas Unedig) / Welsh (United Kingdom)
da_DK => Dansk (Danmark) / Danish (Denmark)
de_DE => Deutsch (Deutschland) / German (Germany)
de_CH => Deutsch (Schweiz) / German (Switzerland)
de_AT => Deutsch (Österreich) / German (Austria)
et_EE => Eesti (Eesti) / Estonian (Estonia)
en_AU => English (Australia) / English (Australia)
en_CA => English (Canada) / English (Canada)
en_IE => English (Ireland) / English (Ireland)
en_NZ => English (New Zealand) / English (New Zealand)
en_GB" selected="selected => English (United Kingdom) / English (United Kingdom)
en_US => English (United States) / English (United States)
es_AR => Español (Argentina) / Spanish (Argentina)
es_CL => Español (Chile) / Spanish (Chile)
es_CO => Español (Colombia) / Spanish (Colombia)
es_CR => Español (Costa Rica) / Spanish (Costa Rica)
es_ES => Español (España) / Spanish (Spain)
es_MX => Español (México) / Spanish (Mexico)
es_PA => Español (Panamá) / Spanish (Panama)
es_PE => Español (Perú) / Spanish (Peru)
es_VE => Español (Venezuela) / Spanish (Venezuela)
eu_ES => Euskara (Espainia) / Basque (Spain)
fil_PH => Filipino (Pilipinas) / Filipino (Philippines)
fr_CA => Français (Canada) / French (Canada)
fr_FR => Français (France) / French (France)
gl_ES => Galego (España) / Galician (Spain)
hr_HR => Hrvatski (Hrvatska) / Croatian (Croatia)
it_IT => Italiano (Italia) / Italian (Italy)
it_CH => Italiano (Svizzera) / Italian (Switzerland)
sw_KE => Kiswahili (Kenya) / Swahili (Kenya)
lv_LV => Latviešu (Latvija) / Latvian (Latvia)
lt_LT => Lietuvių (Lietuva) / Lithuanian (Lithuania)
hu_HU => Magyar (Magyarország) / Hungarian (Hungary)
nl_NL => Nederlands (Nederland) / Dutch (Netherlands)
nb_NO => Norsk Bokmål (Norge) / Norwegian Bokmål (Norway)
nn_NO => Nynorsk (Noreg) / Norwegian Nynorsk (Norway)
pl_PL => Polski (Polska) / Polish (Poland)
pt_BR => Português (Brasil) / Portuguese (Brazil)
pt_PT => Português (Portugal) / Portuguese (Portugal)
ro_RO => Română (România) / Romanian (Romania)
sq_AL => Shqip (Shqipëri) / Albanian (Albania)
sk_SK => Slovenčina (Slovensko) / Slovak (Slovakia)
sl_SI => Slovenščina (Slovenija) / Slovenian (Slovenia)
fi_FI => Suomi (Suomi) / Finnish (Finland)
sv_SE => Svenska (Sverige) / Swedish (Sweden)
vi_VN => Tiếng Việt (Việt Nam) / Vietnamese (Vietnam)
tr_TR => Türkçe (Türkiye) / Turkish (Turkey)
is_IS => íslenska (Ísland) / Icelandic (Iceland)
cs_CZ => čeština (Česká republika) / Czech (Czech Republic)
el_GR => Ελληνικά (Ελλάδα) / Greek (Greece)
sr_Cyrl_RS => Српски (Србија) / Serbian (Serbia)
be_BY => беларуская (Беларусь) / Belarusian (Belarus)
bg_BG => български (България) / Bulgarian (Bulgaria)
mk_MK => македонски (Македонија) / Macedonian (Macedonia)
mn_Cyrl_MN => монгол (Монгол) / Mongolian (Mongolia)
ru_RU => русский (Россия) / Russian (Russia)
uk_UA => українська (Україна) / Ukrainian (Ukraine)
he_IL => עברית (ישראל) / Hebrew (Israel)
ar_DZ => العربية (الجزائر) / Arabic (Algeria)
ar_KW => العربية (الكويت) / Arabic (Kuwait)
ar_MA => العربية (المغرب) / Arabic (Morocco)
ar_SA => العربية (المملكة العربية السعودية) / Arabic (Saudi Arabia)
ar_EG => العربية (مصر) / Arabic (Egypt)
fa_IR => فارسی (ایران) / Persian (Iran)
hi_IN => हिंदी (भारत) / Hindi (India)
bn_BD => বাংলা (বাংলাদেশ) / Bengali (Bangladesh)
gu_IN => ગુજરાતી (ભારત) / Gujarati (India)
th_TH => ไทย (ไทย) / Thai (Thailand)
lo_LA => ລາວ (ລາວ) / Lao (Laos)
ka_GE => ქართული (საქართველო) / Georgian (Georgia)
km_KH => ខ្មែរ (កម្ពុជា) / Khmer (Cambodia)
zh_Hans_CN => 中文 (中国) / Chinese (China)
zh_Hant_HK => 中文 (中華人民共和國香港特別行政區) / Chinese (Hong Kong SAR China)
zh_Hant_TW => 中文 (台灣) / Chinese (Taiwan)
ja_JP => 日本語 (日本) / Japanese (Japan)
ko_KR => 한국어 (대한민국) / Korean (South Korea)

On the next part, I will explain how the magento configuration works.
Now, you just have to choose “French” and save (If your website isn’t already in french)

Change BO language

Before adding translation file, I will show you how to change the BO language.

You have to change the value of Interface Locale :

change language bo

After save, the BO can stay in english because Magento translations files are not present. In this case, it will take the value written in the code (in english).
All content will be put in english on your code and translations files will change them on the language you want.

Translations file creation

Create the file :
app/code/Maxime/Jobs/i18n/fr_FR.csv

The filename “fr_FR” is the code of the language I want.
Translations are case sensitive, and work on FO and on BO.

For the jobs module, I put these translations :

"We are hiring","Nous recrutons"
"Department","Département"
"Departments","Départements"
"Department : ","Département : "
"New Department","Nouveau Département"
"Department Name","Nom du Département"
"Department Description","Description du Département"
"Save and Continue Edit","Sauvegarder et continuer l'édition"
"Save Department","Sauvegarder le Département"
"General Information","Informations générales"
"Add New Department","Ajouter un départment"
"Department saved","Département enregistré"
"Department deleted","Département supprimé"
"Name","Nom"
"A total of %1 record(s) have been deleted.","%1 entrée(s) ont été supprimée(s)"
"Job","Offre d'emploi"
"Jobs","Offres d'emploi"
"New Job","Nouvelle Offre"
"Save and Continue Edit","Sauvegarder et continuer l'édition"
"Save Job","Sauvegarder l'offre"
"General Information","Informations générales"
"Add New job","Ajouter une offre"
"Job saved","Offre d'emploi enregistrée"
"Job deleted","Offre d'emploi supprimée"
"Title","Titre"
"Type","Type"
"Location","Localisation"
"Date","Date"
"Status","Statut"
"Enabled","Activé"
"Disabled","Désactivé"

How it works?
If you check the content we put during previous lessons, you will see on XML files the specific attribute :
translate="true"

Inside classes and templates, we used this method :
__('MY TEXT TO TRANSLATE')

Render on FO and BO

If you go on the Magento BO, you will see the translated module :

translations bo

If you click on one link, the module’s texts are in french in the grid.
You have to put on your module translation file only the texts of your module.

And the render in front :

translations fo

Our translations are OK ! Next time, I will explain how to change the module icon on the BO. The one we have now isn’t really sexy :

icone bo

And after, we will learn how to add new configuration on the Magento backoffice, and how it works !

Continue training
Return to previous lesson
Add translations on your Magento 2 module
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *

We use cookies to ensure that we give you the best experience on our website.
Ok