Is your feature request related to a problem? Please describe.
My problem is that I want to check whether a given locale is available/registered.
Describe the solution you'd like
I'm not sure how svelte-i18n works internally, but I think it would be fairly easy to track an array of registered languages (if that isn't already being done). Depending on what would be more conventional in the context of this library, you could either create a store with an array of all registered locales, or you could create a utility function isLocaleRegistered(), or maybe even both. The former solution (having a store) would be more abstract and open ended though and would open opportunities for more diverse actions than just checking whether a locale is supported (for example listing all the available locales).
Describe alternatives you've considered
My current alternative is to make a custom function isLocaleSupported(lang) that just checks the lang against a predefined array of supported languages. The problem is that this creates 2 sources of truth, now each time I add or remove support for a locale, I also have to remember to update the array of supported locales.
How important is this feature to you?
Not too important, but it would be convenient.
Is your feature request related to a problem? Please describe. My problem is that I want to check whether a given locale is available/registered.
Describe the solution you'd like I'm not sure how
svelte-i18n
works internally, but I think it would be fairly easy to track an array of registered languages (if that isn't already being done). Depending on what would be more conventional in the context of this library, you could either create a store with an array of all registered locales, or you could create a utility functionisLocaleRegistered()
, or maybe even both. The former solution (having a store) would be more abstract and open ended though and would open opportunities for more diverse actions than just checking whether a locale is supported (for example listing all the available locales).Describe alternatives you've considered My current alternative is to make a custom function
isLocaleSupported(lang)
that just checks thelang
against a predefined array of supported languages. The problem is that this creates 2 sources of truth, now each time I add or remove support for a locale, I also have to remember to update the array of supported locales.How important is this feature to you? Not too important, but it would be convenient.
P.S I'm also willing to make a PR for this