lib icon indicating copy to clipboard operation
lib copied to clipboard

locale is transformed to lowercase

Open ToP29 opened this issue 2 years ago • 3 comments

I am working on pretty big project reworking it from svetle-i18n and we are using locale when saving items to database, so previously we saved every locale in uppercase format and now if i implement this package it breaks everything across the project, because it transforms current locale to lowercase. I think that locale should be kept in same format as it is defined in loaders (key locale).

const config = {
  parser: parser({ ignoreTag: true }),
  loaders: [
    {
      locale: 'CS',
      key: '',
      loader: async () => (await import('localization/messages/cs.json')).default,
    },
    {
      locale: 'EN',
      key: '',
      loader: async () => (await import('localization/messages/en.json')).default,
    },
  ],
};

ToP29 avatar Jun 08 '22 12:06 ToP29

Locale is not transformed to lowercase (actually in your case is), but to ISO 639-1 Language Code and I think this is a correct behavior, because you want to be able to use lang, hreflang (and others) html attributes using your $locale..

Don’t know your exact use case, but I think you could use transformed store derived from the original $locale…?

jarda-svoboda avatar Jun 08 '22 14:06 jarda-svoboda

And would it be possible to at least add option to the config, if the transformation to ISO 639-1 Language Code should be enabled or not? I think I am not the only one who is migrating from svelte-i18n and who might find this automatic transformation causing a lot of breaking changes.

ToP29 avatar Jun 08 '22 14:06 ToP29

That’s a good point… Could you, please, provide some small repro? Just to see what exactly causes the issue… I’ll provide some solution for use cases like this.)

jarda-svoboda avatar Jun 08 '22 14:06 jarda-svoboda