refactor(common): use private names rather than aliases internally (#33523)

PR Close #33523
This commit is contained in:
Pete Bacon Darwin
2019-11-04 15:06:30 +00:00
committed by atscott
parent cd6ab209b6
commit 5b21b71c9a
4 changed files with 106 additions and 104 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ɵLocaleDataIndex as LocaleDataIndex, ɵfindLocaleData as findLocaleData, ɵgetLocalePluralCase} from '@angular/core';
import {ɵLocaleDataIndex, ɵfindLocaleData, ɵgetLocalePluralCase} from '@angular/core';
import {CURRENCIES_EN, CurrenciesSymbols} from './currencies';
import {CurrencyIndex, ExtraLocaleDataIndex} from './locale_data';
@ -217,7 +217,7 @@ export enum WeekDay {
* @publicApi
*/
export function getLocaleId(locale: string): string {
return findLocaleData(locale)[LocaleDataIndex.LocaleId];
return ɵfindLocaleData(locale)[ɵLocaleDataIndex.LocaleId];
}
/**
@ -233,10 +233,10 @@ export function getLocaleId(locale: string): string {
*/
export function getLocaleDayPeriods(
locale: string, formStyle: FormStyle, width: TranslationWidth): [string, string] {
const data = findLocaleData(locale);
const data = ɵfindLocaleData(locale);
const amPmData = <[
string, string
][][]>[data[LocaleDataIndex.DayPeriodsFormat], data[LocaleDataIndex.DayPeriodsStandalone]];
][][]>[data[ɵLocaleDataIndex.DayPeriodsFormat], data[ɵLocaleDataIndex.DayPeriodsStandalone]];
const amPm = getLastDefinedValue(amPmData, formStyle);
return getLastDefinedValue(amPm, width);
}
@ -255,9 +255,9 @@ export function getLocaleDayPeriods(
*/
export function getLocaleDayNames(
locale: string, formStyle: FormStyle, width: TranslationWidth): string[] {
const data = findLocaleData(locale);
const data = ɵfindLocaleData(locale);
const daysData =
<string[][][]>[data[LocaleDataIndex.DaysFormat], data[LocaleDataIndex.DaysStandalone]];
<string[][][]>[data[ɵLocaleDataIndex.DaysFormat], data[ɵLocaleDataIndex.DaysStandalone]];
const days = getLastDefinedValue(daysData, formStyle);
return getLastDefinedValue(days, width);
}
@ -276,9 +276,9 @@ export function getLocaleDayNames(
*/
export function getLocaleMonthNames(
locale: string, formStyle: FormStyle, width: TranslationWidth): string[] {
const data = findLocaleData(locale);
const data = ɵfindLocaleData(locale);
const monthsData =
<string[][][]>[data[LocaleDataIndex.MonthsFormat], data[LocaleDataIndex.MonthsStandalone]];
<string[][][]>[data[ɵLocaleDataIndex.MonthsFormat], data[ɵLocaleDataIndex.MonthsStandalone]];
const months = getLastDefinedValue(monthsData, formStyle);
return getLastDefinedValue(months, width);
}
@ -296,8 +296,8 @@ export function getLocaleMonthNames(
* @publicApi
*/
export function getLocaleEraNames(locale: string, width: TranslationWidth): [string, string] {
const data = findLocaleData(locale);
const erasData = <[string, string][]>data[LocaleDataIndex.Eras];
const data = ɵfindLocaleData(locale);
const erasData = <[string, string][]>data[ɵLocaleDataIndex.Eras];
return getLastDefinedValue(erasData, width);
}
@ -313,8 +313,8 @@ export function getLocaleEraNames(locale: string, width: TranslationWidth): [str
* @publicApi
*/
export function getLocaleFirstDayOfWeek(locale: string): WeekDay {
const data = findLocaleData(locale);
return data[LocaleDataIndex.FirstDayOfWeek];
const data = ɵfindLocaleData(locale);
return data[ɵLocaleDataIndex.FirstDayOfWeek];
}
/**
@ -327,8 +327,8 @@ export function getLocaleFirstDayOfWeek(locale: string): WeekDay {
* @publicApi
*/
export function getLocaleWeekEndRange(locale: string): [WeekDay, WeekDay] {
const data = findLocaleData(locale);
return data[LocaleDataIndex.WeekendRange];
const data = ɵfindLocaleData(locale);
return data[ɵLocaleDataIndex.WeekendRange];
}
/**
@ -343,8 +343,8 @@ export function getLocaleWeekEndRange(locale: string): [WeekDay, WeekDay] {
* @publicApi
*/
export function getLocaleDateFormat(locale: string, width: FormatWidth): string {
const data = findLocaleData(locale);
return getLastDefinedValue(data[LocaleDataIndex.DateFormat], width);
const data = ɵfindLocaleData(locale);
return getLastDefinedValue(data[ɵLocaleDataIndex.DateFormat], width);
}
/**
@ -359,8 +359,8 @@ export function getLocaleDateFormat(locale: string, width: FormatWidth): string
* @publicApi
*/
export function getLocaleTimeFormat(locale: string, width: FormatWidth): string {
const data = findLocaleData(locale);
return getLastDefinedValue(data[LocaleDataIndex.TimeFormat], width);
const data = ɵfindLocaleData(locale);
return getLastDefinedValue(data[ɵLocaleDataIndex.TimeFormat], width);
}
/**
@ -375,8 +375,8 @@ export function getLocaleTimeFormat(locale: string, width: FormatWidth): string
* @publicApi
*/
export function getLocaleDateTimeFormat(locale: string, width: FormatWidth): string {
const data = findLocaleData(locale);
const dateTimeFormatData = <string[]>data[LocaleDataIndex.DateTimeFormat];
const data = ɵfindLocaleData(locale);
const dateTimeFormatData = <string[]>data[ɵLocaleDataIndex.DateTimeFormat];
return getLastDefinedValue(dateTimeFormatData, width);
}
@ -391,13 +391,13 @@ export function getLocaleDateTimeFormat(locale: string, width: FormatWidth): str
* @publicApi
*/
export function getLocaleNumberSymbol(locale: string, symbol: NumberSymbol): string {
const data = findLocaleData(locale);
const res = data[LocaleDataIndex.NumberSymbols][symbol];
const data = ɵfindLocaleData(locale);
const res = data[ɵLocaleDataIndex.NumberSymbols][symbol];
if (typeof res === 'undefined') {
if (symbol === NumberSymbol.CurrencyDecimal) {
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
} else if (symbol === NumberSymbol.CurrencyGroup) {
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Group];
return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Group];
}
}
return res;
@ -439,8 +439,8 @@ export function getLocaleNumberSymbol(locale: string, symbol: NumberSymbol): str
* @publicApi
*/
export function getLocaleNumberFormat(locale: string, type: NumberFormatStyle): string {
const data = findLocaleData(locale);
return data[LocaleDataIndex.NumberFormats][type];
const data = ɵfindLocaleData(locale);
return data[ɵLocaleDataIndex.NumberFormats][type];
}
/**
@ -455,8 +455,8 @@ export function getLocaleNumberFormat(locale: string, type: NumberFormatStyle):
* @publicApi
*/
export function getLocaleCurrencySymbol(locale: string): string|null {
const data = findLocaleData(locale);
return data[LocaleDataIndex.CurrencySymbol] || null;
const data = ɵfindLocaleData(locale);
return data[ɵLocaleDataIndex.CurrencySymbol] || null;
}
/**
@ -470,8 +470,8 @@ export function getLocaleCurrencySymbol(locale: string): string|null {
* @publicApi
*/
export function getLocaleCurrencyName(locale: string): string|null {
const data = findLocaleData(locale);
return data[LocaleDataIndex.CurrencyName] || null;
const data = ɵfindLocaleData(locale);
return data[ɵLocaleDataIndex.CurrencyName] || null;
}
/**
@ -481,8 +481,8 @@ export function getLocaleCurrencyName(locale: string): string|null {
* @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
*/
function getLocaleCurrencies(locale: string): {[code: string]: CurrenciesSymbols} {
const data = findLocaleData(locale);
return data[LocaleDataIndex.Currencies];
const data = ɵfindLocaleData(locale);
return data[ɵLocaleDataIndex.Currencies];
}
/**
@ -493,9 +493,9 @@ export const getLocalePluralCase: (locale: string) => ((value: number) => Plural
ɵgetLocalePluralCase;
function checkFullData(data: any) {
if (!data[LocaleDataIndex.ExtraData]) {
if (!data[ɵLocaleDataIndex.ExtraData]) {
throw new Error(
`Missing extra locale data for the locale "${data[LocaleDataIndex.LocaleId]}". Use "registerLocaleData" to load new data. See the "I18n guide" on angular.io to know more.`);
`Missing extra locale data for the locale "${data[ɵLocaleDataIndex.LocaleId]}". Use "registerLocaleData" to load new data. See the "I18n guide" on angular.io to know more.`);
}
}
@ -522,9 +522,9 @@ function checkFullData(data: any) {
* @publicApi
*/
export function getLocaleExtraDayPeriodRules(locale: string): (Time | [Time, Time])[] {
const data = findLocaleData(locale);
const data = ɵfindLocaleData(locale);
checkFullData(data);
const rules = data[LocaleDataIndex.ExtraData][ExtraLocaleDataIndex.ExtraDayPeriodsRules] || [];
const rules = data[ɵLocaleDataIndex.ExtraData][ExtraLocaleDataIndex.ExtraDayPeriodsRules] || [];
return rules.map((rule: string | [string, string]) => {
if (typeof rule === 'string') {
return extractTime(rule);
@ -552,11 +552,11 @@ export function getLocaleExtraDayPeriodRules(locale: string): (Time | [Time, Tim
*/
export function getLocaleExtraDayPeriods(
locale: string, formStyle: FormStyle, width: TranslationWidth): string[] {
const data = findLocaleData(locale);
const data = ɵfindLocaleData(locale);
checkFullData(data);
const dayPeriodsData = <string[][][]>[
data[LocaleDataIndex.ExtraData][ExtraLocaleDataIndex.ExtraDayPeriodFormats],
data[LocaleDataIndex.ExtraData][ExtraLocaleDataIndex.ExtraDayPeriodStandalone]
data[ɵLocaleDataIndex.ExtraData][ExtraLocaleDataIndex.ExtraDayPeriodFormats],
data[ɵLocaleDataIndex.ExtraData][ExtraLocaleDataIndex.ExtraDayPeriodStandalone]
];
const dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
return getLastDefinedValue(dayPeriods, width) || [];