-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Localization support via the svelte compiler. #13043
Comments
So far we've been holding off from doing any such thing within SvelteKit, let alone Svelte. i18n has far too many opinionated setups and providers that there's a good one fits all solution. Things like https://www.npmjs.com/package/svelte-i18n or Inlang are good solutions. |
oh, man. I hope you will reconsider. |
Would it be possible to open up the ability for the community to add runes? |
But you can have a reactive template function, isn't it enough? |
Sadly not. $t`Hello world` Would be compiled to: $t({
en: `Hello world`,
fr: `French version`,
etc: `...`,
}) We will need some way of hooking into the build step inside of Svelte. In this example we could for example have some AI tool translate the text in build time and cache it. Something like this would also remove the need for special locale file loaders. |
Sounds more like work for a preprocessor. |
Yeaa i kinda agree. |
I just made a little vite plugin on NPM: |
When making the plugin I noticed I ran into some issues. |
Describe the problem
I've been thinking of ways to simplify the localization part of our website.
And I think svelte is in a particular great position to make localization a lot simpler for devs to implement.
Describe the proposed solution
My idea is as follows:
Let's say the Svelte compiler can scan your files for instances where text needs to be translated.
My example would be a rune called:
$t
.Example 1:
Example 2:
Svelte would be able to auto-generate key-value-based language files.
Based on all the instances it saw text that needed to be translated.
The benefits would be huge:
What do you guys think of this idea?
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: