sveltekit-i18n / lib

Internationalization library built for SvelteKit.
MIT License
502 stars 33 forks source link

Unsupported locales #54

Closed dewrano closed 2 years ago

dewrano commented 2 years ago

Hi

I'm not sure but I think this method filters away unsupported locales: https://github.com/sveltekit-i18n/base/blob/a5df0f1c63b23504e7dbcbe7a62461f573a78149/src/utils.ts#L26

I'm trying to add the Kurdish language ("ku"), but unfortunately, it's not supported when I try to run this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/supportedLocalesOf

Is there a way for us to disable the sanitizer?

jarda-svoboda commented 2 years ago

Hi @dewrano!

Currently there is no way how to disable the sanitizer, but you have probably found a bug. This lib should work even without standard locales - in that case should only warn and use lower-cased form of the input locale.

I'll try to fix this in the next couple of days, thanks.)

jarda-svoboda commented 2 years ago

Ok, this does not yield any error https://github.com/sveltekit-i18n/base/blob/a5df0f1c63b23504e7dbcbe7a62461f573a78149/src/utils.ts#L32 for ku locale, so sanitized locale is undefined... Definitely needs to be fixed.

jarda-svoboda commented 2 years ago

Will be included in sveltekit-i18n@2.1.3 and @sveltekit-i18n/base@1.1.2

dewrano commented 2 years ago

@jarda-svoboda Thank you for the quick response. I've updated to 2.1.3 and now I see new warnings, but I still can't seem to get it to work. When I print out locales, it returns undefined for ku. See attached screenshot.

image

jarda-svoboda commented 2 years ago

Oh, that’s weird… there are tests for it and it worked..🤔 https://github.com/sveltekit-i18n/base/blob/master/tests/specs/index.spec.ts#L138

i’ll look at it again soon..!

jarda-svoboda commented 2 years ago

It seems it already works on server side, but still does not work on client for some reason... server:

Snímek obrazovky 2022-04-07 v 22 30 17

client:

Snímek obrazovky 2022-04-07 v 22 30 07
jarda-svoboda commented 2 years ago

It seems there is a difference between Node's and JS's Intl so that's probably the reason why all tests were passing for ku locale. Anyway now it's fixed and it works on client as well in sveltekit-i18n@2.1.4 and @sveltekit-i18n/base@1.1.3

dewrano commented 2 years ago

@jarda-svoboda Thank you so much, I can confirm it works. :) Hopefully we can expect #55 soon to disable the many warnings.