globalize-webpack-plugin icon indicating copy to clipboard operation
globalize-webpack-plugin copied to clipboard

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

Open sylvanaar opened this issue 5 years ago • 2 comments

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.

sylvanaar avatar Dec 28 '18 15:12 sylvanaar