From 09e92e65339284e3ed9b4fab31fd551c7938fdff Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Tue, 12 Jul 2016 16:19:17 +0800 Subject: [PATCH 1/4] add i18n guide --- docs/developer_i18n_guide.md | 55 ------------------------------------ 1 file changed, 55 deletions(-) delete mode 100644 docs/developer_i18n_guide.md diff --git a/docs/developer_i18n_guide.md b/docs/developer_i18n_guide.md deleted file mode 100644 index d512ef7d0..000000000 --- a/docs/developer_i18n_guide.md +++ /dev/null @@ -1,55 +0,0 @@ -# Developer's guide for internationalization - -*NOTE: All the files you created should be in UTF-8 encoding.* - ->**For the front-end i18n works,** - -1. You need to create a JavaScript i18n source file under the diretory `/static/resources/js/services/i18n`, it should be named as `locale_messages__.js` with your localized translations. - - This file contains a JSON object named `locale_messages`, and the sample pattern should be like below, - ``` - var local_messages = { - 'sign_in': 'Sign In' - }; - ``` - **NOTE: Please refer the keys which already exist in other i18n files to make your corresponding translations as your locale.** - -2. After creating this locale file, you should include it into the HTML page header template. - - In the file, `/views/sections/header-include.htm`. This template would be rendered by the back-end controller, with checking the current language (`.Lang`) value from the request scope, at each time there is only one script tag would be rendered at front-end page. - ``` - {{ if eq .Lang "zh-CN" }} - - {{ else if eq .Lang "en-US"}} - - {{ else if eq .Lang "-"}} - - {{ end }} - ``` -3. Add the new coming language to the `I18nService` module. - - In the file, `/static/resources/js/services/i18n/services.i18n.js`, append new key-value item to the `supportLanguages` object. - ``` - var supportLanguages = { - 'en-US': 'English', - 'zh-CN': '中文', - '-': '' - }; - ``` - **NOTE: Don't miss to add a comma ahead of the new key-value item you've added.** - ->**For the back-end i18n works,** - -1. Create a file under the directory `/static/i18n/`, named as `locale_-.ini`. - - **NOTE: Please refer the keys which already exist in other i18n files to make your corresponding translations as your locale.** - -2. Add the new comming language to the `app.conf` file. - - In the file, `/Deploy/config/ui/app.conf`, append new item to the configuration section. - ``` - [lang] - types = en-US|zh-CN|- - names = en-US|zh-CN|- - ``` ->**Rebuild and start the Harbor project by using 'docker-compose' command.** \ No newline at end of file From ac99a4c28d517df6a13493feffb9620570faef00 Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Tue, 12 Jul 2016 16:21:22 +0800 Subject: [PATCH 2/4] add i18n guide --- docs/developer_guide_i18n.md | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 docs/developer_guide_i18n.md diff --git a/docs/developer_guide_i18n.md b/docs/developer_guide_i18n.md new file mode 100644 index 000000000..c6cb16ccb --- /dev/null +++ b/docs/developer_guide_i18n.md @@ -0,0 +1,58 @@ +## Developer's Guide for Internationalization (i18n) + +*NOTE: All the files you created should use UTF-8 encoding.* + +### Steps to localize the UI in your language + +1. Copy the file `static/resources/js/services/i18n/locale_messages_en-US.js` to a new file in the same directory named `locale_messages__.js` . + + The file contains a JSON object named `locale_messages`, which consists of key-value pairs of UI strings: + ``` + var local_messages = { + 'sign_in': 'Sign In', + 'sign_up': 'Sign Up', + ... + }; + ``` + In the file `locale_messages__.js`, translate all the values into your language. Do not change any keys. + +2. After creating your locale file, you should include it from the HTML page header template. + + In the file `views/sections/header-include.htm`, look for a `if` statement which switch langauges based on the current language (`.Lang`) value. Add in a `else if` statement for your language: + ``` + {{ if eq .Lang "zh-CN" }} + + {{ else if eq .Lang "en-US"}} + + {{ else if eq .Lang "-"}} + + {{ end }} + ``` +3. Add the new coming language to the `I18nService` module. + + In the file `static/resources/js/services/i18n/services.i18n.js`, append a new key-value item to the `supportLanguages` object. This value will be displayed in the language dropdown list in the UI. + ``` + var supportLanguages = { + 'en-US': 'English', + 'zh-CN': '中文', + '-': '' + }; + ``` + **NOTE: Don't miss the comma before the new key-value item you've added.** + + +4. In the directory `static/i18n/`, copy the file `locale_en-US.ini` to a new file named `locale_-.ini`. In this file, translate all the values on the right hand side into your language. Do not change any keys. + +5. Add the new language to the `app.conf` file. + + In the file `Deploy/config/ui/app.conf`, append a new item to the configuration section. + ``` + [lang] + types = en-US|zh-CN|- + names = en-US|zh-CN|- + ``` + +6. Next, change to `Deploy/` directory, rebuild and start the Harbor by the below command: + ``` + docker-compose up --build -d + ``` From 6dad7166c2a97a4d21c86f4d57a17f6498648e87 Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Tue, 12 Jul 2016 16:29:40 +0800 Subject: [PATCH 3/4] update i18n guide --- docs/developer_guide_i18n.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/developer_guide_i18n.md b/docs/developer_guide_i18n.md index c6cb16ccb..3c828922f 100644 --- a/docs/developer_guide_i18n.md +++ b/docs/developer_guide_i18n.md @@ -24,11 +24,11 @@ {{ else if eq .Lang "en-US"}} - {{ else if eq .Lang "-"}} - + ** {{ else if eq .Lang "-"}} + ** {{ end }} ``` -3. Add the new coming language to the `I18nService` module. +3. Add the new language to the `I18nService` module. In the file `static/resources/js/services/i18n/services.i18n.js`, append a new key-value item to the `supportLanguages` object. This value will be displayed in the language dropdown list in the UI. ``` @@ -52,7 +52,9 @@ names = en-US|zh-CN|- ``` -6. Next, change to `Deploy/` directory, rebuild and start the Harbor by the below command: +6. Next, change to `Deploy/` directory, rebuild and restart the Harbor by the below command: ``` + docker-compose down docker-compose up --build -d ``` + \ No newline at end of file From ef771920807fea7966644b77bcd98d2153fec035 Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Tue, 12 Jul 2016 16:31:58 +0800 Subject: [PATCH 4/4] update i18n guide --- docs/developer_guide_i18n.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/developer_guide_i18n.md b/docs/developer_guide_i18n.md index 3c828922f..df3f58ab2 100644 --- a/docs/developer_guide_i18n.md +++ b/docs/developer_guide_i18n.md @@ -24,8 +24,8 @@ {{ else if eq .Lang "en-US"}} - ** {{ else if eq .Lang "-"}} - ** + {{ else if eq .Lang "-"}} + {{ end }} ``` 3. Add the new language to the `I18nService` module.