Skip to content

Commit 3cd9c59

Browse files
feat(translations): add a new translations-test plugin to test and demo translations features (#1484)
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
1 parent 72c0abd commit 3cd9c59

26 files changed

Lines changed: 2878 additions & 152 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-translations-test': patch
3+
---
4+
5+
Release an initial version

workspaces/translations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"lint:all": "backstage-cli repo lint",
2626
"prettier:check": "prettier --check .",
2727
"prettier:fix": "prettier --write .",
28-
"new": "backstage-cli new --scope @red-hat-developer-hub",
28+
"new": "backstage-cli new --scope red-hat-developer-hub",
2929
"postinstall": "cd ../../ && yarn install"
3030
},
3131
"workspaces": {

workspaces/translations/packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@material-ui/icons": "^4.9.1",
5151
"@red-hat-developer-hub/backstage-plugin-theme": "^0.10.0",
5252
"@red-hat-developer-hub/backstage-plugin-translations": "workspace:^",
53+
"@red-hat-developer-hub/backstage-plugin-translations-test": "workspace:^",
5354
"react": "^18.0.2",
5455
"react-dom": "^18.0.2",
5556
"react-router": "^6.3.0",

workspaces/translations/packages/app/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { SignalsDisplay } from '@backstage/plugin-signals';
5656
import { getThemes } from '@red-hat-developer-hub/backstage-plugin-theme';
5757

5858
import { TranslationsPage } from '@red-hat-developer-hub/backstage-plugin-translations';
59+
import { TranslationsTestPage } from '@red-hat-developer-hub/backstage-plugin-translations-test';
5960

6061
const app = createApp({
6162
apis,
@@ -121,6 +122,7 @@ const routes = (
121122
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
122123
<Route path="/notifications" element={<NotificationsPage />} />
123124
<Route path="/translations" element={<TranslationsPage />} />
125+
<Route path="/translations-test" element={<TranslationsTestPage />} />
124126
</FlatRoutes>
125127
);
126128

workspaces/translations/packages/app/src/components/Root/Root.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ export const Root = ({ children }: PropsWithChildren<{}>) => (
9898
to="translations"
9999
text="Translations"
100100
/>
101+
<SidebarItem
102+
icon={ExtensionIcon}
103+
to="translations-test"
104+
text="Translations Test"
105+
/>
101106
<SidebarDivider />
102107
<SidebarScrollWrapper>
103108
{/* Items in this group will be scrollable if they run out of space */}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# translations-test
2+
3+
Welcome to the translations-test plugin!
4+
5+
_This plugin was created through the Backstage CLI_
6+
7+
## Getting started
8+
9+
Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/translations-test](http://localhost:3000/translations-test).
10+
11+
You can also serve the plugin in isolation by running `yarn start` in the plugin directory.
12+
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads.
13+
It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import { createDevApp } from '@backstage/dev-utils';
17+
import { translationsTestPlugin, TranslationsTestPage } from '../src/plugin';
18+
19+
createDevApp()
20+
.registerPlugin(translationsTestPlugin)
21+
.addPage({
22+
element: <TranslationsTestPage />,
23+
title: 'Root Page',
24+
path: '/translations-test',
25+
})
26+
.render();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "@red-hat-developer-hub/backstage-plugin-translations-test",
3+
"version": "0.0.0",
4+
"license": "Apache-2.0",
5+
"main": "src/index.ts",
6+
"types": "src/index.ts",
7+
"publishConfig": {
8+
"access": "public",
9+
"main": "dist/index.esm.js",
10+
"types": "dist/index.d.ts"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/redhat-developer/rhdh-plugins",
15+
"directory": "workspaces/translations/plugins/translations-test"
16+
},
17+
"backstage": {
18+
"role": "frontend-plugin",
19+
"pluginId": "translations-test",
20+
"pluginPackages": [
21+
"@red-hat-developer-hub/backstage-plugin-translations-test"
22+
]
23+
},
24+
"sideEffects": false,
25+
"scripts": {
26+
"start": "backstage-cli package start",
27+
"build": "backstage-cli package build",
28+
"lint": "backstage-cli package lint",
29+
"test": "backstage-cli package test",
30+
"clean": "backstage-cli package clean",
31+
"prepack": "backstage-cli package prepack",
32+
"postpack": "backstage-cli package postpack"
33+
},
34+
"dependencies": {
35+
"@backstage/core-components": "0.17.2",
36+
"@backstage/core-plugin-api": "1.10.7",
37+
"@backstage/plugin-user-settings": "^0.8.22",
38+
"@backstage/theme": "0.6.6",
39+
"@backstage/ui": "^0.7.0"
40+
},
41+
"peerDependencies": {
42+
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
43+
},
44+
"devDependencies": {
45+
"@backstage/cli": "0.32.1",
46+
"@backstage/core-app-api": "1.17.0",
47+
"@backstage/dev-utils": "1.1.10",
48+
"@backstage/test-utils": "1.7.8",
49+
"@testing-library/jest-dom": "^6.0.0",
50+
"@testing-library/react": "^14.0.0",
51+
"@testing-library/user-event": "^14.0.0",
52+
"msw": "^1.0.0",
53+
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
54+
},
55+
"files": [
56+
"dist"
57+
]
58+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## API Report File for "@red-hat-developer-hub/backstage-plugin-translations-test"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
import { BackstagePlugin } from '@backstage/core-plugin-api';
7+
import { JSX as JSX_2 } from 'react/jsx-runtime';
8+
import { RouteRef } from '@backstage/core-plugin-api';
9+
import { TranslationRef } from '@backstage/core-plugin-api/alpha';
10+
import { TranslationResource } from '@backstage/core-plugin-api/alpha';
11+
12+
// @public (undocumented)
13+
export const TranslationsTestPage: () => JSX_2.Element;
14+
15+
// @public (undocumented)
16+
export const translationsTestPlugin: BackstagePlugin<
17+
{
18+
root: RouteRef<undefined>;
19+
},
20+
{},
21+
{}
22+
>;
23+
24+
// @public (undocumented)
25+
export const translationsTestTranslationRef: TranslationRef<
26+
'plugin.translations-test',
27+
{
28+
readonly 'interpolation.key': string;
29+
readonly 'interpolation.nested.key': string;
30+
readonly 'interpolation.complex.message': string;
31+
readonly 'interpolation.complex.linkText': string;
32+
readonly 'page.title': string;
33+
readonly 'page.subtitle': string;
34+
readonly 'objects.tree.res': string;
35+
readonly 'essentials.key': string;
36+
readonly 'essentials.look.deep': string;
37+
readonly 'formatting.intlNumber': string;
38+
readonly 'formatting.intlNumberWithOptions': string;
39+
readonly 'formatting.intlDateTime': string;
40+
readonly 'formatting.intlRelativeTime': string;
41+
readonly 'formatting.intlRelativeTimeWithOptions': string;
42+
readonly 'formatting.intlRelativeTimeWithOptionsExplicit': string;
43+
readonly 'plurals.key_zero': string;
44+
readonly 'plurals.key_one': string;
45+
readonly 'plurals.key_two': string;
46+
readonly 'plurals.key_few': string;
47+
readonly 'plurals.key_many': string;
48+
readonly 'plurals.key_other': string;
49+
readonly 'plurals.keyWithCount_one': string;
50+
readonly 'plurals.keyWithCount_other': string;
51+
readonly 'context.friend': string;
52+
readonly 'context.friend_male': string;
53+
readonly 'context.friend_female': string;
54+
readonly 'arrays.array': string;
55+
}
56+
>;
57+
58+
// @public (undocumented)
59+
export const translationsTestTranslations: TranslationResource<'plugin.translations-test'>;
60+
61+
// (No @packageDocumentation comment for this package)
62+
```

0 commit comments

Comments
 (0)