Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for translations #11

Open
Lemmmy opened this issue Mar 9, 2021 · 1 comment
Open

Request for translations #11

Lemmmy opened this issue Mar 9, 2021 · 1 comment
Assignees
Labels
i18n This issue or pull request is related to translations/internationalisation
Milestone

Comments

@Lemmmy
Copy link
Member

Lemmmy commented Mar 9, 2021

As KristWeb v2 is becoming more mature, I'm now ready to begin accepting translations again. In terms of completion, I'd say en.json contains around 75% of the keys that a 2.0 release needs. While that means that translations contributed now will still need to be updated again before release, updating them now provides a lot of time to work on them. Shipping with full translations is not necessary for release, but I think it would be a great added bonus for the maturity of the application, as well as accessibility.

Contributing translations is entirely voluntary, but your help in updating them would be much appreciated.

Updating your translations

I haven't yet made a tool to merge locale JSON files, however there is a CSV containing each language and the keys/missing keys. The missing keys (sourced from en_GB, ignoring plurals) are merged into each language. As well as this, there is always the en.json file as a reference.

I tried to keep the pre-existing translations as stable as possible during the rewrite, however a few now-unused keys were removed due to a change in features. From today onwards, all existing keys are considered stable, and will not be removed. Any text that requires changing will instead receive a new key (e.g. intro2 to replace intro).

The following keys have been removed from en.json:

  • sidebar.guestIndicator - The 'guest' system has been removed
  • masterPassword.browseAsGuest - The 'guest' system has been removed
  • masterPassword.intro - The master password system was reworked. Superseded by masterPassword.intro2.
  • masterPassword.dontForgetPassword - The text is no longer relevant, though a new key with similar text may be added in the future.
  • masterPassword.loginIntro - No longer relevant.
  • masterPassword.helpWalletStorage - The text was outdated, and a new key with similar text will be added in the future.

There's a few things to note about the translation system:

Localised numbers (new!)

Interpolated numbers can now be localised directly in the locale file. Almost every number in KristWeb uses this function now, so that numbers will be formatted with thousands-separators in English (e.g. 1000 -> 1,000). The behaviour of this localisation will depend on the system, not on the chosen language (may change in the future). A localised number interpolation may look like this:

    "nameCount": "{{count, number}} name",
    "nameCount_plural": "{{count, number}} names",

<Trans> substitutions

You're likely already familiar with this, but across the locale files, there are substitutions that look like <1 /> or <1>Contents</1>. These refer to React components that are part of the translation string. You are allowed to re-order them, place text before or after them, etc., but do not change the numbering. The number is part of the source code. Additionally, the tags may optionally contain contents; you are allowed to translate this. Examples:

    "blockValueBaseValue": "Base value (<1></1>)",
    "blockValueNextDecrease": "Decreases by <1></1> in <3>{{count, number}} block</3>",
    "blockValueNextDecrease_plural": "Decreases by <1></1> in <3>{{count, number}} blocks</3>",
    "blockDifficultyHashRate": "Approx. <1 />",

Locale files and languages.json moved

The locale files are now located in public/locales/{lang}.json, instead of in a subdirectory for each language. The languages.json file, which contains a list of all languages, is now located in src/__data__/languages.json. You no longer need to edit utils/i18n.ts to add a language.

Testing your translations

If you have access to the KristWeb v2 private beta, then you can test the translations directly on the live beta. Head to Settings -> Debug settings -> Translations to see the i18n debug page, which allows you to track the progress for each language. Then, click Import JSON or drag a locale file anywhere on the page to import your locale file. The existing locale will be replaced, though your language will revert back to English on the next page reload.

If you really need hot-reloading, and don't mind spending some time compiling the project, then check the private repo in tmpim for installation instructions (DM me on Discord for further information).

As usual, when you are done, you can either send me the updated translations file, send a PR, or push straight to master. Feel free to ask any questions here, or on Discord.

@Lemmmy Lemmmy added this to the v2.0.0 milestone Mar 9, 2021
@Lemmmy Lemmmy added the i18n This issue or pull request is related to translations/internationalisation label Mar 9, 2021
@Lemmmy Lemmmy pinned this issue Mar 9, 2021
@Lemmmy
Copy link
Member Author

Lemmmy commented Mar 10, 2021

Small update: JSON5 is now supported for all locale files. Do with that what you will

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n This issue or pull request is related to translations/internationalisation
Projects
None yet
Development

No branches or pull requests

4 participants