build: wire up new CLDR generation tool within Bazel (#42230)

Introduces a few Starlark macros for running the new Bazel
CLDR generation tool. Wires up the new tool so that locales
are generated properly. Also updates the existing
`closure-locale` file to match the new output generated by the Bazel tool.

This commit also re-adds a few locale files that aren't
generated by CLDR 37, but have been accidentally left in
the repository as the Gulp script never removed old locales
from previous CLDR versions. This problem is solved with the
Bazel generation of locale files, but for now we re-add these
old CLDR 33 locale files to not break developers relying on these
(even though the locale data indicies are incorrect; but there might
be users accessing the data directly)

PR Close #42230
This commit is contained in:
Paul Gschwendtner 2021-05-21 22:58:25 +02:00 committed by Alex Rickabaugh
parent 7a3a453072
commit 444d838905
17 changed files with 1417 additions and 5621 deletions

View File

@ -26,6 +26,11 @@ export const format: FormatConfig = {
'!dev-infra/build-worker.js',
// Do not format compliance test-cases since they must match generated code
'!packages/compiler-cli/test/compliance/test_cases/**/*.js',
// Do not format the locale files which are checked-in for Google3, but generated using
// the `generate-locales-tool` from `packages/common/locales`.
'!packages/core/src/i18n/locale_en.ts',
'!packages/common/locales/closure-locale.ts',
'!packages/common/src/i18n/currencies.ts',
]
},
'buildifier': true

View File

@ -1,7 +1,24 @@
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
load("//packages/common/locales:index.bzl", "generate_base_currencies_file")
load("//tools:defaults.bzl", "api_golden_test_npm_package", "ng_module", "ng_package")
package(default_visibility = ["//visibility:public"])
# This generates the `src/i18n/currencies.ts` file through the `generate-locales` tool. Since
# the base currencies file is checked-in for Google3, we add a `generated_file_test` to ensure
# the checked-in file is up-to-date. To disambiguate from the test, we use a more precise target
# name here.
generate_base_currencies_file(
name = "base_currencies_file_generated",
output_file = "base_currencies_generated.ts",
)
generated_file_test(
name = "base_currencies_file",
src = "src/i18n/currencies.ts",
generated = ":base_currencies_file_generated",
)
ng_module(
name = "common",
srcs = glob(

View File

@ -1,18 +1,47 @@
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
load("//packages/common/locales:index.bzl", "LOCALES", "generate_all_locale_files", "generate_closure_locales_file")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
package(default_visibility = ["//visibility:public"])
# This generates the `closure-locale.ts` file through the `generate-locales` tool. Since
# the `closure-locale.ts` file is checked-in for Google3, we add a `generated_file_test` to
# ensure the checked-in file is up-to-date. To disambiguate from the test, we use a more
# precise target name here.
generate_closure_locales_file(
name = "closure_locales_file_generated",
output_file = "closure_locales_generated.ts",
)
generated_file_test(
name = "closure_locale_file",
src = "closure-locale.ts",
generated = ":closure_locales_file_generated",
)
generate_all_locale_files(
name = "locale_files",
)
ts_library(
name = "locales",
srcs = glob(
["**/*.ts"],
# TODO(devversion): Remove glob for checked-in legacy locale files that haven't been
# removed in the past (when CLDR has been updated). These can be removed in a major.
srcs = [file for l in LOCALES for file in [
"%s.ts" % l,
"extra/%s.ts" % l,
]] + glob(
[
"*.ts",
"extra/*.ts",
],
exclude = ["closure-locale.ts"],
),
)
pkg_npm(
name = "package",
srcs = glob(["global/*.js"]) + ["package.json"],
srcs = ["package.json"],
substitutions = {
# Workaround for `.d.ts`` containing `/// <amd-module .../>`
# which are generated in TypeScript v2.9, but not before.
@ -25,5 +54,7 @@ pkg_npm(
# null out the require reference passed into the module.
"factory\\(require, exports\\)": "factory(null, exports)",
},
deps = [":locales"],
# TODO(devversion): Remove glob for checked-in legacy locale files that haven't been
# removed in the past (when CLDR has been updated). These can be removed in a major.
deps = ["global/%s.js" % l for l in LOCALES] + [":locales"] + glob(["global/*.js"]),
)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
const u = undefined;
export default [];

View File

@ -0,0 +1,18 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
const u = undefined;
export default [];

View File

@ -0,0 +1,18 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
const u = undefined;
export default [];

View File

@ -0,0 +1,46 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
const u = undefined;
function plural(n: number): number {
let i = Math.floor(Math.abs(n));
if (i === 0 || i === 1) return 1;
return 5;
}
export default [
'ff-CM', [['subaka', 'kikiiɗe'], u, u], u,
[
['d', 'a', 'm', 'n', 'n', 'm', 'h'], ['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi'],
['dewo', 'aaɓnde', 'mawbaare', 'njeslaare', 'naasaande', 'mawnde', 'hoore-biir'],
['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi']
],
u,
[
['s', 'c', 'm', 's', 'd', 'k', 'm', 'j', 's', 'y', 'j', 'b'],
['sii', 'col', 'mbo', 'see', 'duu', 'kor', 'mor', 'juk', 'slt', 'yar', 'jol', 'bow'],
[
'siilo', 'colte', 'mbooy', 'seeɗto', 'duujal', 'korse', 'morso', 'juko', 'siilto', 'yarkomaa',
'jolal', 'bowte'
]
],
u, [['H-I', 'C-I'], u, ['Hade Iisa', 'Caggal Iisa']], 1, [6, 0],
['d/M/y', 'd MMM, y', 'd MMMM y', 'EEEE d MMMM y'],
['HH:mm', 'HH:mm:ss', 'HH:mm:ss z', 'HH:mm:ss zzzz'], ['{1} {0}', u, u, u],
[',', ' ', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0%', '#,##0.00 ¤', '#E0'], 'FCFA', 'Mbuuɗi Seefaa BEAC',
{'JPY': ['JP¥', '¥'], 'USD': ['US$', '$']}, plural
];

View File

@ -0,0 +1,46 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
const u = undefined;
function plural(n: number): number {
let i = Math.floor(Math.abs(n));
if (i === 0 || i === 1) return 1;
return 5;
}
export default [
'ff-GN', [['subaka', 'kikiiɗe'], u, u], u,
[
['d', 'a', 'm', 'n', 'n', 'm', 'h'], ['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi'],
['dewo', 'aaɓnde', 'mawbaare', 'njeslaare', 'naasaande', 'mawnde', 'hoore-biir'],
['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi']
],
u,
[
['s', 'c', 'm', 's', 'd', 'k', 'm', 'j', 's', 'y', 'j', 'b'],
['sii', 'col', 'mbo', 'see', 'duu', 'kor', 'mor', 'juk', 'slt', 'yar', 'jol', 'bow'],
[
'siilo', 'colte', 'mbooy', 'seeɗto', 'duujal', 'korse', 'morso', 'juko', 'siilto', 'yarkomaa',
'jolal', 'bowte'
]
],
u, [['H-I', 'C-I'], u, ['Hade Iisa', 'Caggal Iisa']], 1, [6, 0],
['d/M/y', 'd MMM, y', 'd MMMM y', 'EEEE d MMMM y'],
['HH:mm', 'HH:mm:ss', 'HH:mm:ss z', 'HH:mm:ss zzzz'], ['{1} {0}', u, u, u],
[',', ' ', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0%', '#,##0.00 ¤', '#E0'], 'FG', 'GNF',
{'GNF': ['FG'], 'JPY': ['JP¥', '¥'], 'USD': ['US$', '$']}, plural
];

View File

@ -0,0 +1,46 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
const u = undefined;
function plural(n: number): number {
let i = Math.floor(Math.abs(n));
if (i === 0 || i === 1) return 1;
return 5;
}
export default [
'ff-MR', [['subaka', 'kikiiɗe'], u, u], u,
[
['d', 'a', 'm', 'n', 'n', 'm', 'h'], ['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi'],
['dewo', 'aaɓnde', 'mawbaare', 'njeslaare', 'naasaande', 'mawnde', 'hoore-biir'],
['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi']
],
u,
[
['s', 'c', 'm', 's', 'd', 'k', 'm', 'j', 's', 'y', 'j', 'b'],
['sii', 'col', 'mbo', 'see', 'duu', 'kor', 'mor', 'juk', 'slt', 'yar', 'jol', 'bow'],
[
'siilo', 'colte', 'mbooy', 'seeɗto', 'duujal', 'korse', 'morso', 'juko', 'siilto', 'yarkomaa',
'jolal', 'bowte'
]
],
u, [['H-I', 'C-I'], u, ['Hade Iisa', 'Caggal Iisa']], 1, [6, 0],
['d/M/y', 'd MMM, y', 'd MMMM y', 'EEEE d MMMM y'],
['h:mm a', 'h:mm:ss a', 'h:mm:ss a z', 'h:mm:ss a zzzz'], ['{1} {0}', u, u, u],
[',', ' ', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0%', '#,##0.00 ¤', '#E0'], 'UM', 'Ugiyya Muritani',
{'JPY': ['JP¥', '¥'], 'MRU': ['UM'], 'USD': ['US$', '$']}, plural
];

View File

@ -0,0 +1,60 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
(function(global) {
global.ng = global.ng || {};
global.ng.common = global.ng.common || {};
global.ng.common.locales = global.ng.common.locales || {};
const u = undefined;
function plural(n) {
let i = Math.floor(Math.abs(n));
if (i === 0 || i === 1) return 1;
return 5;
}
root.ng.common.locales['ff-cm'] = [
'ff-CM',
[['subaka', 'kikiiɗe'], u, u],
u,
[
['d', 'a', 'm', 'n', 'n', 'm', 'h'], ['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi'],
['dewo', 'aaɓnde', 'mawbaare', 'njeslaare', 'naasaande', 'mawnde', 'hoore-biir'],
['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi']
],
u,
[
['s', 'c', 'm', 's', 'd', 'k', 'm', 'j', 's', 'y', 'j', 'b'],
['sii', 'col', 'mbo', 'see', 'duu', 'kor', 'mor', 'juk', 'slt', 'yar', 'jol', 'bow'],
[
'siilo', 'colte', 'mbooy', 'seeɗto', 'duujal', 'korse', 'morso', 'juko', 'siilto', 'yarkomaa',
'jolal', 'bowte'
]
],
u,
[['H-I', 'C-I'], u, ['Hade Iisa', 'Caggal Iisa']],
1,
[6, 0],
['d/M/y', 'd MMM, y', 'd MMMM y', 'EEEE d MMMM y'],
['HH:mm', 'HH:mm:ss', 'HH:mm:ss z', 'HH:mm:ss zzzz'],
['{1} {0}', u, u, u],
[',', ' ', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0%', '#,##0.00 ¤', '#E0'],
'FCFA',
'Mbuuɗi Seefaa BEAC',
{'JPY': ['JP¥', '¥'], 'USD': ['US$', '$']},
plural,
[]
];
})(typeof globalThis !== 'undefined' && globalThis || typeof global !== 'undefined' && global ||
typeof window !== 'undefined' && window);

View File

@ -0,0 +1,60 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
(function(global) {
global.ng = global.ng || {};
global.ng.common = global.ng.common || {};
global.ng.common.locales = global.ng.common.locales || {};
const u = undefined;
function plural(n) {
let i = Math.floor(Math.abs(n));
if (i === 0 || i === 1) return 1;
return 5;
}
root.ng.common.locales['ff-gn'] = [
'ff-GN',
[['subaka', 'kikiiɗe'], u, u],
u,
[
['d', 'a', 'm', 'n', 'n', 'm', 'h'], ['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi'],
['dewo', 'aaɓnde', 'mawbaare', 'njeslaare', 'naasaande', 'mawnde', 'hoore-biir'],
['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi']
],
u,
[
['s', 'c', 'm', 's', 'd', 'k', 'm', 'j', 's', 'y', 'j', 'b'],
['sii', 'col', 'mbo', 'see', 'duu', 'kor', 'mor', 'juk', 'slt', 'yar', 'jol', 'bow'],
[
'siilo', 'colte', 'mbooy', 'seeɗto', 'duujal', 'korse', 'morso', 'juko', 'siilto', 'yarkomaa',
'jolal', 'bowte'
]
],
u,
[['H-I', 'C-I'], u, ['Hade Iisa', 'Caggal Iisa']],
1,
[6, 0],
['d/M/y', 'd MMM, y', 'd MMMM y', 'EEEE d MMMM y'],
['HH:mm', 'HH:mm:ss', 'HH:mm:ss z', 'HH:mm:ss zzzz'],
['{1} {0}', u, u, u],
[',', ' ', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0%', '#,##0.00 ¤', '#E0'],
'FG',
'GNF',
{'GNF': ['FG'], 'JPY': ['JP¥', '¥'], 'USD': ['US$', '$']},
plural,
[]
];
})(typeof globalThis !== 'undefined' && globalThis || typeof global !== 'undefined' && global ||
typeof window !== 'undefined' && window);

View File

@ -0,0 +1,60 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// **Note**: Locale files are generated through Bazel and never part of the sources. This is an
// exception for backwards compatibility. With the Gulp setup we never deleted old locale files
// when updating CLDR, so older locale files which have been removed, or renamed in the CLDR
// data remained in the repository. We keep these files checked-in until the next major to avoid
// potential breaking changes. It's worth noting that the locale data for such files is outdated
// anyway. e.g. the data is missing the directionality, throwing off the indices.
(function(global) {
global.ng = global.ng || {};
global.ng.common = global.ng.common || {};
global.ng.common.locales = global.ng.common.locales || {};
const u = undefined;
function plural(n) {
let i = Math.floor(Math.abs(n));
if (i === 0 || i === 1) return 1;
return 5;
}
root.ng.common.locales['ff-mr'] = [
'ff-MR',
[['subaka', 'kikiiɗe'], u, u],
u,
[
['d', 'a', 'm', 'n', 'n', 'm', 'h'], ['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi'],
['dewo', 'aaɓnde', 'mawbaare', 'njeslaare', 'naasaande', 'mawnde', 'hoore-biir'],
['dew', 'aaɓ', 'maw', 'nje', 'naa', 'mwd', 'hbi']
],
u,
[
['s', 'c', 'm', 's', 'd', 'k', 'm', 'j', 's', 'y', 'j', 'b'],
['sii', 'col', 'mbo', 'see', 'duu', 'kor', 'mor', 'juk', 'slt', 'yar', 'jol', 'bow'],
[
'siilo', 'colte', 'mbooy', 'seeɗto', 'duujal', 'korse', 'morso', 'juko', 'siilto', 'yarkomaa',
'jolal', 'bowte'
]
],
u,
[['H-I', 'C-I'], u, ['Hade Iisa', 'Caggal Iisa']],
1,
[6, 0],
['d/M/y', 'd MMM, y', 'd MMMM y', 'EEEE d MMMM y'],
['h:mm a', 'h:mm:ss a', 'h:mm:ss a z', 'h:mm:ss a zzzz'],
['{1} {0}', u, u, u],
[',', ' ', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0%', '#,##0.00 ¤', '#E0'],
'UM',
'Ugiyya Muritani',
{'JPY': ['JP¥', '¥'], 'MRU': ['UM'], 'USD': ['US$', '$']},
plural,
[]
];
})(typeof globalThis !== 'undefined' && globalThis || typeof global !== 'undefined' && global ||
typeof window !== 'undefined' && window);

View File

@ -0,0 +1,94 @@
load("@cldr_data//:index.bzl", _ALL_CLDR_LOCALES = "LOCALES")
# There are a couple of locales for which no data is present, even within the
# CLDR full tier packages. For these locales, we do not generate any data.
# TODO(devversion): Remove once we update to CLDR v39 where this problem no longer persists.
# Note that this worked before in the Gulp tooling without such an exclusion list because the
# `cldr-data-downloader` overwrote the `availableLocales` to only capture locales with data.
NO_DATA_LOCALES = [
"ff-Adlm",
"ff-Adlm-BF",
"ff-Adlm-CM",
"ff-Adlm-GH",
"ff-Adlm-GM",
"ff-Adlm-GW",
"ff-Adlm-LR",
"ff-Adlm-MR",
"ff-Adlm-NE",
"ff-Adlm-NG",
"ff-Adlm-SL",
"ff-Adlm-SN",
"mai",
"mni",
"mni-Beng",
"ms-ID",
"pcm",
"sat",
"sat-Olck",
"sd-Deva",
"su",
"su-Latn",
]
# List of locales the tool can generate files for.
LOCALES = [l for l in _ALL_CLDR_LOCALES if l not in NO_DATA_LOCALES]
# Labels resolving to the individual `generate-locale-tool` entry-points
GENERATE_LOCALES_TOOL_BIN = "//packages/common/locales/generate-locales-tool/bin"
GET_BASE_CURRENCIES_FILE_BIN = "%s:get-base-currencies-file" % GENERATE_LOCALES_TOOL_BIN
GET_BASE_LOCALE_FILE_BIN = "%s:get-base-locale-file" % GENERATE_LOCALES_TOOL_BIN
GET_CLOSURE_LOCALE_FILE_BIN = "%s:get-closure-locale-file" % GENERATE_LOCALES_TOOL_BIN
WRITE_LOCALE_FILES_TO_DIST_BIN = "%s:write-locale-files-to-dist" % GENERATE_LOCALES_TOOL_BIN
def _run_tool_with_single_output(name, output_file, tool, **kwargs):
native.genrule(
name = name,
outs = [output_file],
srcs = [],
exec_tools = [tool],
cmd = """$(location %s) > $@""" % tool,
**kwargs
)
def generate_base_currencies_file(name, output_file, **kwargs):
_run_tool_with_single_output(
name = name,
output_file = output_file,
tool = GET_BASE_CURRENCIES_FILE_BIN,
**kwargs
)
def generate_base_locale_file(name, output_file, **kwargs):
_run_tool_with_single_output(
name = name,
output_file = output_file,
tool = GET_BASE_LOCALE_FILE_BIN,
**kwargs
)
def generate_closure_locales_file(name, output_file, **kwargs):
_run_tool_with_single_output(
name = name,
output_file = output_file,
tool = GET_CLOSURE_LOCALE_FILE_BIN,
**kwargs
)
def generate_all_locale_files(name, **kwargs):
locale_files = []
for locale in LOCALES:
locale_files += [
"%s.ts" % locale,
"global/%s.js" % locale,
"extra/%s.ts" % locale,
]
native.genrule(
name = name,
outs = locale_files,
srcs = [],
exec_tools = [WRITE_LOCALE_FILES_TO_DIST_BIN],
cmd = """$(location %s) $(@D)""" % WRITE_LOCALE_FILES_TO_DIST_BIN,
**kwargs
)

View File

@ -0,0 +1,13 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// THIS CODE IS GENERATED - DO NOT MODIFY.
export type CurrenciesSymbols = [string] | [string | undefined, string];
/** @internal */
export const CURRENCIES_EN: {[code: string]: CurrenciesSymbols | [string | undefined, string | undefined, number]} = {"ADP":[undefined,undefined,0],"AFN":[undefined,undefined,0],"ALL":[undefined,undefined,0],"AMD":[undefined,undefined,2],"AOA":[undefined,"Kz"],"ARS":[undefined,"$"],"AUD":["A$","$"],"BAM":[undefined,"KM"],"BBD":[undefined,"$"],"BDT":[undefined,"৳"],"BHD":[undefined,undefined,3],"BIF":[undefined,undefined,0],"BMD":[undefined,"$"],"BND":[undefined,"$"],"BOB":[undefined,"Bs"],"BRL":["R$"],"BSD":[undefined,"$"],"BWP":[undefined,"P"],"BYN":[undefined,"р.",2],"BYR":[undefined,undefined,0],"BZD":[undefined,"$"],"CAD":["CA$","$",2],"CHF":[undefined,undefined,2],"CLF":[undefined,undefined,4],"CLP":[undefined,"$",0],"CNY":["CN¥","¥"],"COP":[undefined,"$",2],"CRC":[undefined,"₡",2],"CUC":[undefined,"$"],"CUP":[undefined,"$"],"CZK":[undefined,"Kč",2],"DJF":[undefined,undefined,0],"DKK":[undefined,"kr",2],"DOP":[undefined,"$"],"EGP":[undefined,"E£"],"ESP":[undefined,"₧",0],"EUR":["€"],"FJD":[undefined,"$"],"FKP":[undefined,"£"],"GBP":["£"],"GEL":[undefined,"₾"],"GIP":[undefined,"£"],"GNF":[undefined,"FG",0],"GTQ":[undefined,"Q"],"GYD":[undefined,"$",2],"HKD":["HK$","$"],"HNL":[undefined,"L"],"HRK":[undefined,"kn"],"HUF":[undefined,"Ft",2],"IDR":[undefined,"Rp",2],"ILS":["₪"],"INR":["₹"],"IQD":[undefined,undefined,0],"IRR":[undefined,undefined,0],"ISK":[undefined,"kr",0],"ITL":[undefined,undefined,0],"JMD":[undefined,"$"],"JOD":[undefined,undefined,3],"JPY":["¥",undefined,0],"KHR":[undefined,"៛"],"KMF":[undefined,"CF",0],"KPW":[undefined,"₩",0],"KRW":["₩",undefined,0],"KWD":[undefined,undefined,3],"KYD":[undefined,"$"],"KZT":[undefined,"₸"],"LAK":[undefined,"₭",0],"LBP":[undefined,"L£",0],"LKR":[undefined,"Rs"],"LRD":[undefined,"$"],"LTL":[undefined,"Lt"],"LUF":[undefined,undefined,0],"LVL":[undefined,"Ls"],"LYD":[undefined,undefined,3],"MGA":[undefined,"Ar",0],"MGF":[undefined,undefined,0],"MMK":[undefined,"K",0],"MNT":[undefined,"₮",2],"MRO":[undefined,undefined,0],"MUR":[undefined,"Rs",2],"MXN":["MX$","$"],"MYR":[undefined,"RM"],"NAD":[undefined,"$"],"NGN":[undefined,"₦"],"NIO":[undefined,"C$"],"NOK":[undefined,"kr",2],"NPR":[undefined,"Rs"],"NZD":["NZ$","$"],"OMR":[undefined,undefined,3],"PHP":[undefined,"₱"],"PKR":[undefined,"Rs",2],"PLN":[undefined,"zł"],"PYG":[undefined,"₲",0],"RON":[undefined,"lei"],"RSD":[undefined,undefined,0],"RUB":[undefined,"₽"],"RUR":[undefined,"р."],"RWF":[undefined,"RF",0],"SBD":[undefined,"$"],"SEK":[undefined,"kr",2],"SGD":[undefined,"$"],"SHP":[undefined,"£"],"SLL":[undefined,undefined,0],"SOS":[undefined,undefined,0],"SRD":[undefined,"$"],"SSP":[undefined,"£"],"STD":[undefined,undefined,0],"STN":[undefined,"Db"],"SYP":[undefined,"£",0],"THB":[undefined,"฿"],"TMM":[undefined,undefined,0],"TND":[undefined,undefined,3],"TOP":[undefined,"T$"],"TRL":[undefined,undefined,0],"TRY":[undefined,"₺"],"TTD":[undefined,"$"],"TWD":["NT$","$",2],"TZS":[undefined,undefined,2],"UAH":[undefined,"₴"],"UGX":[undefined,undefined,0],"USD":["$"],"UYI":[undefined,undefined,0],"UYU":[undefined,"$"],"UYW":[undefined,undefined,4],"UZS":[undefined,undefined,2],"VEF":[undefined,"Bs",2],"VND":["₫",undefined,0],"VUV":[undefined,undefined,0],"XAF":["FCFA",undefined,0],"XCD":["EC$","$"],"XOF":["CFA",undefined,0],"XPF":["CFPF",undefined,0],"XXX":["¤"],"YER":[undefined,undefined,0],"ZAR":[undefined,"R"],"ZMK":[undefined,undefined,0],"ZMW":[undefined,"ZK"],"ZWD":[undefined,undefined,0]};

View File

@ -1,7 +1,24 @@
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
load("//tools:defaults.bzl", "api_golden_test", "api_golden_test_npm_package", "ng_module", "ng_package")
load("//packages/common/locales:index.bzl", "generate_base_locale_file")
package(default_visibility = ["//visibility:public"])
# This generates the `src/i18n/locale_en.ts` file through the `generate-locales` tool. Since
# the base locale file is checked-in for Google3, we add a `generated_file_test` to ensure
# the checked-in file is up-to-date. To disambiguate from the test, we use a more precise target
# name here.
generate_base_locale_file(
name = "base_locale_file_generated",
output_file = "base_locale_file_generated.ts",
)
generated_file_test(
name = "base_locale_file",
src = "src/i18n/locale_en.ts",
generated = ":base_locale_file_generated",
)
ng_module(
name = "core",
srcs = glob(

View File

@ -0,0 +1,20 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// THIS CODE IS GENERATED - DO NOT MODIFY.
const u = undefined;
function plural(n: number): number {
const i = Math.floor(Math.abs(n)), v = n.toString().replace(/^[^.]*\.?/, '').length;
if (i === 1 && v === 0)
return 1;
return 5;
}
export default ["en",[["a","p"],["AM","PM"],u],[["AM","PM"],u,u],[["S","M","T","W","T","F","S"],["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["Su","Mo","Tu","We","Th","Fr","Sa"]],u,[["J","F","M","A","M","J","J","A","S","O","N","D"],["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],["January","February","March","April","May","June","July","August","September","October","November","December"]],u,[["B","A"],["BC","AD"],["Before Christ","Anno Domini"]],0,[6,0],["M/d/yy","MMM d, y","MMMM d, y","EEEE, MMMM d, y"],["h:mm a","h:mm:ss a","h:mm:ss a z","h:mm:ss a zzzz"],["{1}, {0}",u,"{1} 'at' {0}",u],[".",",",";","%","+","-","E","×","‰","∞","NaN",":"],["#,##0.###","#,##0%","¤#,##0.00","#E0"],"USD","$","US Dollar",{},"ltr", plural];