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

Come up with an i18n strategy #5

Open
zenhack opened this issue Feb 13, 2023 · 2 comments
Open

Come up with an i18n strategy #5

zenhack opened this issue Feb 13, 2023 · 2 comments
Labels
design Some thought needs to be put in

Comments

@zenhack
Copy link
Owner

zenhack commented Feb 13, 2023

We'd like tempest to be internationalized from very early on. We should figure out what this is going to look like.

Things to look into:

  • Are there any good libraries we can use from Go? Are they going to be a good fit for the client-side wasm environment (e.g. small code size)? I wouldn't be surprised if we ended up being better off rolling some things ourselves, or just wrapping browser APIs.
  • How are we going to go about translations? Ideally we'd design this so that tempest can be translated with stuff like weblate; we should figure out what constraints we need to follow for that to happen.
@zenhack zenhack added the design Some thought needs to be put in label Feb 13, 2023
@zenhack
Copy link
Owner Author

zenhack commented Mar 20, 2023

Reference for browser APIs around this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl

It does seem like the Go libraries are going to be too bloated to use in the browser -- hard to avoid in a library that has extensive unicode support. We'll probably end up writing thin wrappers around the browser APIs instead then.

It looks like weblate is fairly flexible wrt. the formats it can import & export.

@zenhack
Copy link
Owner Author

zenhack commented Mar 20, 2023

I pushed a simple change to let us at least write internationalized UI strings; no way to actually supply an alternate localization, but when we do we won't have to hunt through all of the code to internationalize everything.

The new internal/browser/intl package lets you do things like:

l10n.Fmt("Hello, %0!", name)

where l10n is of type intl.L10N; it will translate the format string into the target locale and then splice in the arguments.

At some point we can write a tools that will:

  • Find all the places we supply a format string, and extract them for translation
  • Import translations so we can construct an L10N from them to use.

This shouldn't be too complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Some thought needs to be put in
Projects
None yet
Development

No branches or pull requests

1 participant