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

UI: Localize #67

Closed
benbucksch opened this issue Jun 4, 2024 · 5 comments · Fixed by #111
Closed

UI: Localize #67

benbucksch opened this issue Jun 4, 2024 · 5 comments · Fixed by #111
Assignees

Comments

@benbucksch
Copy link
Collaborator

benbucksch commented Jun 4, 2024

Options:

Considerations:

  • Hard to change localization format ("message format") above
  • In the UI code, I'd like tr('Some English words ending with {ending}', {ending}), i.e. have the English string hardcoded. This is a) more fail-safe, and b) avoids that we have to invent new string IDs and c) allows to delay the localization during development, not touching multiple files all the time.
  • Must handle plural forms (both options above do that)
  • Would be nice, if it could handle brand names without code in the UI. (Fluent can do that, need to check Format.JS)
  • L10n format must be supported by online web tools for translators.

Tasks:

  • Choose localization library
  • Extract all UI strings from the code (Svelte HTML, Svelte JS, logic JS), and localize it.
  • Create a script in TypeScript that extracts the strings from the source code and builds the English locale, in the translation files, as the l10n engine expects them. That locale will then be the basis for the translation to other languages.
  • Create a sample translation in 1 other language, and test it.
  • Later (other ticket): Set up system to translate to other languages using AI tools. See Translate app UI using AI tools #108
@benbucksch
Copy link
Collaborator Author

@jermy-c Could you please complete this task in the next week?

@jermy-c
Copy link
Collaborator

jermy-c commented Jun 26, 2024

Localization Library

Lingui is the localization library chosen.
https://github.com/HenryLie/svelte-i18n-lingui is the svelte wrapper for the library used for UI Localization.

Pros

  1. It uses natively uses English strings as IDs
  2. It fallsback to the English string if there's no translations, which allows delaying localization during development.
  3. It allows interpolation of svelte components in between translation which gives translations more context and lets translators translate without touching the HTML. e.g.
<T msg="Click # for more information">
	<a href="/about">{$t`here`}</a>
</T>
  1. Has a string extraction tool

Cons

  1. Very new and the svelte wrapper is even newer

IMPORTANT!

  1. Must use gt``string`` in JS/TS files, instead of gt("string") otherwise string extraction won't work. gt does not work on string literals HenryLie/svelte-i18n-lingui#6
  2. Extraction uses sveltePreprocess which causes an error when $: headHTML = ``<style>\n${cssBody}\n${cssContent}\n</style>``;

@benbucksch
Copy link
Collaborator Author

benbucksch commented Jun 27, 2024 via email

@benbucksch
Copy link
Collaborator Author

@jermy-c I've fixed the translation of the ts modules, in the way we discussed yesterday, in b364b94

@jermy-c Could you please still fix the review comments in #111 and make a PR for that?

@benbucksch
Copy link
Collaborator Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants