diff options
Diffstat (limited to 'doc/development/i18n/externalization.md')
-rw-r--r-- | doc/development/i18n/externalization.md | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/doc/development/i18n/externalization.md b/doc/development/i18n/externalization.md index 7ddcd426fd7..a81e656fc27 100644 --- a/doc/development/i18n/externalization.md +++ b/doc/development/i18n/externalization.md @@ -20,7 +20,7 @@ The following tools are used: 1. [`gettext_i18n_rails`](https://github.com/grosser/gettext_i18n_rails): this gem allow us to translate content from models, views and controllers. Also - it gives us access to the following raketasks: + it gives us access to the following Rake tasks: - `rake gettext:find`: Parses almost all the files from the Rails application looking for content that has been marked for translation. Finally, it updates the PO files with the new content that @@ -30,7 +30,7 @@ The following tools are used: 1. [`gettext_i18n_rails_js`](https://github.com/webhippie/gettext_i18n_rails_js): this gem is useful to make the translations available in JavaScript. It - provides the following raketask: + provides the following Rake task: - `rake gettext:po_to_json`: Reads the contents from the PO files and generates JSON files containing all the available translations. @@ -131,7 +131,7 @@ You can mark that content for translation with: In JavaScript we added the `__()` (double underscore parenthesis) function that you can import from the `~/locale` file. For instance: -```js +```javascript import { __ } from '~/locale'; const label = __('Subscribe'); ``` @@ -167,7 +167,7 @@ For example use `%{created_at}` in Ruby but `%{createdAt}` in JavaScript. Make s - In JavaScript (when Vue cannot be used): - ```js + ```javascript import { __, sprintf } from '~/locale'; sprintf(__('Hello %{username}'), { username: 'Joe' }); // => 'Hello Joe' @@ -180,7 +180,7 @@ For example use `%{created_at}` in Ruby but `%{createdAt}` in JavaScript. Make s escape any interpolated dynamic values yourself, for instance using `escape` from `lodash`. - ```js + ```javascript import { escape } from 'lodash'; import { __, sprintf } from '~/locale'; @@ -220,14 +220,14 @@ For example use `%{created_at}` in Ruby but `%{createdAt}` in JavaScript. Make s - In JavaScript: - ```js + ```javascript n__('Apple', 'Apples', 3) // => 'Apples' ``` Using interpolation: - ```js + ```javascript n__('Last day', 'Last %d days', x) // => When x == 1: 'Last day' // => When x == 2: 'Last 2 days' @@ -274,7 +274,7 @@ Namespaces should be PascalCase. - In JavaScript: - ```js + ```javascript s__('OpenedNDaysAgo|Opened') ``` @@ -285,7 +285,7 @@ guidelines for more details](translation.md#namespaced-strings). - In JavaScript: -```js +```javascript import { createDateTimeFormat } from '~/locale'; const dateFormat = createDateTimeFormat({ year: 'numeric', month: 'long', day: 'numeric' }); @@ -372,7 +372,7 @@ structure is the same in all languages. For instance, the following: -```js +```javascript {{ s__("mrWidget|Set by") }} {{ author.name }} {{ s__("mrWidget|to be merged automatically when the pipeline succeeds") }} @@ -380,7 +380,7 @@ For instance, the following: should be externalized as follows: -```js +```javascript {{ sprintf(s__("mrWidget|Set by %{author} to be merged automatically when the pipeline succeeds"), { author: author.name }) }} ``` @@ -439,7 +439,7 @@ This also applies when using links in between translated sentences, otherwise th - In JavaScript (when Vue cannot be used), instead of: - ```js + ```javascript {{ sprintf(s__("ClusterIntegration|Learn more about %{link}"), { link: '<a href="https://cloud.google.com/compute/docs/regions-zones/regions-zones" target="_blank" rel="noopener noreferrer">zones</a>' @@ -449,7 +449,7 @@ This also applies when using links in between translated sentences, otherwise th Set the link starting and ending HTML fragments as placeholders like so: - ```js + ```javascript {{ sprintf(s__("ClusterIntegration|Learn more about %{linkStart}zones%{linkEnd}"), { linkStart: '<a href="https://cloud.google.com/compute/docs/regions-zones/regions-zones" target="_blank" rel="noopener noreferrer">', @@ -536,9 +536,9 @@ The linter will take the following into account: - Variable usage - Only one unnamed (`%d`) variable, since the order of variables might change in different languages - - All variables used in the message-id are used in the translation + - All variables used in the message ID are used in the translation - There should be no variables used in a translation that aren't in the - message-id + message ID - Errors during translation. The errors are grouped per file, and per message ID: @@ -562,7 +562,7 @@ Errors in `locale/zh_TW/gitlab.po`: In this output the `locale/zh_HK/gitlab.po` has syntax errors. The `locale/zh_TW/gitlab.po` has variables that are used in the translation that -aren't in the message with id `1 pipeline`. +aren't in the message with ID `1 pipeline`. ## Adding a new language |