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

Locale Support for xx-XX, e.g. it-IT #93

Open
sylvanaar opened this issue Dec 28, 2018 · 2 comments
Open

Locale Support for xx-XX, e.g. it-IT #93

sylvanaar opened this issue Dec 28, 2018 · 2 comments

Comments

@sylvanaar
Copy link

sylvanaar commented Dec 28, 2018

The CLDR data does not have data for locales in the form xx-XX where XX are the same 2 characters. e.g. it-IT.

I assume the expectation is to use just xx (e.g. it) in that case.

This plugin doesn't seem to work under those circumstances. Doesn't build correctly

Example error:

With it-IT in the supported locales we get:

Module parse failed: Cannot find module './main/it-IT/ca-gregorian'

Is there a workaround?

Edit: This is the actual algorithm that should be used to determine the right locale data:

Valid Locale
A populated locale is one for which ICU has data, or one in which client code has registered a service. If the requested locale is not populated, then ICU will fallback until it reaches a populated locale. The first populated locale it reaches is the valid locale. The
valid locale is reachable from the requested locale via zero or more fallback steps.

Fallback
Locale fallback proceeds as follows:

The variant is removed, if there is one.

The country is removed, if there is one.

The script is removed, if there is one.

The ICU default locale is examined. The same set of steps is performed for the default locale.

At any point, if the desired data is found, then the fallback procedure stops. Keywords are not altered during fallback until the default locale is reached, at which point all keywords are replaced by those assigned to the default locale.

@ieugen
Copy link

ieugen commented Jun 18, 2019

We've hit tbe same issue. Our solution was to fallback to a more generic language tag: from it-IT to it and then to en.

Another option is to define the mappings in your app if yoh know them in advance.

Anothe option is to check if locale == language part + - + upper(language part). E.g 'it-IT' === 'it-' + upper('it').

Cldr is not supposed to have all the data, of course.

@devinm-hrbl
Copy link

I'm trying to upgrade webpack and I saw this posted by Sylvanaar, another reminder of everything he taught me.

We ended up doing a pretty complex workaround on this, it's similar to what you wrote. The library I wrote both adds and overrides the cldr library as a node script fired off in the build step.

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

3 participants