Peerio client translations
Peerio client apps implement translations with Peerio.Translator library
cheatsheet
"Some text {#otherId}" - will find another key with name 'otherId' and put it's value in the placeholder
"Retry: {count}" - call as t('key', {count: 5})
"Click <site>here {count} times</>" - call as t('key', {count:5, site: text => <a href=''>text</a>})
Translation workflow
- New strings are added to 'dev' branch of peerio-copy/client.json
- When ready, dev branch is getting merged to master
- Github hook triggers Peerio service which uploads updated file to transifex
- Strings get translated on transifex site
- Developers run transifex client on mobile repository to download translation files
developers
Tools and environment
- install transifex client
brew install python
sudo pip install transifex-client
- clone peerio-copy repository
- switch to dev branch
- link peerio-copy to peerio-client-mobile
cd peerio-copy
bower link
cd ../peerio-client-mobile
bower link peerio-copy
updating files
bower-installer
will copy latest client_en_.json
from linked peerio-copy package to peerio-client-mobile/locales foldergulp localize
will pull latest translations file from transifex (except english)gulp compile
will copy all translations from /locales folder to /www/locales
using translator api
Translation function is available as t()
- regular string
t('stringKey')
- string with variable placeholders
// "progress": "uploading {current} from {max}"
t('progress', {current:5, max:100})
- strings with segments/wrappers
// "link": "click \<url>here</>"
t('link', {url: segment => <a href=''>segment</a>)
Do not cache localized strings, remember that locale can change on the fly.
If you absolutely have to do it - listen to locale change event to rebuild the cache.
translators
- use
{#hashKey}
to reference another string
{
"greet": "Hello",
"personalGreet": "{#greet}, friend!"
}
- don't change anything inside curly braces
"bla bla {i'm a variable set by developers}"
- if you see a segment, get the idea of what it means from the name, and don't change anything inside angle brackets
"<url>click here</> to get happy"
"this is really <emphasis>important</>"