From 208817f69ec4bc91d191b33788df7b6fc06e955a Mon Sep 17 00:00:00 2001 From: kotwys <52920928+kotwys@users.noreply.github.com> Date: Fri, 24 Jul 2020 19:24:55 +0400 Subject: [PATCH] Implemented ability to override definitions from @formatjs. Added fixed definitions for Esperanto (#26) * Introduce locale searching Some locales may be absent or incorrect in default packages so these should be obtained from other places instead. * Add fixed Esperanto locale * Update Esperanto locales * Redo locale substitution This reverts commit f2e1047fd8bc88082169577dfe168384013c51cc. * Include locales in the repository * Add newline character at the end --- .eslintignore | 1 + .prettierignore | 1 + package.json | 1 + .../i18n/overrides/relativetimeformat/eo.js | 2 ++ tsconfig.json | 3 +- webpack.config.js | 13 ++++++++ yarn.lock | 32 +++++++++++++++++++ 7 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 packages/app/services/i18n/overrides/relativetimeformat/eo.js diff --git a/.eslintignore b/.eslintignore index a47b4d6..1ec25c2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,3 +3,4 @@ dll storybook-static node_modules cache +packages/app/services/i18n/overrides diff --git a/.prettierignore b/.prettierignore index d8be4ed..c2dcab7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,3 +9,4 @@ cache *.svg *.hbs .gitlab-ci.yml +packages/app/services/i18n/overrides diff --git a/package.json b/package.json index 77205ce..d8c3b8d 100644 --- a/package.json +++ b/package.json @@ -132,6 +132,7 @@ "exports-loader": "^0.7.0", "extract-react-intl-messages": "^4.1.1", "file-loader": "^6.0.0", + "file-replace-loader": "^1.2.0", "html-loader": "^1.1.0", "html-webpack-plugin": "^4.3.0", "identity-obj-proxy": "^3.0.0", diff --git a/packages/app/services/i18n/overrides/relativetimeformat/eo.js b/packages/app/services/i18n/overrides/relativetimeformat/eo.js new file mode 100644 index 0000000..a5ce4bd --- /dev/null +++ b/packages/app/services/i18n/overrides/relativetimeformat/eo.js @@ -0,0 +1,2 @@ +/* @generated */ +Intl.RelativeTimeFormat&&"function"==typeof Intl.RelativeTimeFormat.__addLocaleData&&Intl.RelativeTimeFormat.__addLocaleData({data:{eo:{nu:["latn"],year:{0:"en ĉi tiu jaro",1:"en la sekva jaro","-1":"en la pasinta jaro",past:{one:"antaŭ {0} jaro",other:"antaŭ {0} jaroj"},future:{one:"post {0} jaro",other:"post {0} jaroj"}},"year-short":{0:"ĉi-jare",1:"venontjare","-1":"pasintjare",past:{one:"antaŭ {0} jaro",other:"antaŭ {0} jaroj"},future:{one:"post {0} jaro",other:"post {0} jaroj"}},"year-narrow":{0:"ĉi-jare",1:"venontjare","-1":"pasintjare",past:{one:"antaŭ {0} jaro",other:"antaŭ {0} jaroj"},future:{one:"post {0} jaro",other:"post {0} jaroj"}},quarter:{0:"en ĉi tiu kvaronjaro",1:"en la venonta kvaronjaro","-1":"en la pasinta kvaronjaro",past:{one:"antaŭ {0} kvaronjaro",other:"antaŭ {0} kvaronjaroj"},future:{one:"post {0} kvaronjaro",other:"post {0} kvaronjaroj"}},"quarter-short":{0:"ĉi-kvaronjare",1:"venontkvaronjare","-1":"pasintkvaronjare",past:{one:"antaŭ {0} kvaronjaro",other:"antaŭ {0} kvaronjaroj"},future:{one:"post {0} kvaronjaro",other:"post {0} kvaronjaroj"}},"quarter-narrow":{0:"ĉi-kvaronjare",1:"venontkvaronjare","-1":"pasintkvaronjare",past:{one:"antaŭ {0} kvaronjaro",other:"antaŭ {0} kvaronjaroj"},future:{one:"post {0} kvaronjaro",other:"post {0} kvaronjaroj"}},month:{0:"en ĉi tiu monato",1:"en la venonta monato","-1":"en la pasinta monato",past:{one:"antaŭ {0} monato",other:"antaŭ {0} monatoj"},future:{one:"post {0} monato",other:"post {0} monatoj"}},"month-short":{0:"ĉi-monate",1:"venontmonate","-1":"pasintmonate",past:{one:"antaŭ {0} monato",other:"antaŭ {0} monatoj"},future:{one:"post {0} monato",other:"post {0} monatoj"}},"month-narrow":{0:"ĉi-monate",1:"venontmonate","-1":"pasintmonate",past:{one:"antaŭ {0} monato",other:"antaŭ {0} monatoj"},future:{one:"post {0} monato",other:"post {0} monatoj"}},week:{0:"en ĉi tiu semajno",1:"en la venonta semajno","-1":"en la pasinta semajno",past:{one:"antaŭ {0} semajno",other:"antaŭ {0} semajnoj"},future:{one:"post {0} semajno",other:"post {0} semajnoj"}},"week-short":{0:"ĉi-semajne",1:"venontsemajne","-1":"pasintsemajne",past:{one:"antaŭ {0} semajno",other:"antaŭ {0} semajnoj"},future:{one:"post {0} semajno",other:"post {0} semajnoj"}},"week-narrow":{0:"ĉi-semajne",1:"venontsemajne","-1":"pasintsemajne",past:{one:"antaŭ {0} semajno",other:"antaŭ {0} semajnoj"},future:{one:"post {0} semajno",other:"post {0} semajnoj"}},day:{0:"hodiaŭ",1:"morgaŭ",2:"postmorgaŭ","-2":"antaŭhieraŭ","-1":"hieraŭ",past:{one:"antaŭ {0} tago",other:"antaŭ {0} tagoj"},future:{one:"post {0} tago",other:"post {0} tagoj"}},"day-short":{0:"hodiaŭ",1:"morgaŭ",2:"postmorgaŭ","-2":"antaŭhieraŭ","-1":"hieraŭ",past:{one:"antaŭ {0} tago",other:"antaŭ {0} tagoj"},future:{one:"post {0} tago",other:"post {0} tagoj"}},"day-narrow":{0:"hodiaŭ",1:"morgaŭ",2:"postmorgaŭ","-2":"antaŭhieraŭ","-1":"hieraŭ",past:{one:"antaŭ {0} tago",other:"antaŭ {0} tagoj"},future:{one:"post {0} tago",other:"post {0} tagoj"}},hour:{0:"en ĉi tiu horo",past:{one:"antaŭ {0} horo",other:"antaŭ {0} horoj"},future:{one:"post {0} horo",other:"post {0} horoj"}},"hour-short":{0:"ĉi-hore",past:{one:"antaŭ {0} horo",other:"antaŭ {0} horoj"},future:{one:"post {0} horo",other:"post {0} horoj"}},"hour-narrow":{0:"ĉi-hore",past:{one:"antaŭ {0} horo",other:"antaŭ {0} horoj"},future:{one:"post {0} horo",other:"post {0} horoj"}},minute:{0:"en ĉi tiu minuto",past:{one:"antaŭ {0} minuto",other:"antaŭ {0} minutoj"},future:{one:"post {0} minuto",other:"post {0} minutoj"}},"minute-short":{0:"ĉi-minute",past:{one:"antaŭ {0} minuto",other:"antaŭ {0} minutoj"},future:{one:"post {0} minuto",other:"post {0} minutoj"}},"minute-narrow":{0:"ĉi-minute",past:{one:"antaŭ {0} minuto",other:"antaŭ {0} minutoj"},future:{one:"post {0} minuto",other:"post {0} minutoj"}},second:{0:"en ĉi tiu sekundo",past:{one:"antaŭ {0} sekundo",other:"antaŭ {0} sekundoj"},future:{one:"post {0} sekundo",other:"post {0} sekundoj"}},"second-short":{0:"ĉi-sekunde",past:{one:"antaŭ {0} sekundo",other:"antaŭ {0} sekundoj"},future:{one:"post {0} sekundo",other:"post {0} sekundoj"}},"second-narrow":{0:"ĉi-sekunde",past:{one:"antaŭ {0} sekundo",other:"antaŭ {0} sekundoj"},future:{one:"post {0} sekundo",other:"post {0} sekundoj"}}}},availableLocales:["eo"],aliases:{},parentLocales:{}}); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index aefd871..49122cf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,5 +21,6 @@ "jsx": "preserve", "strict": true }, - "include": ["@types", "packages", "config", ".storybook"] + "include": ["@types", "packages", "config", ".storybook"], + "exclude": ["packages/app/services/i18n/overrides"] } diff --git a/webpack.config.js b/webpack.config.js index d3f160b..65f195d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -200,6 +200,19 @@ const webpackConfig = { type: 'javascript/auto', use: ['fontgen-loader'], }, + { + // Replace some locales provided by FormatJS with local ones + test: /@formatjs\/intl-\w+\/dist\/locale-data/, + loader: 'file-replace-loader', + options: { + condition: 'if-replacement-exists', + replacement: (resource) => + resource.replace( + /node_modules\/@formatjs\/intl-(\w+)\/dist\/locale-data\/(\w+)\.js/, + 'packages/app/services/i18n/overrides/$1/$2.js', + ), + }, + }, ], }, diff --git a/yarn.lock b/yarn.lock index 75acf16..42303fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3511,6 +3511,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== +"@types/json-schema@^7.0.4": + version "7.0.5" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.5.tgz#dcce4430e64b443ba8945f0290fb564ad5bac6dd" + integrity sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ== + "@types/json5@^0.0.30": version "0.0.30" resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.30.tgz#44cb52f32a809734ca562e685c6473b5754a7818" @@ -4295,6 +4300,16 @@ ajv@^6.10.0, ajv@^6.5.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^6.12.2: + version "6.12.3" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706" + integrity sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + alphanum-sort@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3" @@ -8029,6 +8044,14 @@ file-loader@^6.0.0: loader-utils "^2.0.0" schema-utils "^2.6.5" +file-replace-loader@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/file-replace-loader/-/file-replace-loader-1.2.0.tgz#1271c51c5515380282192afb52c84b52ddd1dd1a" + integrity sha512-uIpToqndYZ4JwrTtDAedRk2721Dam9S4T0ZZQKrxljOA5BBEhIBVRNSwOc7X6vXmlVeXBM+goNvUq5Uis4UBCg== + dependencies: + loader-utils "^1.2.3" + schema-utils "^2.6.4" + file-system-cache@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/file-system-cache/-/file-system-cache-1.0.5.tgz#84259b36a2bbb8d3d6eb1021d3132ffe64cfff4f" @@ -14405,6 +14428,15 @@ schema-utils@^2.6.1: ajv "^6.10.2" ajv-keywords "^3.4.1" +schema-utils@^2.6.4: + version "2.7.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.0.tgz#17151f76d8eae67fbbf77960c33c676ad9f4efc7" + integrity sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A== + dependencies: + "@types/json-schema" "^7.0.4" + ajv "^6.12.2" + ajv-keywords "^3.4.1" + scss-tokenizer@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1"