소스 검색

Changed title text test so that it wont fail on useTranslation hook, that gets called with the title text instead of static string before changes. Changed the name of the locale file so that it follows plugin__<name-of-the-plugin> convention. Added a test-frontend.sh script that checks if the strings in the plugin have been localized using i18n.

Mylanos 3 년 전
부모
커밋
dd1f8fc995
7개의 변경된 파일30개의 추가작업 그리고 960개의 파일을 삭제
  1. 1 1
      console-extensions.json
  2. 1 2
      i18next-parser.config.js
  3. 1 1
      integration-tests/tests/example-page.cy.ts
  4. 2 1
      locales/en/plugin__console-plugin-template.json
  5. 3 4
      src/components/ExamplePage.tsx
  6. 15 0
      test-frontend.sh
  7. 7 951
      yarn.lock

+ 1 - 1
console-extensions.json

@@ -11,7 +11,7 @@
     "type": "console.navigation/href",
     "properties": {
       "id": "example",
-      "name": "Plugin Example",
+      "name": "%plugin__console-plugin-template~Plugin Example%",
       "href": "/example",
       "perspective": "admin",
       "section": "home"

+ 1 - 2
i18next-parser.config.js

@@ -3,14 +3,13 @@ const { CustomJSONLexer } = require('./i18n-scripts/lexers');
 
 // eslint-disable-next-line no-undef
 module.exports = {
-  input: ['src/**/*.{js,jsx,ts,tsx}'],
   sort: true,
   createOldCatalogs: false,
   keySeparator: false,
   locales: ['en'],
   namespaceSeparator: '~',
   reactNamespace: false,
-  defaultNamespace: 'plugin__crontab-plugin',
+  defaultNamespace: 'plugin__console-plugin-template',
   useKeysAsDefaultValue: true,
 
   // see below for more details

+ 1 - 1
integration-tests/tests/example-page.cy.ts

@@ -76,7 +76,7 @@ describe('Console plugin template test', () => {
     cy.get('[data-test="nav"]').contains('Plugin Example').click();
     cy.url().should('include', '/example');
     cy.get('[data-test="example-page-title"]').should(
-      'contain',
+      'include.text',
       'Hello, Plugin!',
     );
   });

+ 2 - 1
locales/en/plugin__console-plugin.json → locales/en/plugin__console-plugin-template.json

@@ -6,6 +6,7 @@
   "Hello, Plugin!": "Hello, Plugin!",
   "in package.json mapping the reference to the module.": "in package.json mapping the reference to the module.",
   "Nice!": "Nice!",
+  "Plugin Example": "Plugin Example",
   "This is a custom page contributed by the console plugin template. The extension that adds the page is declared in console-extensions.json in the project root along with the corresponding nav item. Update console-extensions.json to change or add extensions. Code references in console-extensions.json must have a corresonding property": "This is a custom page contributed by the console plugin template. The extension that adds the page is declared in console-extensions.json in the project root along with the corresponding nav item. Update console-extensions.json to change or add extensions. Code references in console-extensions.json must have a corresonding property",
   "Your plugin is working.": "Your plugin is working."
-}
+}

+ 3 - 4
src/components/ExamplePage.tsx

@@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next';
 
 
 export default function ExamplePage() {
-  const { t } = useTranslation('plugin__console-plugin');
+  const { t } = useTranslation('plugin__console-plugin-template');
 
   return (
     <>
@@ -28,19 +28,18 @@ export default function ExamplePage() {
             <Text component="p">
               <span className="console-plugin-template__nice">
                 {t('Nice!')}
-              </span>
+              </span>{' '}
               {t('Your plugin is working.')}
             </Text>
             <Text component="p">
               {t(
                 'This is a custom page contributed by the console plugin template. The extension that adds the page is declared in console-extensions.json in the project root along with the corresponding nav item. Update console-extensions.json to change or add extensions. Code references in console-extensions.json must have a corresonding property',
               )}
-              This is a custom page contributed by the console plugin template.
               <code>{t('exposedModules')}</code>{' '}
               {t('in package.json mapping the reference to the module.')}
             </Text>
             <Text component="p">
-            {t('After cloning this project, replace references to')}{' '}
+              {t('After cloning this project, replace references to')}{' '}
               <code>{t('console-template-plugin')}</code>{' '}
               {t(
                 'and other plugin metadata in package.json with values for your plugin.',

+ 15 - 0
test-frontend.sh

@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# https://ci-operator-configresolver-ui-ci.apps.ci.l2s4.p1.openshiftapps.com/help#env
+OPENSHIFT_CI=${OPENSHIFT_CI:=false}
+ARTIFACT_DIR=${ARTIFACT_DIR:=/tmp/artifacts}
+
+yarn i18n
+GIT_STATUS="$(git status --short --untracked-files -- public/locales packages/**/locales)"
+if [ -n "$GIT_STATUS" ]; then
+  echo "i18n files are not up to date. Run 'yarn i18n' then commit changes."
+  git --no-pager diff
+  exit 1
+fi

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 7 - 951
yarn.lock


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.