RFC: i18n
See original GitHub issue- Feature Name: i18n overhaul
- Start Date: 2018-09-20
- RFC PR:
Summary
Overhaul of the i18n module by:
- Supporting multistore scenarios & multilanguage stores
- Move all the translations into one JSON file inside the theme, and introduce core/modules/extensions translation keys scoping
- Add a mechanism for modules to expose translations keys & add warnings for missing translations keys for enabled languages in development mode
- BONUS: better translation key naming
Motivation
As of today, we only support multistore scenarios. It’s impossible to know which translation key is exposed by a module or an extension and it’s hard to find them because they are all mixed up. We have to merge files and convert them from CSV files. As the translations keys are not in the theme file, I don’t know what are the default translations and I don’t know which languages are supported. If I want to translate my store in Latin, I have to implement ALL core translations keys. Translations keys can clash: if I add an extension with an existing core translation key I can override it without knowing it
Guide-level explanation
Example of the new translation files:
{
"core": {
"ok": "OK",
"remove-compare": "Remove from compare",
"resetting-password": "Resetting the password ...",
"error-reset-password-email": "Error while sending reset password e-mail"
},
"offline-order": {
"confirm-order-offline": "Your order has been confirmed but you're offline"
},
"google-analytics": {
"cookie-google-analytics": "This website uses Google Analytics"
},
"home": {
"home-page": "This is our home page"
},
"about": {
"introduction": "Introducing our team"
}
}
How to use them?
t('core.ok')
Each time you add a page, a module or an extension, you add the scoped section inside the JSON file and you add the translations exposed by the module/extension.
Reference-level explanation
Drawbacks
The users who wants to upgrade will have to migrate their CSV files to the new format.
Rationale and alternatives
Prior art
Unresolved questions
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top GitHub Comments
I haven’t finished writing it 😅
I hope you’re kidding about translations keys. Actual translations keys are unmanageable because some of them takes 3 lines and they’ll break with every typo.
How to load only required languages on the site and avoid loading all available files from core/i18n/resource/i18n?
Another thing. After update to 1.3 translations don’t work. What are the requirements for them?
My translations are in src/themes/[MYTHEME]/resource/i18n/*.csv. In config it is set
"i18n": { "defaultCountry": "AT", "defaultLanguage": "DE", "availableLocale": ["de-DE", "de-AT"], "defaultLocale": "de-AT", "currencyCode": "EUR", "currencySign": "€", "dateFormat": "HH:mm D.M.YYYY", "fullCountryName": "Austria", "fullLanguageName": "German" },
But I see the messages in EN only. Any hint will be appreciated