cancel
Showing results for 
Search instead for 
Did you mean: 

Translate a label for another locale does not work

Translate a label for another locale does not work

During Magento2 installation, I chose "Chinese (Hong Kong)" as the locale for the store.

 

After install, I try to customize the "Sign In" label in the frontend page to Chinese. What I did was below:

- Created a new theme which inherits Luma theme (with a custom logo)

- Create a folder "i18n" under the theme directory

- Create a file "zh_HK.csv" (standard locale code for Chinese Hong Kong) with the following line:

  - "Sign In","登入"

- Apply the theme and flush all caches

 

However, when I go to frontend and refresh the page, I cannot see the label in Chinese. I can only change the label when using "en_US" as the locale and enter my custom labels in the file en_US.csv.

 

I am sure the new theme is working as it can load the custom logo.

 

Does anyone else had experience in performing frontend translation in other locale, and provide some advice on how to troubleshoot it?

 

Many thanks

Clarence

 

2 REPLIES 2

Re: Translate a label for another locale does not work

Maybe this can help you: https://community.magento.com/t5/Programming-Questions/Translations-and-language-packs/m-p/25014#U25...

 

I didn't found any official/right answer to be sure but I guess that those steps are neccesary.

Re: Translate a label for another locale does not work

Dear Damian,

 

The page you provide is very useful.

 

The following are the steps that I had taken:

  • Create a language pack for Chinese HK (by cloning your project on github)
  • Publish the package to Packagist
  • In my project, run the following command to install the new language pack via PHP composer:
  • composer require skywidesoft/magento2-language-zh_hk
  • Pack the language pack
  • php bin/magento i18n:pack --mode=merge -d vendor/skywidesoft/magento2-language-zh_hk/zh_hk.csv . zh_Hant_HK
  • However, during the pack command, I run into a problem which complains about invalid character. I found that I need to delete all the single quote characters (i.e. "'") from the csv file
  • Generate the files
  • php bin/magento setup:static-content:deploy zh_Hant_HK

 

I believe there is some issue in the translation tool in handling strings with single quote character.

 

Regards

Clarence