5. About this talk
Localization process in general and more
about gettext format.
What is c-3po and how it helped us to
improve existing process?
6. About this talk
Localization process in general and more
about gettext format.
What is c-3po and how it helped us to
improve existing process?
Continuous translations.
8. Our initial tasks
1. Localize frontend on several projects:
(cabinet, company sites)
Bigl.ua
others...
9. Our initial tasks
1. Localize frontend on several projects:
(cabinet, company sites)
Bigl.ua
others ...
1. Setup translation process when devs and translators
can work independently.
14. ICU is cool, but ...
1. Poor tooling (editors for translators e.t.c).
15. ICU is cool, but ...
1. Poor tooling (editors for translators e.t.c).
2. Our backend already used gettext.
16. ICU - cool but ...
"{gender_of_host, select, "
"female {"
"{num_guests, plural, offset:1 "
"=0 {{host} does not give a party.}"
"=1 {{host} invites {guest} to her party.}"
"=2 {{host} invites {guest} and one other person to her party.}"
"other {{host} invites {guest} and # other people to her party.}}}"
"male {"
"{num_guests, plural, offset:1 "
"=0 {{host} does not give a party.}"
"=1 {{host} invites {guest} to his party.}"
"=2 {{host} invites {guest} and one other person to his party.}"
"other {{host} invites {guest} and # other people to his party.}}}"
"other {"
"{num_guests, plural, offset:1 "
"=0 {{host} does not give a party.}"
"=1 {{host} invites {guest} to their party.}"
"=2 {{host} invites {guest} and one other person to their party.}"
"other {{host} invites {guest} and # other people to their party.}}}}"
39. #: app.js:10
msgid "${ n } second"
msgid_plural "${ n } seconds"
msgstr[0] "${ n } секунда"
msgstr[1] "${ n } секунди"
msgstr[2] "${ n } секунд"
Plural forms example
40. #. Notes for the translator
#: app.js:6
#, flag
msgid "Choose locale"
msgstr "Оберіть локаль"
Comments
53. Why just not simple functions but tags?
c-3po must work without transpilation
54. Why just not simple functions but tags?
// Without babel transpile !!!
const name = ‘Mike’
t(`Hello ${name}`)
function t(str) {
// strs -> ‘Hello Mike’
// no chance to get ‘Hello ${name}’ msgid here :(
}
103. Ukrainian/Russian strings in sources
How to be with plurals? Standard ngettext accepts only 2
plural forms? What if we have more or less than 2 plural
forms?
104. Ukrainian/Russian strings in sources
How to be with plurals? Standard ngettext accepts only 2
plural forms? What if we have more or less than 2 plural
forms?
114. ngettext - plural forms
ngettext(msgid`${n} time clicked`, `${n} times clicked`, n) < Usage
115. ngettext - plural forms
ngettext(msgid`${n} time clicked`, `${n} times clicked`, n)
msgid "${ n } time clicked"
msgid_plural "${ n } times clicked"
msgstr[0] "${ n } time clicked [translated]"
msgstr[1] "${ n } times clicked [translated]"
< Usage
< Extract
116. Forgot msgid ?
ERROR in Error: Module build failed: SyntaxError: First argument must be tagged
template expression. You should use 'msgid' tag
2 |
3 |
> 4 | ngettext(`${hours} hour`, `${hours} hours`, hours);
| ^
5 |
Demo on jsfiddle
Doc - https://c-3po.js.org/ngettext.html
117. ngettext - resolve
function _tag_ngettext(n, args) {
return args[+(n != 1)];
}
_tag_ngettext(n,
[n + " time clicked [translated]", n + " times clicked [translated]"]));
Demo on jsfiddle
Doc - https://c-3po.js.org/ngettext.html
134. import { t } from 'c-3po';
function test(name) {
return t`multi line string
with multiple line breaks and
with formatting ${name}`
}
Multiline (auto dedent)
137. Translator comments
// translator: some description for the extracted string.
t`some string`
#. some description for the extracted string
msgid "some string"
msgstr ""
140. Summary
● Native js tagged template strings for formatting
● Can precompile translation on a build step
141. Summary
● Native js tagged template strings for formatting
● Can precompile translation on a build step
● Works with and without babel
142. Summary
● Native js tagged template strings for formatting
● Can precompile translation on a build step
● Works with and without babel
● Extracts and resolves translations from everything
that works with babel (jsx)
143. Summary
● Native js tagged template strings for formatting
● Can precompile translation on a build step
● Works with and without babel
● Extracts and resolves translations from everything
that works with babel (jsx)
● Efficient dev and prod setup
144. Summary
● Native js tagged template strings for formatting
● Can precompile translation on a build step
● Works with and without babel
● Extracts and resolves translations from everything
that works with babel (jsx)
● Efficient dev and prod setup
● Validation for translated strings
145. Summary
● Native js tagged template strings for formatting
● Can precompile translation on a build step
● Works with and without babel
● Extracts and resolves translations from everything
that works with babel (jsx)
● Efficient dev and prod setup
● Validation for translated strings
● Can use any default locale in sources (not only
English)