Skip to content

Commit

Permalink
fix(@formatjs/intl-locale): fix according to tc39/test262#2628
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho committed May 20, 2020
1 parent ed34904 commit 1006ed2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/intl-locale/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ function removeLikelySubtags(
): UnicodeLanguageId {
const {variants, ...max} = addLikelySubtags(unicodeLangId);
const trials: UnicodeLanguageId[] = [
{lang: unicodeLangId.lang},
{lang: unicodeLangId.lang, region: unicodeLangId.region},
{lang: unicodeLangId.lang, script: unicodeLangId.script},
{lang: max.lang},
{lang: max.lang, region: max.region},
{lang: max.lang, script: max.script},
];
for (const trial of trials) {
if (isLanguageEqualWithoutVariants(max, addLikelySubtags(trial))) {
Expand Down
17 changes: 8 additions & 9 deletions packages/intl-locale/tests/minimize.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import {IntlLocale} from '../src';
import * as data from 'cldr-core/supplemental/likelySubtags.json';
IntlLocale._addLikelySubtagData(data.supplemental.likelySubtags);
// This is different from test262 bc of https://github.com/tc39/test262/issues/2628
const testDataMinimal = {
// Undefined primary language.
und: 'und',
'und-Thai': 'und-Thai',
'und-419': 'und-419',
'und-150': 'und-150',
'und-AT': 'und-AT',
und: 'en',
'und-Thai': 'th',
'und-419': 'es-419',
'und-150': 'ru-150',
'und-AT': 'de-AT',

// https://unicode-org.atlassian.net/browse/ICU-13786
'aae-Latn-IT': 'aae-Latn-IT',
'aae-Thai-CO': 'aae-Thai-CO',

// https://unicode-org.atlassian.net/browse/ICU-10220
// https://unicode-org.atlassian.net/browse/ICU-12345
'und-CW': 'und-CW',
'und-US': 'und',
'zh-Hant': 'zh-Hant',
'und-CW': 'pap-CW',
'und-US': 'en',
'zh-Hant': 'zh-TW',
'zh-Hani': 'zh-Hani',
};

Expand Down

0 comments on commit 1006ed2

Please sign in to comment.