fix(ivy): use goog.LOCALE for Closure Compiler to define default LOCALE_ID (#31519)
Prior to this commit, default value for LOCALE_ID was not setup for Closure Compiler. In Closure Compiler, we can use `goog.LOCALE` as a default value, which will be replaced at build time with current locale. PR Close #31519
This commit is contained in:
parent
40d785f0a0
commit
09576e9683
|
@ -30,7 +30,16 @@ export function _keyValueDiffersFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _localeFactory(locale?: string): string {
|
export function _localeFactory(locale?: string): string {
|
||||||
return locale || 'en-US';
|
if (locale) {
|
||||||
|
return locale;
|
||||||
|
}
|
||||||
|
// Use `goog.LOCALE` as default value for `LOCALE_ID` token for Closure Compiler.
|
||||||
|
// Note: default `goog.LOCALE` value is `en`, when Angular used `en-US`. In order to preserve
|
||||||
|
// backwards compatibility, we use Angular default value over Closure Compiler's one.
|
||||||
|
if (ngI18nClosureMode && typeof goog !== 'undefined' && goog.LOCALE !== 'en') {
|
||||||
|
return goog.LOCALE;
|
||||||
|
}
|
||||||
|
return 'en-US';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ declare namespace goog {
|
||||||
* as it is sometimes true.
|
* as it is sometimes true.
|
||||||
*/
|
*/
|
||||||
export const DEBUG: boolean;
|
export const DEBUG: boolean;
|
||||||
|
export const LOCALE: string;
|
||||||
export const getMsg: (input: string, placeholders?: {[key: string]: string}) => string;
|
export const getMsg: (input: string, placeholders?: {[key: string]: string}) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue