question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

  • 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidRouyercommented, Sep 21, 2018

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.

0reactions
shkodasvcommented, Oct 24, 2018

How to load only required languages on the site and avoid loading all available files from core/i18n/resource/i18n? langs-prefetch

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC 3536: Terminology Used in Internationalization in the IETF
RFC 3536 Terminology Used in Internationalization in the IETF May 2003 Examples of scripts are Latin, Cyrillic, Greek, Arabic, and Han (the ideographs...
Read more >
RFC 6365 - Terminology Used in Internationalization in the IETF
RFC 6365 Internationalization Terminology September 2011 1. Introduction As the IETF Character Set Policy specification [RFC2277] summarizes: ...
Read more >
RFC: I18n Routing · Discussion #17078 · vercel/next.js - GitHub
This RFC focuses only on the routing goals of internationalization and localization, this would allow i18n libraries like react-intl, react-i18next, lingui, ...
Read more >
RFC 2825 - Issues of I18N, Domain Names, and the - faqs.org
RFC 2825 - A Tangled Web: Issues of I18N, Domain Names, and the. ... the range of architectural issues that the internationalization of...
Read more >
RFC: Enterprise-ready internationalization (i18n) for Rails
RFC : Enterprise-ready internationalization (i18n) for Rails. 133 views ... All the different localization libraries try to select an appropriate
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found