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

Provide a Readable<string> instead of pure string #247

Open
iPepperRnD opened this issue Mar 4, 2024 · 0 comments
Open

Provide a Readable<string> instead of pure string #247

iPepperRnD opened this issue Mar 4, 2024 · 0 comments

Comments

@iPepperRnD
Copy link

I would like to use svelte-i18n to provide localized strings to a custom component, if I use string parameters and provide the value through a call to $t('...') the parameter is correctly translated but doesn't change if the language selection is modified.

I managed to have it working by passing the translation key to the component and call $t(...) directly from my component, though I don't find this really clean as it means by component has a dependency and MUST be used with translation.

Could it be possible to introduce a function which would return a Readable instead of a string ? In essence, I'd expect something like this would work:

function readable(key: string) {
   return derived( t, $t => $t(key) );

I can add this in my own code of course, but I think it would be a nice addition to the library (plus I'm not sure if it would work as nicely with parameters).

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

No branches or pull requests

1 participant