diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-10-24 07:16:57 +0300 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-10-24 07:21:37 +0300 |
commit | bb943537adbeaec64b6b9a703ffb17dfa1af5fd5 (patch) | |
tree | 0c0be7c5037817bfc70fa7e40729c293bfbccac2 /doc/development/i18n | |
parent | 82446a2bd009e7d7481c35a142063a3973be77ce (diff) |
Update i18n in FE docs, marking, interpolation
Diffstat (limited to 'doc/development/i18n')
-rw-r--r-- | doc/development/i18n/externalization.md | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/doc/development/i18n/externalization.md b/doc/development/i18n/externalization.md index 167260b6e0e..7c38260406d 100644 --- a/doc/development/i18n/externalization.md +++ b/doc/development/i18n/externalization.md @@ -180,15 +180,43 @@ aren't in the message with id `1 pipeline`. ## Working with special content + +### Just marking content for parsing + +- In Ruby/HAML: + + ```ruby + _('Subscribe') + ``` + +- In JavaScript: + + ```js + import { __ } from '../../../locale'; + const label = __('Subscribe'); + ``` + + +Sometimes there are some dynamic translations that can't be found by the +parser when running `bundle exec rake gettext:find`. For these scenarios you can +use the [`_N` method](https://github.com/grosser/gettext_i18n_rails/blob/c09e38d481e0899ca7d3fc01786834fa8e7aab97/Readme.md#unfound-translations-with-rake-gettextfind). + +There is also and alternative method to [translate messages from validation errors](https://github.com/grosser/gettext_i18n_rails/blob/c09e38d481e0899ca7d3fc01786834fa8e7aab97/Readme.md#option-a). + ### Interpolation - In Ruby/HAML: ```ruby - _("Hello %{name}") % { name: 'Joe' } + _("Hello %{name}") % { name: 'Joe' } => 'Hello Joe' ``` -- In JavaScript: Not supported at this moment. +- In JavaScript: + + ```js + import { __, sprintf } from '../../../locale'; + sprintf(__('Hello %{username}'), { username: 'Joe' }) => 'Hello Joe' + ``` ### Plurals @@ -234,14 +262,6 @@ Sometimes you need to add some context to the text that you want to translate s__('OpenedNDaysAgo|Opened') ``` -### Just marking content for parsing - -Sometimes there are some dynamic translations that can't be found by the -parser when running `bundle exec rake gettext:find`. For these scenarios you can -use the [`_N` method](https://github.com/grosser/gettext_i18n_rails/blob/c09e38d481e0899ca7d3fc01786834fa8e7aab97/Readme.md#unfound-translations-with-rake-gettextfind). - -There is also and alternative method to [translate messages from validation errors](https://github.com/grosser/gettext_i18n_rails/blob/c09e38d481e0899ca7d3fc01786834fa8e7aab97/Readme.md#option-a). - ## Adding a new language Let's suppose you want to add translations for a new language, let's say French. |