Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
feat($locale): Include original locale ID in $locale
Browse files Browse the repository at this point in the history
Most systems use *IETF language tag* codes which are typically a combination
of the ISO 639 language code and ISO 3166-1 country code with an underscore
or hyphen delimiter. For example `en_US`, `en_AU`, etc.

Whilst the `$locale.id` comes close, the lowercase format makes it impossible
to transform to an IETF tag reliably. For example, it would be impossible
to deduce `en_Dsrt_US` from `en-dsrt-us`.

Closes #13390
  • Loading branch information
petebacondarwin committed Jan 26, 2016
1 parent adb0e17 commit 63492a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions i18n/spec/closureI18nExtractorSpec.js
Expand Up @@ -4,6 +4,7 @@ findLocaleId = closureI18nExtractor.findLocaleId;
extractNumberSymbols = closureI18nExtractor.extractNumberSymbols;
extractCurrencySymbols = closureI18nExtractor.extractCurrencySymbols;
extractDateTimeSymbols = closureI18nExtractor.extractDateTimeSymbols;
outputLocale = closureI18nExtractor.outputLocale;


function newTestLocaleInfo() {
Expand Down Expand Up @@ -272,3 +273,10 @@ describe("serializeContent", function() {
});
});

describe("outputLocale", function() {
it("should render the correct locale ids", function() {
var output = outputLocale(newTestLocaleInfo(), 'fr_CA');
expect(output).toContain('"id": "fr-ca"');
expect(output).toContain('"localeID": "fr_CA"');
});
});
6 changes: 4 additions & 2 deletions i18n/src/closureI18nExtractor.js
Expand Up @@ -161,6 +161,7 @@ function outputLocale(localeInfo, localeID) {
if (!localeObj.DATETIME_FORMATS) {
localeObj.DATETIME_FORMATS = fallBackObj.DATETIME_FORMATS;
}
localeObj.localeID = localeID;
localeObj.id = correctedLocaleId(localeID);

var getDecimals = [
Expand Down Expand Up @@ -201,10 +202,11 @@ function outputLocale(localeInfo, localeID) {
DATETIME_FORMATS: localeObj.DATETIME_FORMATS,
NUMBER_FORMATS: localeObj.NUMBER_FORMATS,
pluralCat: localeObj.pluralCat,
id: localeObj.id
id: localeObj.id,
localeID: localeID
};

var content = serializeContent(localeInfo[localeID]);
var content = serializeContent(localeObj);
if (content.indexOf('getVF(') < 0) {
getVF = '';
}
Expand Down

0 comments on commit 63492a0

Please sign in to comment.