elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.8k stars 8.19k forks source link

[i18n][system upgrade] Change pseudolocale implementation #180244

Open Bamieh opened 6 months ago

Bamieh commented 6 months ago

With the i18n packages upgrade, our current pseudo locale implementation is very limited and has obvious drawbacks:

  1. Only en-xa is supported from the psuedo locale suite.
  2. Runtime check at the react Provider level checking if the language is en-xa
  3. Will break with the newly supported ICU syntax, needs to update the regexp

The new formatJS library support psuedo localization at 'compile' time. Where a new psuedo localized translation file is generated and supplied to kibana like other languages. If we switch from switching alphabets at runtime to this static file we gain multiple benefits:

  1. Remove our custom implementation
  2. No more runtime check in production for a dev only feature.
  3. Support all ICU syntax supported by formatJS
  4. Supports all psuedo localizations:
locale description
xx-LS my name is {name}SSSSSSSSSSSSSSSSSSSSSSSSS
xx-AC MY NAME IS {name}
xx-HA [javascript]my name is {name}
en-XA [ḿẏ ƞȧȧḿḗḗ īş {name}]
en-XB ‮ɯʎ uɐɯǝ ıs {name}

The new work flow runs as follows:

  1. Extract pseudo localized version of the code by running: node scripts/i18n_pseudo --pseudo-locale <pseudoLocale>
  2. Running kibana with the created pseudo locale yarn start --i18n.locale="en-xa"

Note that the extracted psuedo locales are git ignored and must be generated when needed, this is to guarantee that we are have full messages coverage everytime.

We can also run this script when yarn start is called and the locale is set to a pseudo locale so people who need this will not need to run the new extra step.

elasticmachine commented 6 months ago

Pinging @elastic/kibana-core (Team:Core)