Skip to content

Commit

Permalink
feat: rename Locale.rootLocale to Locale.ROOT
Browse files Browse the repository at this point in the history
  • Loading branch information
Cauli Tomaz committed Apr 16, 2020
1 parent e54b3ff commit ab38995
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/locale/Locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Locale {
zh: 'zh-Hans-CN'
};

public static rootLocale: Locale = Locale.parse('und');
public static ROOT: Locale = Locale.parse('und');

public static forLanguageTag(locale: string = defaultLocale): Locale {
return Locale.parse(locale);
Expand Down
6 changes: 3 additions & 3 deletions src/locale/__tests__/Locale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Locale', () => {
expect(() => Locale.parseStrict(tag)).toThrow('Found superfluous content after tag');

expect(() => Locale.parse(tag)).not.toThrow();
expect(Locale.parse(tag).toString()).toBe(Locale.rootLocale.toString());
expect(Locale.parse(tag).toString()).toBe(Locale.ROOT.toString());
});
});

Expand All @@ -38,7 +38,7 @@ describe('Locale', () => {
);

expect(() => Locale.parse(tag)).not.toThrow();
expect(Locale.parse(tag).toString()).toBe(Locale.rootLocale.toString());
expect(Locale.parse(tag).toString()).toBe(Locale.ROOT.toString());
});
});

Expand All @@ -49,7 +49,7 @@ describe('Locale', () => {
);

expect(() => Locale.parse(tag)).not.toThrow();
expect(Locale.parse(tag).toString()).toBe(Locale.rootLocale.toString());
expect(Locale.parse(tag).toString()).toBe(Locale.ROOT.toString());
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/locale/__tests__/LocaleMatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('LocaleMatcher', () => {

locale = Locale.parse('und-BR');
candidates = [Locale.parse('en'), Locale.parse('pt')];
expect(matcherRegion.match(locale, candidates)).toEqual(Locale.rootLocale);
expect(matcherRegion.match(locale, candidates)).toEqual(Locale.ROOT);
});

it('also accepts plain strings as input', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/locale/matchers/LocaleMatcherDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LocaleMatcherDefault implements Matcher {
key = Locale.parse(key);
candidates = candidates.map(c => Locale.parse(c));

const candidatesWithDefault = [...candidates, Locale.rootLocale];
const candidatesWithDefault = [...candidates, Locale.ROOT];
const everyKey = LocaleMatcherDefault.getSplitLocales([key]);

for (const currentKey of everyKey) {
Expand Down
6 changes: 3 additions & 3 deletions src/locale/matchers/LocaleMatcherPreferRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LocaleMatcherPreferRegion implements Matcher {
LocaleMatcherPreferRegion.getRegionMatch(key, candidates),
// in case it did not find a match by region (getRegionMatch)
// and the language part of the input is 'und',
// the best locale will certainly be Locale.rootLocale.
// the best locale will certainly be Locale.ROOT.
//
// Otherwise it could match, with 'getLanguageMatch',
// another label with the language part 'und' but with a more specific region,
Expand Down Expand Up @@ -72,8 +72,8 @@ class LocaleMatcherPreferRegion implements Matcher {
}

private static getRootLanguageMatch(input: Locale): Locale {
if (input.getLanguage() === Locale.rootLocale.getLanguage()) {
return Locale.rootLocale;
if (input.getLanguage() === Locale.ROOT.getLanguage()) {
return Locale.ROOT;
}

return null;
Expand Down

0 comments on commit ab38995

Please sign in to comment.