]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Fix i18n configuration
authorTiago Melo <tmelo@suse.com>
Fri, 7 Feb 2020 17:17:35 +0000 (16:17 -0100)
committerTiago Melo <tmelo@suse.com>
Tue, 12 May 2020 23:39:43 +0000 (23:39 +0000)
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/angular.json
src/pybind/mgr/dashboard/frontend/package.json
src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/supported-languages.enum.ts
src/pybind/mgr/dashboard/frontend/src/polyfills.ts
src/pybind/mgr/dashboard/tests/test_home.py

index beaeb5a549c54b23c580f3b2e171a8398df31fbd..310b340d80398211dc6d2ff6e43fc486754fe874 100644 (file)
@@ -5,59 +5,20 @@
   "projects": {
     "ceph-dashboard": {
       "i18n": {
+        "sourceLocale": { "code": "en", "baseHref": "" },
         "locales": {
-          "cs": {
-            "translation": "src/locale/messages.cs.xlf",
-            "baseHref": ""
-          },
-          "de-DE": {
-            "translation": "src/locale/messages.de-DE.xlf",
-            "baseHref": ""
-          },
-          "en-US": {
-            "translation": "src/locale/messages.en-US.xlf",
-            "baseHref": ""
-          },
-          "es-ES": {
-            "translation": "src/locale/messages.es-ES.xlf",
-            "baseHref": ""
-          },
-          "fr-FR": {
-            "translation": "src/locale/messages.fr-FR.xlf",
-            "baseHref": ""
-          },
-          "id-ID": {
-            "translation": "src/locale/messages.id-ID.xlf",
-            "baseHref": ""
-          },
-          "it-IT": {
-            "translation": "src/locale/messages.it-IT.xlf",
-            "baseHref": ""
-          },
-          "ja-JP": {
-            "translation": "src/locale/messages.ja-JP.xlf",
-            "baseHref": ""
-          },
-          "ko-KR": {
-            "translation": "src/locale/messages.ko-KR.xlf",
-            "baseHref": ""
-          },
-          "pl-PL": {
-            "translation": "src/locale/messages.pl-PL.xlf",
-            "baseHref": ""
-          },
-          "pt-BR": {
-            "translation": "src/locale/messages.pt-BR.xlf",
-            "baseHref": ""
-          },
-          "zh-CN": {
-            "translation": "src/locale/messages.zh-CN.xlf",
-            "baseHref": ""
-          },
-          "zh-TW": {
-            "translation": "src/locale/messages.zh-TW.xlf",
-            "baseHref": ""
-          }
+          "cs": { "translation": "src/locale/messages.cs.xlf", "baseHref": "" },
+          "de": { "translation": "src/locale/messages.de-DE.xlf", "baseHref": "" },
+          "es": { "translation": "src/locale/messages.es-ES.xlf", "baseHref": "" },
+          "fr": { "translation": "src/locale/messages.fr-FR.xlf", "baseHref": "" },
+          "id": { "translation": "src/locale/messages.id-ID.xlf", "baseHref": "" },
+          "it": { "translation": "src/locale/messages.it-IT.xlf", "baseHref": "" },
+          "ja": { "translation": "src/locale/messages.ja-JP.xlf", "baseHref": "" },
+          "ko": { "translation": "src/locale/messages.ko-KR.xlf", "baseHref": "" },
+          "pl": { "translation": "src/locale/messages.pl-PL.xlf", "baseHref": "" },
+          "pt": { "translation": "src/locale/messages.pt-BR.xlf", "baseHref": "" },
+          "zh-Hans": { "translation": "src/locale/messages.zh-CN.xlf", "baseHref": "" },
+          "zh-Hant": { "translation": "src/locale/messages.zh-TW.xlf", "baseHref": "" }
         }
       },
       "root": "",
@@ -74,6 +35,7 @@
             "main": "src/main.ts",
             "tsConfig": "src/tsconfig.app.json",
             "polyfills": "src/polyfills.ts",
+            "deleteOutputPath": false,
             "assets": [
               "src/assets",
               "src/favicon.ico",
               ]
             },
             "cs": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "cs"
-              ],
-              "outputPath": "dist"
+              "localize": ["cs"]
             },
             "de-DE": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "de-DE"
-              ],
-              "outputPath": "dist"
+              "localize": ["de"]
             },
             "en-US": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "en-US"
-              ],
-              "outputPath": "dist"
+              "localize": ["en"]
             },
             "es-ES": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "es-ES"
-              ],
-              "outputPath": "dist"
+              "localize": ["es"]
             },
             "fr-FR": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "fr-FR"
-              ],
-              "outputPath": "dist"
+              "localize": ["fr"]
             },
             "id-ID": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "id-ID"
-              ],
-              "outputPath": "dist"
+              "localize": ["id"]
             },
             "it-IT": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "it-IT"
-              ],
-              "outputPath": "dist"
+              "localize": ["it"]
             },
             "ja-JP": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "ja-JP"
-              ],
-              "outputPath": "dist"
+              "localize": ["ja"]
             },
             "ko-KR": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "ko-KR"
-              ],
-              "outputPath": "dist"
+              "localize": ["ko"]
             },
             "pl-PL": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "pl-PL"
-              ],
-              "outputPath": "dist"
+              "localize": ["pl"]
             },
             "pt-BR": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "pt-BR"
-              ],
-              "outputPath": "dist"
+              "localize": ["pt"]
             },
             "zh-CN": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "zh-CN"
-              ],
-              "outputPath": "dist"
+              "localize": ["zh-Hans"]
             },
             "zh-TW": {
-              "budgets": [
-                {
-                  "type": "anyComponentStyle",
-                  "maximumWarning": "6kb"
-                }
-              ],
-              "localize": [
-                "zh-TW"
-              ],
-              "outputPath": "dist"
+              "localize": ["zh-Hant"]
             }
           }
         },
             "cs": {
               "browserTarget": "ceph-dashboard:build:cs"
             },
-            "de-DE": {
-              "browserTarget": "ceph-dashboard:build:de-DE"
+            "de": {
+              "browserTarget": "ceph-dashboard:build:de"
             },
-            "en-US": {
-              "browserTarget": "ceph-dashboard:build:en-US"
+            "en": {
+              "browserTarget": "ceph-dashboard:build:en"
             },
-            "es-ES": {
-              "browserTarget": "ceph-dashboard:build:es-ES"
+            "es": {
+              "browserTarget": "ceph-dashboard:build:es"
             },
-            "fr-FR": {
-              "browserTarget": "ceph-dashboard:build:fr-FR"
+            "fr": {
+              "browserTarget": "ceph-dashboard:build:fr"
             },
-            "id-ID": {
-              "browserTarget": "ceph-dashboard:build:id-ID"
+            "id": {
+              "browserTarget": "ceph-dashboard:build:id"
             },
-            "it-IT": {
-              "browserTarget": "ceph-dashboard:build:it-IT"
+            "it": {
+              "browserTarget": "ceph-dashboard:build:it"
             },
-            "ja-JP": {
-              "browserTarget": "ceph-dashboard:build:ja-JP"
+            "ja": {
+              "browserTarget": "ceph-dashboard:build:ja"
             },
-            "ko-KR": {
-              "browserTarget": "ceph-dashboard:build:ko-KR"
+            "ko": {
+              "browserTarget": "ceph-dashboard:build:ko"
             },
-            "pl-PL": {
-              "browserTarget": "ceph-dashboard:build:pl-PL"
+            "pl": {
+              "browserTarget": "ceph-dashboard:build:pl"
             },
-            "pt-BR": {
-              "browserTarget": "ceph-dashboard:build:pt-BR"
+            "pt": {
+              "browserTarget": "ceph-dashboard:build:pt"
             },
             "zh-CN": {
               "browserTarget": "ceph-dashboard:build:zh-CN"
   "cli": {
     "analytics": false
   }
-}
\ No newline at end of file
+}
index d3fa80a1c20b1611dd057c8d782c60fa1a07e140..1fa5f23c90a61fb6c483905fd75c0bd1ecce3fc6 100644 (file)
@@ -8,7 +8,7 @@
   "scripts": {
     "ng": "ng",
     "start": "npm run env_build && ng serve --host 0.0.0.0",
-    "build": "export _locale=${LOCALE:-$npm_package_config_locale}; if [ ${_locale} = $npm_package_config_locale ]; then export _file=; else export _file=src/locale/messages.${_locale}.xlf; fi; ng build --outputPath=dist/${_locale} --i18nFile=${_file} --i18nLocale=${_locale}",
+    "build": "export _locale=${LOCALE:-$npm_package_config_locale}; ng build --configuration=${_locale}",
     "prebuild": "npm run env_build",
     "build:cs": "LOCALE=cs npm run build",
     "build:de-DE": "LOCALE=de-DE npm run build",
@@ -25,7 +25,7 @@
     "build:zh-TW": "LOCALE=zh-TW npm run build",
     "env_build": "cp src/environments/environment.tpl.ts src/environments/environment.prod.ts && cp src/environments/environment.tpl.ts src/environments/environment.ts  && node ./environment.build.js",
     "i18n": "npm run i18n:extract && npm run i18n:push && npm run i18n:pull && npm run i18n:merge",
-    "i18n:extract": "ng xi18n --i18n-format xlf --i18n-locale en-US --output-path locale --progress=false && ngx-extractor -i 'src/**/*.ts' -f xlf -o src/locale/messages.xlf -l en-US",
+    "i18n:extract": "ng xi18n --output-path locale --progress=false && ngx-extractor -i 'src/**/*.ts' -f xlf -o src/locale/messages.xlf -l en-US",
     "i18n:push": "npx i18ntool push -c i18n.config.json",
     "i18n:pull": "npx i18ntool pull -c i18n.config.json",
     "i18n:merge": "npx i18ntool merge -c i18n.config.json",
index e3a09dba73a6ed15cc5ac5082e2c66e557767860..57753f17f4d102d87359cd8dd45a9eea851fa84a 100644 (file)
@@ -44,47 +44,47 @@ describe('LanguageSelectorComponent', () => {
     expectLanguageChange('cs');
   });
 
-  it('should change to de-DE', () => {
-    expectLanguageChange('de-DE');
+  it('should change to de', () => {
+    expectLanguageChange('de');
   });
 
-  it('should change to es-ES', () => {
-    expectLanguageChange('es-ES');
+  it('should change to es', () => {
+    expectLanguageChange('es');
   });
 
-  it('should change to fr-FR', () => {
-    expectLanguageChange('fr-FR');
+  it('should change to fr', () => {
+    expectLanguageChange('fr');
   });
 
-  it('should change to id-ID', () => {
-    expectLanguageChange('id-ID');
+  it('should change to id', () => {
+    expectLanguageChange('id');
   });
 
-  it('should change to it-IT', () => {
-    expectLanguageChange('it-IT');
+  it('should change to it', () => {
+    expectLanguageChange('it');
   });
 
-  it('should change to ja-JP', () => {
-    expectLanguageChange('ja-JP');
+  it('should change to ja', () => {
+    expectLanguageChange('ja');
   });
 
-  it('should change to ko-KR', () => {
-    expectLanguageChange('ko-KR');
+  it('should change to ko', () => {
+    expectLanguageChange('ko');
   });
 
-  it('should change to pl-PL', () => {
-    expectLanguageChange('pl-PL');
+  it('should change to pl', () => {
+    expectLanguageChange('pl');
   });
 
-  it('should change to pt-BR', () => {
-    expectLanguageChange('pt-BR');
+  it('should change to pt', () => {
+    expectLanguageChange('pt');
   });
 
-  it('should change to zh-CN', () => {
-    expectLanguageChange('zh-CN');
+  it('should change to zh-Hans', () => {
+    expectLanguageChange('zh-Hans');
   });
 
-  it('should change to zh-TW', () => {
-    expectLanguageChange('zh-TW');
+  it('should change to zh-Hant', () => {
+    expectLanguageChange('zh-Hant');
   });
 });
index 1ba8a6eb667a0c96c86807c462020e2211a7676d..251ae4b072a06a7c2407bb2b3c27900f433ecfc3 100644 (file)
@@ -16,18 +16,18 @@ import {
 // language-selector.component.spec.ts
 export enum SupportedLanguages {
   'cs' = 'Čeština',
-  'de-DE' = 'Deutsch',
-  'en-US' = 'English',
-  'es-ES' = 'Español',
-  'fr-FR' = 'Français',
-  'id-ID' = 'Bahasa Indonesia',
-  'it-IT' = 'Italiano',
-  'ja-JP' = '日本語',
-  'ko-KR' = '한국어',
-  'pl-PL' = 'Polski',
-  'pt-BR' = 'Português (brasileiro)',
-  'zh-CN' = '中文 (简体)',
-  'zh-TW' = '中文 (繁體)'
+  'de' = 'Deutsch',
+  'en' = 'English',
+  'es' = 'Español',
+  'fr' = 'Français',
+  'id' = 'Bahasa Indonesia',
+  'it' = 'Italiano',
+  'ja' = '日本語',
+  'ko' = '한국어',
+  'pl' = 'Polski',
+  'pt' = 'Português (brasileiro)',
+  'zh-Hans' = '中文 (简体)',
+  'zh-Hant' = '中文 (繁體)'
 }
 
 // Supported languages:
index 39a942e0444ed4abf5d272975983f04eec945406..3368646d33aa0eac03fe9c3ac01e47f55bf878da 100644 (file)
@@ -1,3 +1,7 @@
+/***************************************************************************************************
+ * Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
+ */
+import '@angular/localize/init';
 /**
  * This file includes polyfills needed by Angular and is loaded before the app.
  * You can add your own extra polyfills to this file.
index 2ec1b2ad764164a7188277caa153faff67d01758..b44e6d09059478caf6b26e98cfd06118ff22510c 100644 (file)
@@ -24,7 +24,7 @@ class HomeTest(ControllerTestCase, FakeFsMixin):
         cls.fs.create_dir(frontend_path)
         cls.fs.create_file(
             os.path.join(frontend_path, '..', 'package.json'),
-            contents='{"config":{"locale": "en-US"}}')
+            contents='{"config":{"locale": "en"}}')
         with mock.patch(cls.builtins_open, new=cls.f_open),\
                 mock.patch('os.listdir', new=cls.f_os.listdir):
             lang = LanguageMixin()
@@ -52,7 +52,7 @@ class HomeTest(ControllerTestCase, FakeFsMixin):
     @mock.patch(FakeFsMixin.builtins_open, new=FakeFsMixin.f_open)
     @mock.patch('os.stat', new=FakeFsMixin.f_os.stat)
     @mock.patch('os.listdir', new=FakeFsMixin.f_os.listdir)
-    def test_home_en_us(self):
+    def test_home_en(self):
         self._get('/', headers=[('Accept-Language', 'en-US')])
         self.assertStatus(200)
         logger.info(self.body)