Replies: 7 comments 1 reply
-
Hi @wmertens, I've looked at the plans you have for When I started this library, Miško had not yet made public his idea of using Indeed, I think I was the first to try At that time, I had already implemented the key syntax This syntax is more verbose, but has some advantages:
Especially the lack of dynamic keys ($localize In any case, about your questions:
The library is now relatively stable (a lot depends on Qwik changes), and I know that several devs are using it for their projects. I'm open to new ideas and contributions, but without creating other breaking changes for those using it. |
Beta Was this translation helpful? Give feedback.
-
I think these features would be possible to add without changing the existing API, no? |
Beta Was this translation helpful? Give feedback.
-
BTW, FYI, here's what I was considering building before I found out that qwik-speak already has a vite plugin. As you can see the ideas were very similar to what you built. vite-plugin-static-i18nThis statically generates translated copies of code bundles, so that you can serve them to clients as-is. Pro:
Con:
How it worksIn the server and in dev mode, all translations are loaded into memory eagerly, but for a production client build, all the typestype I18nKey = string
type I18nOrdinal = string
/** a string matching /([^$]|\$[0-9$])*/ */
type I18nTranslation = string
/** The locale JSON file format */
type I18nPlural = {
locale: string // the locale key, e.g. en_us or en
name?: string // the name of the locale in the locale, e.g. "Nederlands"
translations: {
/** Note that the object translation only works when used with `plural` */
[key: I18nKey]: I18nTranslation | {
[tag: number | I18nOrdinal | "*"]: I18nTranslation
}
}
} lib
|
Beta Was this translation helpful? Give feedback.
-
Hey you are doing a great job! ⭐ I'll need some time to evaluate it and evaluate possible integrations. In the meantime, I'll answer your questions above:
Already no, I meant it wouldn't be hard to add that syntax to the
I really don't like this solution: the Qwik locale must contain the current language (then also used by this library) and nothing else in my opinion: it could create other problems.
Yes, I think it's a big difference! even when dynamic keys and In any case, even if we were able to remove the context, it would create a big breaking change: since version v0.14.0 I have already required a great effort from those used the library: pass to |
Beta Was this translation helpful? Give feedback.
-
Just an addition: I am very happy with your proposal (and you are a great person for having done it): I also think that having a single i18n library for Qwik is a great thing. However, if it won't be possible to merge, feel free to use what I have done (it is open source, and under the MIT license), or to ask for advice. I think diversity is a wealth, so even different libraries using different ways to solve the same problem would be a wealth! |
Beta Was this translation helpful? Give feedback.
-
Hi @wmertens, I did some tests: I think that implementing and maintaining also template syntax would be very expensive (especially for handling the As for no context, I have already explained above that I don't have an alternative solution: the current context contains the Speak locale, the By the way, I see that |
Beta Was this translation helpful? Give feedback.
-
@wmertens I finally found a way to make the new
At least, this ensures that |
Beta Was this translation helpful? Give feedback.
-
There's 2 things that qwik-i18n does better IMHO:
t`Hi there ${name}!`
instead oft('app.greet$$Hi there {{name}}!', {name})
For 1, would it for example be possible to simply convert
t`Hi there ${name}!`
internally to the key"tmpl.Hi there {{1}}!"
with the default value"Hi there {{1}}!"
and params{1: name}
?Template strings are always static so they will always be inline-able.
For 2, qwik-i18n uses the qwik-core-builtin
getLocale()
to know what the current locale is, and it uses the global scope to store translations.The global scope is fine for translations because they are the same for everyone. In browsers you only need a subset, never a different set for the same keys+locale, so it's safe.
It would be great if qwik-speak could adopt these features.
Beta Was this translation helpful? Give feedback.
All reactions