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

Add a register store? #244

Open
LVitus opened this issue Jan 21, 2024 · 0 comments
Open

Add a register store? #244

LVitus opened this issue Jan 21, 2024 · 0 comments

Comments

@LVitus
Copy link

LVitus commented Jan 21, 2024

Is your feature request related to a problem? Please describe.
This would give a good overview over the registered locales. And enable one to easily implement a locales switcher referencing the registered locales as the source of thruth, this is also saving time when adding or modifying locals.

Describe the solution you'd like
I would like a register store to be implemented, which has an array of objects representing each locale. The locale objects could have properties like:

{ languageCode: string; languageName: string; flagUrl: string; etc... }

The locale objects could replace the locale string in the register func, and the string passed currently becomes part of the object.

Describe alternatives you've considered
Right now I am creating the mentioned array myself and I am looping over it and calling the register function for each of the objects. Maybe you could also implement a register locales function which accepts an array of locales objects and registers each locales.

registerStore.set([
{
languageCode: "en",
languageTitle: "English"
},
{
languageCode: "de-DE",
languageTitle: "Deutsch"
},
{
languageCode: "ja-JP",
languageTitle: "日本語"
},
{
languageCode: "fr-FR",
languageTitle: "Français"
}
]);

locales.forEach(locale => {
register(locale.languageCode, () => import($lib/i18n/${locale.languageCode}.json))
});

How important is this feature to you?
important yes

Additional context
none

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