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
Add basic i18n support #941
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I've come to prefer the gettext
style of using the actual message as key. But I have no strong preference.
As you say this could easily be extended with plural forms etc. Agree on the link rewriting being tedious.
A nice starting point.
I agree with it being a good starting point! I can do a more formal review this Wednesday (but I am also fine with merging it). A quick idea regarding the issue with repetitive base url paths: could a I have no real preference regarding actual message style but it can be good to further discuss it and how we can achieve pluralization. |
Yay, that worked! I tried that before, but missed that you then can't use root-relative paths ( |
Merging this now, continued discussion has been mostly about the |
Why did Paraglide JS seem "too large"? We need to improve our communication :) cc @LorisSigrist
|
Hi @samuelstroschein, sorry for the sloppy comment (edited now). What I meant was that in our particular case and right now any lib probably has more functionality than we need. Paraglide seems great btw and something we'll probably consider again at some point :) |
Description
Tickets involved
LXL-4362
Summary of changes
A modest proposal on how we could approach the i18n issue. Svelte has no official solution, and after looking at a number of libs, many seem too large, hacky or abandoned.
I then found this example that felt like a good approach and decided to try it out. It's basically a function that loads the needed translations and returns a translator function from the layout. It supports nested translation files and basic string interpolation (
hello {name} how are you
) and can easily be extended to support our exact needs (unknown to me at this point...)Some notes:
.js
at the moment. This allows us to typecheck theen
using thesv
one for example, keeping them fully synced. But we could just as well use json files./en/
etc) at runtime, which is needed for correct links to be rendered. Current solution exposes abase
variable that needs to be prepended to all links, which is a bit tedious...