-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Adding new translations for i18n
Oppia supports internationalization (i18n) for most learner-facing pages using the angular-translate library, documentation for which can be found here. Anyone is welcome to add new translations, or correct existing ones. For more information about developing for i18n, please see our i18n developer guide.
Thanks to translatewiki.net, it's easy to add or update translations for Oppia! To do so, just follow these steps:
- Visit the Oppia Translatewiki page.
- Click "Translate this project".
- Select a language to contribute translations for. (Also, read the notes below describing the translation formats used for variables and plurals.)
Changes will then be pushed to Oppia automatically by the translatewiki admins (@Nikerabbit and @siebrand), and they will show up in future Oppia releases.
Within translations, you could add variables that would be later replaced with personalized content. For example, in the text
You have 3 new notifications.
the number of notifications is a variable, and thus cannot be included directly in the translation. Angular translate solves this problem by using an interpolation service. Your translated phrase should look like:
You have <[notification_number]> new notifications.
In the html page, the value of notification_number
will be substituted accordingly by angular-translate. For more details, please refer to the angular-translate documentation. IMPORTANT: the default mechanism of indicating an expression in Angular is using the symbols {{ and }}, however in Oppia these symbols have been replaced by <[ and ]>.
In the example above, if there is only one notification, then we should change "notifications" for "notification". Furthermore, some languages may have more plural forms than English. To handle this, we use a different interpolation service, called messageformat. In this case, the translation should look like this:
{notification_number, plural, =0{You have no notifications.} one{You have one notification.} other{You have # notifications.}}
In this example, the # symbol will be replaced by the value of the notification_number
variable. For a more elaborate tutorial, please refer to the angular-translate guide for pluralization.
In general, it is better to add translations via the translatewiki UI where possible. However, in exceptional cases, you can manually add a language to the Oppia codebase in three simple steps:
- Copy assets/i18n/en.json file into a new file called
xx.json
, where xx is the language code for the new language. You can find this code here. Save the resulting file in the samei18n/
directory. - Replace all occurrences of English with the translated phrase in the target language. It's OK if you omit some translations, but please ensure to remove all occurrences of English translations from the file as when a translation key is missing, the English variant will be used as a fall-back. Please refer to the notes below on how to handle variables and pluralization during translation. Please also see qqq.json for important contextual information about what is being translated, and feel free to ask questions on GitHub Discussions if anything is unclear!
- In feconf.py, add a new entry to the variable
SUPPORTED_SITE_LANGUAGES
representing the language code and the language name.
After this, you should be able to see the new language listen in the Oppia splash page and translate the site using the language dropdown in the footer.
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- FAQs
- Installing Oppia
- Getting started with the codebase
- Making your first PR
- Learning resources for developers
- Codebase Overview
- Coding Guidelines
- Coding style guide
- Guidelines for creating new files
- How to add a new page
- How to write frontend type definitions
- How to write design docs
- Revert and Regression Policy
- Server errors and solutions
-
Debugging
- If your presubmit checks fail
- If CI checks fail on your PR
- Finding the commit that introduced a bug
- Interpreting GitHub Actions Results
- Debugging Docs
- Debugging datastore locally
- Debugging end-to-end tests
- Debugging backend tests
- Debugging frontend tests
- Debug frontend code
- Debugging custom ESLint check tests
- Debugging custom Pylint check tests
- Debugging Stories
- Guidelines for launching new features
- Guidelines for making an urgent fix (hotfix)
- Lint Checks
- Oppia's code owners and checks to be carried out by developers
- Privacy aware programming
- Backend Type Annotations
- Bytes and string handling in Python 3
- Guidelines for Developers with Write Access to oppia/oppia
- Testing
- Release Process
Developer Reference
- Oppiabot
- Frontend
- Backend
- Translations
- Webpack
- Third-party libraries
- Extension frameworks
- Oppia-ml Extension
- Mobile development
- Mobile device testing
- Performance testing
- Build process
- Team structure
- Triaging Process
- Playbooks
- Wiki
- Past Events