Replies: 2 comments 6 replies
-
I think having a translate option is a good move forward. A library always adds dependencies, which are in my opinion not always necessary. I like a minimal implementation and have some thoughts about your suggestions. I would not add another json config file. I would put it in the options. Something like:
The translate function would then look for the default or selected language. The usage of the function is ok, I would rather use a label instead of the text directly. Also some other thoughts. The lens team did think about this from the start and had a German and English label in the catalogue, do we want to readd this? |
Beta Was this translation helpful? Give feedback.
-
Translations are implemented: https://github.com/samply/lens/blob/develop/book/src/guide/translations.md |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently some user-facing messages are configured in the lens options, e.g.:
I feel like it would make sense to include these translations in lens and configure only the language (english or german) in the lens options.
Advantages of this approach would be:
Possible issues:
If we want to move forward with this approach here is my suggestion how to implement it.
I've looked into localization libraries and didn't find anything I liked. Some are no longer maintained (sveltekit-i18n, typesafe-i18n) and others pretty intrusive (Paraglide JS). I would propose an extremely simple approach of having a file
german.json
:And a function
translate
:Then use it like that:
Typescript will show an error if you are trying to translate a string that is not defined in the translations JSON file.
Beta Was this translation helpful? Give feedback.
All reactions