-
-
Notifications
You must be signed in to change notification settings - Fork 729
i18n
The OFN is available in several languages. You can help translating at Transifex.
Our code is on Github and that is where our source locale en
is maintained. To enable people to translate it easily via Transifex, we need to feed it into Transifex and then get the translations back into Github again. Here is the story of the current process. Our main actors are Github, Transifex and our Continuous Integration (CI) server.
Quite regularly, a developer changes some code that involves changing text. Text is changed in the file config/locales/en.yml
. Once that change has made it into our production code, the master branch on Github, it needs translating into all the other languages. Transifex is configured to check en.yml on Github every day and make any changes available for translation.
Translators may notice that their language is not 100% translated due to changes of the source file. Then they translate and once a language reaches 100% again, Transifex notifies our CI server.
Our CI server is running txgh to listen to Transifex. When a translation reaches 100%, it will download it from Transifex and push it to Github on the "transifex" branch. It will create the branch if it doesn't exist. It also opens a pull request so that we can easily merge the changes into master for the next release.
Please note that once a translation reached 100%, Transifex doesn't notify our CI server about any further changes. You can trigger another notification by reviewing the translation to 100%. Any updates after the review have to be downloaded and committed manually.
The Transifex client is a command line tool that helps with manually downloading translations. After installing, you can replace all locales with the latest Transifex version:
# cd openfoodnetwork
tx pull --force
When making changes to config/locales/en.yml
or other locals, ensure you reload I18n js translations to see the changes in the application.
rake tmp:cache:clear
Scopes/keys must be unique at all levels. If duplicated, they may work in the browser but can result in unrelated failing tests.
Bad
shop:
vegetables:
carrot: 'carrot'
...
shop:
fruit:
apple: 'apple'
Good
shop:
vegetables:
carrot: 'carrot'
fruit:
apple: 'apple'...
In JavaScript it's better to use our Angular filter for translations:
Bad
join(" " + t('shop.products.filter_properties_or' ) + " ")
Good:
join(" {{ 'shop.products.filter_properties_or' | t }} ")
In some cases we had problems with the global t
function not working when called directly. I think it depends on the scope in which the code is running. Using the t
filter is the safer option and we should try to be consistently using only that one in JavaScript.
Development environment setup
- Pipeline development process
- Bug severity
- Feature template (epic)
- Internationalisation (i18n)
- Dependency updates
Development
- Developer Guidelines
- The process of review, test, merge and deploy
- Making a great commit
- Making a great pull request
- Code Conventions
- Database migrations
- Testing and Rspec Tips
- Automated Testing Gotchas
- Rubocop
- Angular and OFN
- Feature toggles
- Stimulus and Turbo
Testing
- Testing process
- OFN Testing Documentation (Handbooks)
- Continuous Integration
- Parallelized test suite with knapsack
- Karma
Releasing
Specific features
Data and APIs
Instance-specific configuration
External services
Design