Skip to content

Commit

Permalink
Changed title text test so that it wont fail on useTranslation hook, …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Mylanos committed Aug 2, 2023
1 parent f9de271 commit dd1f8fc
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 1,830 deletions.
2 changes: 1 addition & 1 deletion console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions i18next-parser.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/example-page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!',
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
7 changes: 3 additions & 4 deletions src/components/ExamplePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
Expand All @@ -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.',
Expand Down
15 changes: 15 additions & 0 deletions test-frontend.sh
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit dd1f8fc

Please sign in to comment.