Skip to content

Translations

Alex Saltykov edited this page Apr 14, 2023 · 5 revisions

Each element in _index.html that contains a message has data-attribute data-translate-id. At the same time there is a number of translate files here. File name is the language code, for example ar.json stands for arabic.

https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

How translation files are organized?

Each key of these json files is unique message id. Value is an object with properties:

  • value - localized message
  • prop - which property should be localized (ex. if you have an element like <span data-translate-id="foo">Foo</span>, prop will be 'text' and for element like <input data-translate-id="bar" placeholder="Bar" /> prop will be 'placeholder')
  • defaultValue - original message just for reference

How to add new locale?

  1. Clone https://github.com/johnSamilin/rosplata-back
  2. Run npm run translations:add code (where code is two-letters language code, like ru or hi)
  3. Edit messages in rosplata/translations/[code].json
  4. Run npm run translations:apply
  5. Create PR

What if I

edited message in _index.html?

  1. Update this message in each translation file
  2. Run npm run translations:apply
  3. Create PR

created new message in _index.html?

  1. Make sure you added data-translate-id
  2. Run npm run translations:generate
  3. Update this message in each translation file
  4. Run npm run translations:apply
  5. Create PR