diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /doc/development/i18n | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'doc/development/i18n')
-rw-r--r-- | doc/development/i18n/externalization.md | 128 | ||||
-rw-r--r-- | doc/development/i18n/proofreader.md | 103 | ||||
-rw-r--r-- | doc/development/i18n/translation.md | 4 |
3 files changed, 130 insertions, 105 deletions
diff --git a/doc/development/i18n/externalization.md b/doc/development/i18n/externalization.md index 796a1f44ccd..53825f0904a 100644 --- a/doc/development/i18n/externalization.md +++ b/doc/development/i18n/externalization.md @@ -131,40 +131,70 @@ You can mark that content for translation with: ### JavaScript files -In JavaScript we added the `__()` (double underscore parenthesis) function that -you can import from the `~/locale` file. For instance: +The `~/locale` module exports the following key functions for externalization: + +- `__()` (double underscore parenthesis) +- `s__()` (namespaced double underscore parenthesis) +- `__()` Mark content for translation (note the double underscore). +- `s__()` Mark namespaced content for translation +- `n__()` Mark pluralized content for translation ```javascript -import { __ } from '~/locale'; +import { __, s__, n__ } from '~/locale'; + +const defaultErrorMessage = s__('Branches|Create branch failed.'); const label = __('Subscribe'); +const message = n__('Apple', 'Apples', 3) ``` -To test JavaScript translations you must: - -- Change the GitLab localization to a language other than English. -- Generate JSON files by using `bin/rake gettext:po_to_json` or `bin/rake gettext:compile`. +To test JavaScript translations, learn about [manually testing translations from the UI](#manually-test-translations-from-the-ui). ### Vue files -In Vue files, we make the following functions available: +In Vue files, we make the following functions available to Vue templates using the `translate` mixin: -- `__()` (double underscore parenthesis) -- `s__()` (namespaced double underscore parenthesis) +- `__()` +- `s__()` +- `n__()` +- `sprintf` -You can therefore import from the `~/locale` file. -For example: +This means you can externalize strings in Vue templates without having to import these functions from the `~/locale` file: -```javascript -import { __, s__ } from '~/locale'; -const label = __('Subscribe'); -const nameSpacedlabel = __('Plan|Subscribe'); +```html +<template> + <h1>{{ s__('Branches|Create a new branch') }}</h1> + <gl-button>{{ __('Create branch') }}</gl-button> +</template> ``` -For the static text strings we suggest two patterns for using these translations in Vue files: +If you need to translate strings in the Vue component's JavaScript, you can import the necessary externalization function from the `~/locale` file as described in the [JavaScript files](#javascript-files) section. -- External constants file: +To test Vue translations, learn about [manually testing translations from the UI](#manually-test-translations-from-the-ui). - ```javascript +#### Recommendations + +If strings are reused throughout a component, it can be useful to define these strings as variables. We recommend defining an `i18n` property on the component's `$options` object. If there is a mixture of many-use and single-use strings in the component, consider using this approach to create a local [Single Source of Truth](https://about.gitlab.com/handbook/values/#single-source-of-truth) for externalized strings. + +```javascript +<script> + export default { + i18n: { + buttonLabel: s__('Plan|Button Label') + } + }, +</script> + +<template> + <gl-button :aria-label="$options.i18n.buttonLabel"> + {{ $options.i18n.buttonLabel }} + </gl-button> +</template> +``` + +Also consider defining these strings in a `constants.js` file, especially if they need +to be shared across different modules. + +```javascript javascripts │ └───alert_settings @@ -179,60 +209,41 @@ For the static text strings we suggest two patterns for using these translations /* Integration constants */ - export const I18N_ALERT_SETTINGS_FORM = { - saveBtnLabel: __('Save changes'), - }; + export const MSG_ALERT_SETTINGS_FORM_ERROR = __('Failed to save alert settings.') // alert_settings_form.vue import { - I18N_ALERT_SETTINGS_FORM, + MSG_ALERT_SETTINGS_FORM_ERROR, } from '../constants'; <script> export default { - i18n: { - I18N_ALERT_SETTINGS_FORM, - } + MSG_ALERT_SETTINGS_FROM_ERROR, } </script> <template> - <gl-button - ref="submitBtn" - variant="success" - type="submit" - > - {{ $options.i18n.I18N_ALERT_SETTINGS_FORM }} - </gl-button> + <gl-alert v-if="showAlert"> + {{ $options.MSG_ALERT_SETTINGS_FORM_ERROR }} + </gl-alert> </template> - ``` - - When possible, you should opt for this pattern, as this allows you to import these strings directly into your component specs for re-use during testing. - -- Internal component `$options` object: +``` - ```javascript - <script> - export default { - i18n: { - buttonLabel: s__('Plan|Button Label') - } - }, - </script> +Using either `constants` or `$options.i18n` allows us to reference messages directly in specs: - <template> - <gl-button :aria-label="$options.i18n.buttonLabel"> - {{ $options.i18n.buttonLabel }} - </gl-button> - </template> - ``` +```javascript +import { MSG_ALERT_SETTINGS_FORM_ERROR } from 'path/to/constants.js'; -To visually test the Vue translations: +// okay +expect(wrapper.text()).toEqual('this test will fail just from button text changing!'); -1. Change the GitLab localization to another language than English. -1. Generate JSON files using `bin/rake gettext:po_to_json` or `bin/rake gettext:compile`. +// better +expect(wrapper.text()).toEqual(MyComponent.i18n.buttonLabel); +// also better +expect(wrapper.text()).toEqual(MSG_ALERT_SETTINGS_FORM_ERROR); +``` ### Dynamic translations @@ -853,3 +864,10 @@ Suppose you want to add translations for a new language, for example, French: git add locale/fr/ app/assets/javascripts/locale/fr/ git commit -m "Add French translations for Value Stream Analytics page" ``` + +## Manually test translations from the UI + +To manually test Vue translations: + +1. Change the GitLab localization to another language than English. +1. Generate JSON files using `bin/rake gettext:po_to_json` or `bin/rake gettext:compile`. diff --git a/doc/development/i18n/proofreader.md b/doc/development/i18n/proofreader.md index 6e3b32e18df..462c3fde7d6 100644 --- a/doc/development/i18n/proofreader.md +++ b/doc/development/i18n/proofreader.md @@ -12,88 +12,91 @@ are very appreciative of the work done by translators and proofreaders! ## Proofreaders <!-- vale gitlab.Spelling = NO --> + - Albanian - Proofreaders needed. - Amharic - - Tsegaselassie Tadesse - [GitLab](https://gitlab.com/tsega), [CrowdIn](https://crowdin.com/profile/tsegaselassi/activity) + - Tsegaselassie Tadesse - [GitLab](https://gitlab.com/tsega), [Crowdin](https://crowdin.com/profile/tsegaselassi) - Arabic - Proofreaders needed. - Bosnian - Proofreaders needed. - Bulgarian - - Lyubomir Vasilev - [CrowdIn](https://crowdin.com/profile/lyubomirv) + - Lyubomir Vasilev - [Crowdin](https://crowdin.com/profile/lyubomirv) - Catalan - - David Planella - [GitLab](https://gitlab.com/dplanella), [CrowdIn](https://crowdin.com/profile/dplanella) + - David Planella - [GitLab](https://gitlab.com/dplanella), [Crowdin](https://crowdin.com/profile/dplanella) - Chinese Simplified 简体中文 - - Huang Tao - [GitLab](https://gitlab.com/htve), [CrowdIn](https://crowdin.com/profile/htve) - - Victor Wu - [GitLab](https://gitlab.com/victorwuky), [CrowdIn](https://crowdin.com/profile/victorwu) - - Xiaogang Wen - [GitLab](https://gitlab.com/xiaogang_gitlab), [CrowdIn](https://crowdin.com/profile/xiaogang_gitlab) + - Huang Tao - [GitLab](https://gitlab.com/htve), [Crowdin](https://crowdin.com/profile/htve) + - Victor Wu - [GitLab](https://gitlab.com/_victorwu_), [Crowdin](https://crowdin.com/profile/victorwu) + - Xiaogang Wen - [GitLab](https://gitlab.com/xiaogang_cn), [Crowdin](https://crowdin.com/profile/xiaogang_gitlab) + - Shuang Zhang - [GitLab](https://gitlab.com/tonygodspeed92), [Crowdin](https://crowdin.com/profile/tonygodspeed92) - Chinese Traditional 繁體中文 - - Weizhe Ding - [GitLab](https://gitlab.com/d.weizhe), [CrowdIn](https://crowdin.com/profile/d.weizhe) - - Yi-Jyun Pan - [GitLab](https://gitlab.com/pan93412), [CrowdIn](https://crowdin.com/profile/pan93412) - - Victor Wu - [GitLab](https://gitlab.com/victorwuky), [CrowdIn](https://crowdin.com/profile/victorwu) + - Weizhe Ding - [GitLab](https://gitlab.com/d.weizhe), [Crowdin](https://crowdin.com/profile/d.weizhe) + - Yi-Jyun Pan - [GitLab](https://gitlab.com/pan93412), [Crowdin](https://crowdin.com/profile/pan93412) + - Victor Wu - [GitLab](https://gitlab.com/_victorwu_), [Crowdin](https://crowdin.com/profile/victorwu) - Chinese Traditional, Hong Kong 繁體中文 (香港) - - Victor Wu - [GitLab](https://gitlab.com/victorwuky), [CrowdIn](https://crowdin.com/profile/victorwu) - - Ivan Ip - [GitLab](https://gitlab.com/lifehome), [CrowdIn](https://crowdin.com/profile/lifehome) + - Victor Wu - [GitLab](https://gitlab.com/_victorwu_), [Crowdin](https://crowdin.com/profile/victorwu) + - Ivan Ip - [GitLab](https://gitlab.com/lifehome), [Crowdin](https://crowdin.com/profile/lifehome) - Croatian - Proofreaders needed. - Czech - - Jan Urbanec - [GitLab](https://gitlab.com/TatranskyMedved), [CrowdIn](https://crowdin.com/profile/Tatranskymedved) + - Jan Urbanec - [GitLab](https://gitlab.com/TatranskyMedved), [Crowdin](https://crowdin.com/profile/Tatranskymedved) - Danish - - Saederup92 - [GitLab](https://gitlab.com/Saederup92), [CrowdIn](https://crowdin.com/profile/Saederup92) + - Saederup92 - [GitLab](https://gitlab.com/Saederup92), [Crowdin](https://crowdin.com/profile/Saederup92) - Dutch - - Emily Hendle - [GitLab](https://gitlab.com/pundachan), [CrowdIn](https://crowdin.com/profile/pandachan) + - Emily Hendle - [GitLab](https://gitlab.com/pundachan), [Crowdin](https://crowdin.com/profile/pandachan) - Esperanto - - Lyubomir Vasilev - [CrowdIn](https://crowdin.com/profile/lyubomirv) + - Lyubomir Vasilev - [Crowdin](https://crowdin.com/profile/lyubomirv) - Estonian - Proofreaders needed. - Filipino - - Andrei Jiroh Halili - [GitLab](https://gitlab.com/AJHalili2006DevPH), [Crowdin](https://crowdin.com/profile/AndreiJirohHaliliDev2006) + - Andrei Jiroh Halili - [GitLab](https://gitlab.com/ajhalili2006), [Crowdin](https://crowdin.com/profile/AndreiJirohHaliliDev2006) - French - - Davy Defaud - [GitLab](https://gitlab.com/DevDef), [CrowdIn](https://crowdin.com/profile/DevDef) + - Davy Defaud - [GitLab](https://gitlab.com/DevDef), [Crowdin](https://crowdin.com/profile/DevDef) - Galician - - Antón Méixome - [CrowdIn](https://crowdin.com/profile/meixome) - - Pedro Garcia - [GitLab](https://gitlab.com/pedgarrod), [CrowdIn](https://crowdin.com/profile/breaking_pitt) + - Antón Méixome - [Crowdin](https://crowdin.com/profile/meixome) + - Pedro Garcia - [GitLab](https://gitlab.com/pedgarrod), [Crowdin](https://crowdin.com/profile/breaking_pitt) - German - - Michael Hahnle - [GitLab](https://gitlab.com/mhah), [CrowdIn](https://crowdin.com/profile/mhah) - - Katrin Leinweber - [GitLab](https://gitlab.com/katrinleinweber/), [CrowdIn](https://crowdin.com/profile/katrinleinweber) + - Michael Hahnle - [GitLab](https://gitlab.com/mhah), [Crowdin](https://crowdin.com/profile/mhah) + - Katrin Leinweber - [GitLab](https://gitlab.com/katrinleinweber), [Crowdin](https://crowdin.com/profile/katrinleinweber) - Greek - Proofreaders needed. - Hebrew - - Yaron Shahrabani - [GitLab](https://gitlab.com/yarons), [CrowdIn](https://crowdin.com/profile/YaronSh) + - Yaron Shahrabani - [GitLab](https://gitlab.com/yarons), [Crowdin](https://crowdin.com/profile/YaronSh) - Hindi - Proofreaders needed. - Hungarian - Proofreaders needed. - Indonesian - - Adi Ferdian - [GitLab](https://gitlab.com/adiferd), [CrowdIn](https://crowdin.com/profile/adiferd) - - Ahmad Naufal Mukhtar - [GitLab](https://gitlab.com/anaufalm), [CrowdIn](https://crowdin.com/profile/anaufalm) + - Adi Ferdian - [GitLab](https://gitlab.com/adiferd), [Crowdin](https://crowdin.com/profile/adiferd) + - Ahmad Naufal Mukhtar - [GitLab](https://gitlab.com/anaufalm), [Crowdin](https://crowdin.com/profile/anaufalm) - Italian - - Massimiliano Cuttini - [GitLab](https://gitlab.com/maxcuttins), [CrowdIn](https://crowdin.com/profile/maxcuttins) - - Paolo Falomo - [GitLab](https://gitlab.com/paolofalomo), [CrowdIn](https://crowdin.com/profile/paolo.falomo) + - Massimiliano Cuttini - [GitLab](https://gitlab.com/maxcuttins), [Crowdin](https://crowdin.com/profile/maxcuttins) + - Paolo Falomo - [GitLab](https://gitlab.com/paolofalomo), [Crowdin](https://crowdin.com/profile/paolo.falomo) - Japanese - - Hiroyuki Sato - [GitLab](https://gitlab.com/hiroponz), [CrowdIn](https://crowdin.com/profile/hiroponz) - - Tomo Dote - [GitLab](https://gitlab.com/fu7mu4), [CrowdIn](https://crowdin.com/profile/fu7mu4) - - Hiromi Nozawa - [GitLab](https://gitlab.com/hir0mi), [CrowdIn](https://crowdin.com/profile/hir0mi) - - Takuya Noguchi - [GitLab](https://gitlab.com/tnir), [CrowdIn](https://crowdin.com/profile/tnir) + - Hiroyuki Sato - [GitLab](https://gitlab.com/hiroponz), [Crowdin](https://crowdin.com/profile/hiroponz) + - Tomo Dote - [GitLab](https://gitlab.com/fu7mu4), [Crowdin](https://crowdin.com/profile/fu7mu4) + - Hiromi Nozawa - [GitLab](https://gitlab.com/hir0mi), [Crowdin](https://crowdin.com/profile/hir0mi) + - Takuya Noguchi - [GitLab](https://gitlab.com/tnir), [Crowdin](https://crowdin.com/profile/tnir) - Korean - - Chang-Ho Cha - [GitLab](https://gitlab.com/changho-cha), [CrowdIn](https://crowdin.com/profile/zzazang) - - Ji Hun Oh - [GitLab](https://gitlab.com/Baw-Appie), [CrowdIn](https://crowdin.com/profile/BawAppie) - - Jeongwhan Choi - [GitLab](https://gitlab.com/jeongwhanchoi), [CrowdIn](https://crowdin.com/profile/jeongwhanchoi) + - Chang-Ho Cha - [GitLab](https://gitlab.com/changho-cha), [Crowdin](https://crowdin.com/profile/zzazang) + - Ji Hun Oh - [GitLab](https://gitlab.com/Baw-Appie), [Crowdin](https://crowdin.com/profile/BawAppie) + - Jeongwhan Choi - [GitLab](https://gitlab.com/jeongwhanchoi), [Crowdin](https://crowdin.com/profile/jeongwhanchoi) + - Sunjung Park - [GitLab](https://gitlab.com/sunjungp), [Crowdin](https://crowdin.com/profile/sunjungp) - Mongolian - Proofreaders needed. - Norwegian Bokmal - - Imre Kristoffer Eilertsen - [GitLab](https://gitlab.com/DandelionSprout), [CrowdIn](https://crowdin.com/profile/DandelionSprout) + - Imre Kristoffer Eilertsen - [GitLab](https://gitlab.com/DandelionSprout), [Crowdin](https://crowdin.com/profile/DandelionSprout) - Polish - - Filip Mech - [GitLab](https://gitlab.com/mehenz), [CrowdIn](https://crowdin.com/profile/mehenz) - - Maksymilian Roman - [GitLab](https://gitlab.com/villaincandle), [CrowdIn](https://crowdin.com/profile/villaincandle) - - Jakub Gładykowski - [GitLab](https://gitlab.com/gladykov), [CrowdIn](https://crowdin.com/profile/gladykov) + - Filip Mech - [GitLab](https://gitlab.com/mehenz), [Crowdin](https://crowdin.com/profile/mehenz) + - Maksymilian Roman - [GitLab](https://gitlab.com/villaincandle), [Crowdin](https://crowdin.com/profile/villaincandle) + - Jakub Gładykowski - [GitLab](https://gitlab.com/gladykov), [Crowdin](https://crowdin.com/profile/gladykov) - Portuguese - - Diogo Trindade - [GitLab](https://gitlab.com/luisdiogo2071317), [CrowdIn](https://crowdin.com/profile/ldiogotrindade) + - Diogo Trindade - [GitLab](https://gitlab.com/luisdiogo2071317), [Crowdin](https://crowdin.com/profile/ldiogotrindade) - Portuguese, Brazilian - - Paulo George Gomes Bezerra - [GitLab](https://gitlab.com/paulobezerra), [CrowdIn](https://crowdin.com/profile/paulogomes.rep) - - André Gama - [GitLab](https://gitlab.com/andregamma), [CrowdIn](https://crowdin.com/profile/ToeOficial) - - Eduardo Addad de Oliveira - [GitLab](https://gitlab.com/eduardoaddad), [CrowdIn](https://crowdin.com/profile/eduardoaddad) + - Paulo George Gomes Bezerra - [GitLab](https://gitlab.com/paulobezerra), [Crowdin](https://crowdin.com/profile/paulogomes.rep) + - André Gama - [GitLab](https://gitlab.com/andregamma), [Crowdin](https://crowdin.com/profile/ToeOficial) + - Eduardo Addad de Oliveira - [GitLab](https://gitlab.com/eduardoaddad), [Crowdin](https://crowdin.com/profile/eduardoaddad) - Romanian - Proofreaders needed. - Russian @@ -108,22 +111,22 @@ are very appreciative of the work done by translators and proofreaders! - Slovak - Proofreaders needed. - Spanish - - Pedro Garcia - [GitLab](https://gitlab.com/pedgarrod), [CrowdIn](https://crowdin.com/profile/breaking_pitt) + - Pedro Garcia - [GitLab](https://gitlab.com/pedgarrod), [Crowdin](https://crowdin.com/profile/breaking_pitt) - Swedish - - Johannes Nilsson - [GitLab](https://gitlab.com/nlssn), [CrowdIn](https://crowdin.com/profile/nlssn) + - Johannes Nilsson - [GitLab](https://gitlab.com/nlssn), [Crowdin](https://crowdin.com/profile/nlssn) - Turkish - - Ali Demirtaş - [GitLab](https://gitlab.com/alidemirtas), [CrowdIn](https://crowdin.com/profile/alidemirtas) - - Rıfat Ünalmış (Rifat Unalmis) - [GitLab](https://gitlab.com/runalmis), [CrowdIn](https://crowdin.com/profile/runalmis) + - Ali Demirtaş - [GitLab](https://gitlab.com/alidemirtas), [Crowdin](https://crowdin.com/profile/alidemirtas) + - Rıfat Ünalmış (Rifat Unalmis) - [GitLab](https://gitlab.com/runalmis), [Crowdin](https://crowdin.com/profile/runalmis) - Ukrainian - - Volodymyr Sobotovych - [GitLab](https://gitlab.com/wheleph), [CrowdIn](https://crowdin.com/profile/wheleph) - - Andrew Vityuk - [GitLab](https://gitlab.com/3_1_3_u), [CrowdIn](https://crowdin.com/profile/andruwa13) + - Volodymyr Sobotovych - [GitLab](https://gitlab.com/wheleph), [Crowdin](https://crowdin.com/profile/wheleph) + - Andrew Vityuk - [GitLab](https://gitlab.com/3_1_3_u), [Crowdin](https://crowdin.com/profile/andruwa13) - Welsh - - Delyth Prys - [GitLab](https://gitlab.com/Delyth), [CrowdIn](https://crowdin.com/profile/DelythPrys) + - Delyth Prys - [GitLab](https://gitlab.com/Delyth), [Crowdin](https://crowdin.com/profile/DelythPrys) <!-- vale gitlab.Spelling = YES --> ## Become a proofreader -Before requesting proofreader permissions in CrowdIn, be sure you have a history of contributing +Before requesting proofreader permissions in Crowdin, be sure you have a history of contributing translations to the GitLab project. 1. Contribute translations to GitLab. See instructions for @@ -143,7 +146,7 @@ translations to the GitLab project. - Name - Link to your GitLab profile - - Link to your CrowdIn profile + - Link to your Crowdin profile In the merge request description, include links to any projects you have previously translated. diff --git a/doc/development/i18n/translation.md b/doc/development/i18n/translation.md index f2592d9a8b9..34b7f5e8763 100644 --- a/doc/development/i18n/translation.md +++ b/doc/development/i18n/translation.md @@ -81,8 +81,10 @@ ethnicity. In languages that distinguish between a male and female form, use bot neutral formulation. <!-- vale gitlab.Spelling = NO --> + For example, in German, the word _user_ can be translated into _Benutzer_ (male) or _Benutzerin_ (female). Therefore, _create a new user_ translates to _Benutzer(in) anlegen_. + <!-- vale gitlab.Spelling = YES --> ### Updating the glossary @@ -93,7 +95,9 @@ To propose additions to the glossary, please ## French translation guidelines <!-- vale gitlab.Spelling = NO --> + In French, the _écriture inclusive_ is now over (see on [Legifrance](https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000036068906/)). To include both genders, write _Utilisateurs et utilisatrices_ instead of _Utilisateur·rice·s_. If there is not enough space, use the male gender alone. + <!-- vale gitlab.Spelling = YES --> |