SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
Magento 2 : i18n – how can I rephrase that?
Mage Titans Spain | June 2017
My name is:
Tadhg
- g
About me?
Family always comes first…
Magento comes a distant second ☺ @TadhgBowe
▪ 300+ e-commerce websites since 1997
▪ Substantial e-commerce website experience (ca. 100 yrs)
▪ Magento specialists since 2010 (ca. 100 implementations)
▪ Magento 2 certified
▪ Shopify Plus certified
I work for a company called “Screen Pages”
7 YEARS OF
MAGENTO
Fiesta!! In my own village!!
Viva Madrid!
Today’s Agenda:
i18n in Magento 2
Focus on how language translations work
Let’s look at a few examples
Current limitations
Future nice to haves
Disclaimer:
I AM STILL LEARNING MAGENTO 2 ☺
i18n?
Let’s THINK BIG!
internationalisation and localisation are means of adapting computer
software to different languages, regional differences and technical
requirements of a target market (locale)
Don’t make the customer think!
Locale setting:
Stores > Configuration > General > Locale Options:
Contact Us - Write Us!
module-contact
vendor/magento/module-contact
module-contact: contents of en_US.csv
"Write Us","Write Us"
"Jot us a note and we’ll get back to you as quickly as possible.","Jot us a note and we’ll get back to you as
quickly as possible."
Name,Name
Email,Email
"Phone Number","Phone Number"
"What’s on your mind?","What’s on your mind?"
Submit,Submit
"Name: %name","Name: %name"
"Email: %email","Email: %email"
"Phone Number: %telephone","Phone Number: %telephone"
"Comment: %comment","Comment: %comment"
"Contacts Section","Contacts Section"
Contacts,Contacts
"Contact Us","Contact Us"
Export/Examine all translations:
bin/magento i18n:pack /[SITE PATH]/[SITE_NAME]/en_US.csv -d en_US
"Write Us","Write Us",module,Magento_Contact
Name,Name,module,Magento_Contact
Email,Email,module,Magento_Contact
"Phone Number","Phone Number",module,Magento_Contact
Submit,Submit,module,Magento_Contact
"Continue Shopping","Continue Shopping",module,Magento_Checkout
Email,Email,module,Magento_Catalog
Email,Email,module,Magento_Customer
Let’s take a closer look:
module-contact/view/frontend/templates/form.phtml
…<fieldset class="fieldset">

<legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Write Us') ?></span></legend><br />

<div class="field note no-label"><?php /* @escapeNotVerified */ echo __('Jot us a note and we’ll get back to
you as quickly as possible.') ?></div>

<div class="field name required">

<label class="label" for="name"><span><?php /* @escapeNotVerified */ echo __('Name') ?></span></label>

<div class="control">

<input name="name" id="name" title="<?php /* @escapeNotVerified */ echo __('Name') ?>" value="<?php
echo $block->escapeHtml($this->helper('MagentoContactHelperData')->getPostValue('name') ?: $this-
>helper('MagentoContactHelperData')->getUserName()) ?>" class="input-text" type="text" data-
validate="{required:true}"/>

</div>

</div>

<div class="field email required">

<label class="label" for="email"><span><?php /* @escapeNotVerified */ echo __('Email') ?></span></label>

<div class="control">

<input name="email" id="email" title="<?php /* @escapeNotVerified */ echo __('Email') ?>" value="<?php
echo $block->escapeHtml($this->helper('MagentoContactHelperData')->getPostValue('email') ?: $this-
>helper('MagentoContactHelperData')->getUserEmail()) ?>" class="input-text" type="email" data-
validate="{required:true, 'validate-email':true}"/>

</div>

</div>…
How do translations work:
public function loadData($area = null, $forceReload = false)

{

…

$this->_loadModuleTranslation();

$this->_loadThemeTranslation();

$this->_loadPackTranslation();

$this->_loadDbTranslation();

…
return $this;

}
[YOUR SITE]/vendor/magento/framework/Translate.php
Who wins?
1. $this->_loadDbTranslation();



Not there?
2. $this->_loadPackTranslation();



Not there?
3. $this->_loadThemeTranslation();



Not there?
4. $this->_loadModuleTranslation();



Not there? It will simply output the original phrase.

Golden rules for today:
WEBSITE OWNER ALWAYS THINKING BIG!
e.g. future multilingual website store views,
in-house seasonal store views
Not allowed to change a translation in template files
1. Inline translation:
From our Translate.php: $this->_loadDbTranslation();

Enabled via: Stores > Configuration > Advanced > Developer > Translate Inline > Enabled for
Storefront = Yes
(don’t forget Developer Client Restrictions > Allowed IPs).
Translation Phrases Stored in DB “translation” table.
1. Inline translation:
What about something like “Email”?
Our challenge is to change “Email” to “Your Email Address” and only on the Contact Us Page
Inline Translation: ‘Email’ to ‘Your Email Address’
Inline Translation: ‘Email’ to ‘Your Email Address’
Inline Translation: So where else might ‘Email’ change?
Inline Translations are GLOBAL across the frontend
2. Language Pack:
Language Pack: Folder structure
Language Pack: Example files
Some examples in es_ES.csv:
In our en_GB.csv:
(note: remember to clear your translation caches and any others that apply)
Language Pack: Results…
Language Pack Translations are GLOBAL across the frontend
Happy so far? ☺
3. Theme Translation: Folder structure
Theme Translation: en_GB.csv
In our en_GB.csv:
So! Did it work?
Theme Translation: Results…
Theme Translations are GLOBAL across the frontend
Theme Translation: Module level?
Will this work?!
Theme Translation: Module level - results…
Nothing changed.
So we’re a little stuck!
Nope!
Anything else?
1. $this->_loadDbTranslation(); (GLOBAL)

2. $this->_loadPackTranslation(); (GLOBAL)

3. $this->_loadThemeTranslation(); (GLOBAL)

4. $this->_loadModuleTranslation(); (MODULE)

What about theme level changes in a foreign language website
e.g. two Spanish store views?
How about this solution:
1. $this->_loadDbTranslation(); (GLOBAL)

2. $this->_loadThemeModuleTranslation(); (MODULE)

3. $this->_loadThemeTranslation(); (GLOBAL)

4. $this->_loadPackTranslation(); (GLOBAL)

5. $this->_loadModuleTranslation(); (MODULE)

But what about super active client…?
What if the client wants to change their own translations at a
very specific module level!?
Now we’re going places! ☺
1. $this->_loadClientMediaThemeModuleTranslation(); (MODULE)

2. $this->_loadClientMediaThemeTranslation(); (GLOBAL)

3. $this->_loadDbTranslation(); (GLOBAL) 

4. $this->_loadThemeModuleTranslation(); (MODULE)

5. $this->_loadThemeTranslation(); (GLOBAL)

6. $this->_loadPackTranslation(); (GLOBAL)

7. $this->_loadModuleTranslation(); (MODULE)

Our solution inside a module:
Getting thirsty… hurry up Tadhg!
Basket page translations:
Comes from a js-translation.json file
(pub/static/frontend/theme/locale)
Basket page translations: where they come from
<!-- ko ifnot: getCartParam('summary_count') -->

<strong class="subtitle empty" data-bind="visible:
closeSidebar()">

<!-- ko i18n: 'You have no items in your shopping cart.' --
><!-- /ko -->

</strong>
.../module-checkout/view/frontend/web/template/minicart/content.html
…/module-checkout/view/frontend/templates/cart/noItems.phtml
<div class="cart-empty">

<?php echo $block->getChildHtml('checkout_cart_empty_widget'); ?>

<p><?php echo __('You have no items in your shopping cart.') ?></p>
…

</div>
…
Be careful with this file!
Oops.
Careful: Theme translations don’t currently work with js-translation.json file.
In vendor/magento/module-translation/Model/Json/PreProcessor.php function process(…)
$area = $this->areaList->getArea($areaCode);
$area->load(MagentoFrameworkAppArea::PART_TRANSLATE);
needs to be:
$area = $this->areaList->getArea($areaCode);
$area->load(MagentoFrameworkAppArea::PART_DESIGN);
$area->load(MagentoFrameworkAppArea::PART_TRANSLATE);
Ref: https://github.com/magento/magento2/issues/8508#issuecomment-281329241
Careful when you change a phrase!
Another nice to have: Translation Phrase -> CMS Block:
In our en_GB.csv:
"Jot us a note and we’ll get back to you as quickly as possible.","{{{Contact_Us_Write_To_Us_Into}}}"
To summarise:
▪ Magento 2 has translations well covered.

▪ Make sure you create a i18n folder and translation .csv in your module.
▪ Try to avoid making phrase changes directly in template files.

▪ Be careful when making an existing phrase change. Does it exist elsewhere!?

▪ Read the devdocs ☺ devdocs.magento.com/guides/v2.0/ search for “Translations”

▪ Drink Horchata – It’s good for you too apparently! ☺
OMG! There’s an English (Ireland) locale…
Finally my favourite Irish translation phrase…
“to be sure”,”to be sure”
I
Cheers!
@TadhgBowe
Good Luck To You All! Gracias.

Contenu connexe

Similaire à Tadhg Bowe - i18n: how can I rephrase that?

Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
Byrne Reese
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
references
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
Anthony Montalbano
 

Similaire à Tadhg Bowe - i18n: how can I rephrase that? (20)

Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Screen Pages - Mage Titans - i18n Translations - Magento 2
Screen Pages  - Mage Titans - i18n Translations - Magento 2Screen Pages  - Mage Titans - i18n Translations - Magento 2
Screen Pages - Mage Titans - i18n Translations - Magento 2
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
WordPress Standardized Loop API
WordPress Standardized Loop APIWordPress Standardized Loop API
WordPress Standardized Loop API
 
Symfony 1, mi viejo amigo
Symfony 1, mi viejo amigoSymfony 1, mi viejo amigo
Symfony 1, mi viejo amigo
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
 
Mangento
MangentoMangento
Mangento
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
 
Magento++
Magento++Magento++
Magento++
 
Shopify Partner Social
Shopify Partner SocialShopify Partner Social
Shopify Partner Social
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
Hacking Movable Type
Hacking Movable TypeHacking Movable Type
Hacking Movable Type
 
Develop magento 2 custom shipping module
Develop magento 2 custom shipping moduleDevelop magento 2 custom shipping module
Develop magento 2 custom shipping module
 
Test upload
Test uploadTest upload
Test upload
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
How to create multi language store in magento 2
How to create multi language store in magento 2How to create multi language store in magento 2
How to create multi language store in magento 2
 
Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 

Plus de Mage Titans ES

Plus de Mage Titans ES (6)

David Bolufer - Make your magento2 fly2
David Bolufer - Make your magento2 fly2David Bolufer - Make your magento2 fly2
David Bolufer - Make your magento2 fly2
 
Oliver Montes - Chatbots para programadores y gestores eCommerce
Oliver Montes - Chatbots para programadores y gestores eCommerceOliver Montes - Chatbots para programadores y gestores eCommerce
Oliver Montes - Chatbots para programadores y gestores eCommerce
 
Eli Barnett - El Comercio Unificado, borrando fronteras entre el mundo físico...
Eli Barnett - El Comercio Unificado, borrando fronteras entre el mundo físico...Eli Barnett - El Comercio Unificado, borrando fronteras entre el mundo físico...
Eli Barnett - El Comercio Unificado, borrando fronteras entre el mundo físico...
 
Miguel Balparda - Haciendo su vida más fácil con Magento 2 y la terminal
Miguel Balparda - Haciendo su vida más fácil con Magento 2 y la terminalMiguel Balparda - Haciendo su vida más fácil con Magento 2 y la terminal
Miguel Balparda - Haciendo su vida más fácil con Magento 2 y la terminal
 
Mikel Ruiz - Magento X-Files
Mikel Ruiz - Magento X-FilesMikel Ruiz - Magento X-Files
Mikel Ruiz - Magento X-Files
 
Oscar recio - De 0 a 100 con Magento 2
Oscar recio  -  De 0 a 100 con Magento 2Oscar recio  -  De 0 a 100 con Magento 2
Oscar recio - De 0 a 100 con Magento 2
 

Dernier

VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
nilamkumrai
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
nirzagarg
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 

Dernier (20)

VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 

Tadhg Bowe - i18n: how can I rephrase that?

  • 1. Magento 2 : i18n – how can I rephrase that? Mage Titans Spain | June 2017
  • 3. About me? Family always comes first… Magento comes a distant second ☺ @TadhgBowe
  • 4. ▪ 300+ e-commerce websites since 1997 ▪ Substantial e-commerce website experience (ca. 100 yrs) ▪ Magento specialists since 2010 (ca. 100 implementations) ▪ Magento 2 certified ▪ Shopify Plus certified I work for a company called “Screen Pages” 7 YEARS OF MAGENTO
  • 5. Fiesta!! In my own village!!
  • 7. Today’s Agenda: i18n in Magento 2 Focus on how language translations work Let’s look at a few examples Current limitations Future nice to haves
  • 8. Disclaimer: I AM STILL LEARNING MAGENTO 2 ☺
  • 9. i18n? Let’s THINK BIG! internationalisation and localisation are means of adapting computer software to different languages, regional differences and technical requirements of a target market (locale)
  • 10. Don’t make the customer think!
  • 11. Locale setting: Stores > Configuration > General > Locale Options:
  • 12. Contact Us - Write Us!
  • 14. module-contact: contents of en_US.csv "Write Us","Write Us" "Jot us a note and we’ll get back to you as quickly as possible.","Jot us a note and we’ll get back to you as quickly as possible." Name,Name Email,Email "Phone Number","Phone Number" "What’s on your mind?","What’s on your mind?" Submit,Submit "Name: %name","Name: %name" "Email: %email","Email: %email" "Phone Number: %telephone","Phone Number: %telephone" "Comment: %comment","Comment: %comment" "Contacts Section","Contacts Section" Contacts,Contacts "Contact Us","Contact Us"
  • 15. Export/Examine all translations: bin/magento i18n:pack /[SITE PATH]/[SITE_NAME]/en_US.csv -d en_US "Write Us","Write Us",module,Magento_Contact Name,Name,module,Magento_Contact Email,Email,module,Magento_Contact "Phone Number","Phone Number",module,Magento_Contact Submit,Submit,module,Magento_Contact "Continue Shopping","Continue Shopping",module,Magento_Checkout Email,Email,module,Magento_Catalog Email,Email,module,Magento_Customer
  • 16. Let’s take a closer look:
  • 17. module-contact/view/frontend/templates/form.phtml …<fieldset class="fieldset">
 <legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Write Us') ?></span></legend><br />
 <div class="field note no-label"><?php /* @escapeNotVerified */ echo __('Jot us a note and we’ll get back to you as quickly as possible.') ?></div>
 <div class="field name required">
 <label class="label" for="name"><span><?php /* @escapeNotVerified */ echo __('Name') ?></span></label>
 <div class="control">
 <input name="name" id="name" title="<?php /* @escapeNotVerified */ echo __('Name') ?>" value="<?php echo $block->escapeHtml($this->helper('MagentoContactHelperData')->getPostValue('name') ?: $this- >helper('MagentoContactHelperData')->getUserName()) ?>" class="input-text" type="text" data- validate="{required:true}"/>
 </div>
 </div>
 <div class="field email required">
 <label class="label" for="email"><span><?php /* @escapeNotVerified */ echo __('Email') ?></span></label>
 <div class="control">
 <input name="email" id="email" title="<?php /* @escapeNotVerified */ echo __('Email') ?>" value="<?php echo $block->escapeHtml($this->helper('MagentoContactHelperData')->getPostValue('email') ?: $this- >helper('MagentoContactHelperData')->getUserEmail()) ?>" class="input-text" type="email" data- validate="{required:true, 'validate-email':true}"/>
 </div>
 </div>…
  • 18. How do translations work: public function loadData($area = null, $forceReload = false)
 {
 …
 $this->_loadModuleTranslation();
 $this->_loadThemeTranslation();
 $this->_loadPackTranslation();
 $this->_loadDbTranslation();
 … return $this;
 } [YOUR SITE]/vendor/magento/framework/Translate.php
  • 19. Who wins? 1. $this->_loadDbTranslation();
 
 Not there? 2. $this->_loadPackTranslation();
 
 Not there? 3. $this->_loadThemeTranslation();
 
 Not there? 4. $this->_loadModuleTranslation();
 
 Not there? It will simply output the original phrase.

  • 20. Golden rules for today: WEBSITE OWNER ALWAYS THINKING BIG! e.g. future multilingual website store views, in-house seasonal store views Not allowed to change a translation in template files
  • 21. 1. Inline translation: From our Translate.php: $this->_loadDbTranslation();
 Enabled via: Stores > Configuration > Advanced > Developer > Translate Inline > Enabled for Storefront = Yes (don’t forget Developer Client Restrictions > Allowed IPs). Translation Phrases Stored in DB “translation” table.
  • 23. What about something like “Email”? Our challenge is to change “Email” to “Your Email Address” and only on the Contact Us Page
  • 24. Inline Translation: ‘Email’ to ‘Your Email Address’
  • 25. Inline Translation: ‘Email’ to ‘Your Email Address’
  • 26. Inline Translation: So where else might ‘Email’ change? Inline Translations are GLOBAL across the frontend
  • 29. Language Pack: Example files Some examples in es_ES.csv: In our en_GB.csv: (note: remember to clear your translation caches and any others that apply)
  • 30. Language Pack: Results… Language Pack Translations are GLOBAL across the frontend
  • 32. 3. Theme Translation: Folder structure
  • 33. Theme Translation: en_GB.csv In our en_GB.csv: So! Did it work?
  • 34. Theme Translation: Results… Theme Translations are GLOBAL across the frontend
  • 35. Theme Translation: Module level? Will this work?!
  • 36. Theme Translation: Module level - results… Nothing changed. So we’re a little stuck! Nope!
  • 37. Anything else? 1. $this->_loadDbTranslation(); (GLOBAL)
 2. $this->_loadPackTranslation(); (GLOBAL)
 3. $this->_loadThemeTranslation(); (GLOBAL)
 4. $this->_loadModuleTranslation(); (MODULE)
 What about theme level changes in a foreign language website e.g. two Spanish store views?
  • 38. How about this solution: 1. $this->_loadDbTranslation(); (GLOBAL)
 2. $this->_loadThemeModuleTranslation(); (MODULE)
 3. $this->_loadThemeTranslation(); (GLOBAL)
 4. $this->_loadPackTranslation(); (GLOBAL)
 5. $this->_loadModuleTranslation(); (MODULE)

  • 39. But what about super active client…? What if the client wants to change their own translations at a very specific module level!?
  • 40. Now we’re going places! ☺ 1. $this->_loadClientMediaThemeModuleTranslation(); (MODULE)
 2. $this->_loadClientMediaThemeTranslation(); (GLOBAL)
 3. $this->_loadDbTranslation(); (GLOBAL) 
 4. $this->_loadThemeModuleTranslation(); (MODULE)
 5. $this->_loadThemeTranslation(); (GLOBAL)
 6. $this->_loadPackTranslation(); (GLOBAL)
 7. $this->_loadModuleTranslation(); (MODULE)

  • 41. Our solution inside a module:
  • 43. Basket page translations: Comes from a js-translation.json file (pub/static/frontend/theme/locale)
  • 44. Basket page translations: where they come from <!-- ko ifnot: getCartParam('summary_count') -->
 <strong class="subtitle empty" data-bind="visible: closeSidebar()">
 <!-- ko i18n: 'You have no items in your shopping cart.' -- ><!-- /ko -->
 </strong> .../module-checkout/view/frontend/web/template/minicart/content.html …/module-checkout/view/frontend/templates/cart/noItems.phtml <div class="cart-empty">
 <?php echo $block->getChildHtml('checkout_cart_empty_widget'); ?>
 <p><?php echo __('You have no items in your shopping cart.') ?></p> …
 </div> …
  • 45. Be careful with this file!
  • 46. Oops. Careful: Theme translations don’t currently work with js-translation.json file. In vendor/magento/module-translation/Model/Json/PreProcessor.php function process(…) $area = $this->areaList->getArea($areaCode); $area->load(MagentoFrameworkAppArea::PART_TRANSLATE); needs to be: $area = $this->areaList->getArea($areaCode); $area->load(MagentoFrameworkAppArea::PART_DESIGN); $area->load(MagentoFrameworkAppArea::PART_TRANSLATE); Ref: https://github.com/magento/magento2/issues/8508#issuecomment-281329241
  • 47. Careful when you change a phrase!
  • 48. Another nice to have: Translation Phrase -> CMS Block: In our en_GB.csv: "Jot us a note and we’ll get back to you as quickly as possible.","{{{Contact_Us_Write_To_Us_Into}}}"
  • 49. To summarise: ▪ Magento 2 has translations well covered.
 ▪ Make sure you create a i18n folder and translation .csv in your module. ▪ Try to avoid making phrase changes directly in template files.
 ▪ Be careful when making an existing phrase change. Does it exist elsewhere!?
 ▪ Read the devdocs ☺ devdocs.magento.com/guides/v2.0/ search for “Translations”
 ▪ Drink Horchata – It’s good for you too apparently! ☺
  • 50. OMG! There’s an English (Ireland) locale…
  • 51. Finally my favourite Irish translation phrase… “to be sure”,”to be sure” I
  • 52. Cheers! @TadhgBowe Good Luck To You All! Gracias.