chore: add ui translation package (#5115)
* chore: add ui translation package * Update package.json * Create itchy-glasses-end.md
This commit is contained in:
7
.changeset/itchy-glasses-end.md
Normal file
7
.changeset/itchy-glasses-end.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
'@verdaccio/ui-theme': minor
|
||||||
|
'@verdaccio/ui-components': minor
|
||||||
|
'@verdaccio/ui-i18n': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: new i18n package for ui
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -36,6 +36,7 @@ packages/standalone/dist/
|
|||||||
packages/plugins/ui-theme/static
|
packages/plugins/ui-theme/static
|
||||||
/packages/plugins/ui-theme/src/i18n/download_translations/
|
/packages/plugins/ui-theme/src/i18n/download_translations/
|
||||||
!/packages/plugins/ui-theme/src/i18n/crowdin/ui.json
|
!/packages/plugins/ui-theme/src/i18n/crowdin/ui.json
|
||||||
|
/packages/core/**/download_translations/
|
||||||
|
|
||||||
## ui tests
|
## ui tests
|
||||||
!/packages/ui-components/vitest/api/*.tgz
|
!/packages/ui-components/vitest/api/*.tgz
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ api_token_env: CROWDIN_VERDACCIO_API_KEY
|
|||||||
preserve_hierarchy: true
|
preserve_hierarchy: true
|
||||||
|
|
||||||
files:
|
files:
|
||||||
|
- source: /packages/core/i18n/src/crowdin/*.json
|
||||||
|
translation: '/packages/core/i18n/src/download_translations/%locale%/%original_file_name%'
|
||||||
- source: /packages/plugins/ui-theme/src/i18n/crowdin/*.json
|
- source: /packages/plugins/ui-theme/src/i18n/crowdin/*.json
|
||||||
translation: '/packages/plugins/ui-theme/src/i18n/download_translations/%locale%/%original_file_name%'
|
translation: '/packages/plugins/ui-theme/src/i18n/download_translations/%locale%/%original_file_name%'
|
||||||
- source: /website/i18n/en/**/*
|
- source: /website/i18n/en/**/*
|
||||||
@@ -16,4 +18,3 @@ files:
|
|||||||
- source: /website/versioned_docs/**/*
|
- source: /website/versioned_docs/**/*
|
||||||
translation: /website/i18n/%locale%/docusaurus-plugin-content-docs/**/%original_file_name%
|
translation: /website/i18n/%locale%/docusaurus-plugin-content-docs/**/%original_file_name%
|
||||||
ignore: [/website/versioned_docs/version-6.x/api/**/*]
|
ignore: [/website/versioned_docs/version-6.x/api/**/*]
|
||||||
|
|
||||||
14
packages/core/i18n/.babelrc
Normal file
14
packages/core/i18n/.babelrc
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../.babelrc",
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"@babel/env",
|
||||||
|
{
|
||||||
|
"targets": {
|
||||||
|
"node": 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@babel/typescript"
|
||||||
|
]
|
||||||
|
}
|
||||||
6
packages/core/i18n/.eslintignore
Normal file
6
packages/core/i18n/.eslintignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
coverage/
|
||||||
|
lib/
|
||||||
|
.nyc_output
|
||||||
|
tests-report/
|
||||||
|
build/
|
||||||
5
packages/core/i18n/.eslintrc.json
Normal file
5
packages/core/i18n/.eslintrc.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/no-use-before-define": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
packages/core/i18n/package.json
Normal file
47
packages/core/i18n/package.json
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "@verdaccio/ui-i18n",
|
||||||
|
"version": "8.0.0-next-8.10",
|
||||||
|
"description": "ui i18n",
|
||||||
|
"keywords": [
|
||||||
|
"private",
|
||||||
|
"package",
|
||||||
|
"repository",
|
||||||
|
"registry",
|
||||||
|
"enterprise",
|
||||||
|
"modules",
|
||||||
|
"proxy",
|
||||||
|
"server",
|
||||||
|
"verdaccio"
|
||||||
|
],
|
||||||
|
"main": "./build/index.js",
|
||||||
|
"types": "./build/index.d.ts",
|
||||||
|
"author": "Juan Picado <juanpicado19@gmail.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://verdaccio.org",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "https",
|
||||||
|
"url": "https://github.com/verdaccio/verdaccio",
|
||||||
|
"directory": "packages/core/url-resolver"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/verdaccio/verdaccio/issues"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"clean": "rimraf ./build",
|
||||||
|
"test": "echo \"Error: no test specified\"",
|
||||||
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
||||||
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
||||||
|
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
|
||||||
|
"build": "pnpm run build:js && pnpm run build:types"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/verdaccio"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/core/i18n/src/index.ts
Normal file
1
packages/core/i18n/src/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { loadTranslationFile as default } from './loadTranslationFile';
|
||||||
9
packages/core/i18n/tsconfig.build.json
Normal file
9
packages/core/i18n/tsconfig.build.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./build"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["src/**/*.test.ts"]
|
||||||
|
}
|
||||||
9
packages/core/i18n/tsconfig.json
Normal file
9
packages/core/i18n/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.reference.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./build"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["src/**/*.test.ts"]
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
"@verdaccio/node-api": "workspace:8.0.0-next-8.10",
|
"@verdaccio/node-api": "workspace:8.0.0-next-8.10",
|
||||||
"@verdaccio/types": "workspace:*",
|
"@verdaccio/types": "workspace:*",
|
||||||
"@verdaccio/ui-components": "workspace:4.0.0-next-8.5",
|
"@verdaccio/ui-components": "workspace:4.0.0-next-8.5",
|
||||||
|
"@verdaccio/ui-i18n": "workspace:8.0.0-next-8.10",
|
||||||
"@vitejs/plugin-react": "4.3.4",
|
"@vitejs/plugin-react": "4.3.4",
|
||||||
"babel-loader": "8.4.1",
|
"babel-loader": "8.4.1",
|
||||||
"babel-plugin-dynamic-import-node": "2.3.3",
|
"babel-plugin-dynamic-import-node": "2.3.3",
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
|
||||||
|
import loadTranslationFile from '@verdaccio/ui-i18n';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_LANGUAGE,
|
DEFAULT_LANGUAGE,
|
||||||
LanguageConfiguration,
|
LanguageConfiguration,
|
||||||
listLanguages,
|
listLanguages,
|
||||||
listLanguagesAsString,
|
listLanguagesAsString,
|
||||||
} from './enabledLanguages';
|
} from './enabledLanguages';
|
||||||
import { loadTranslationFile } from './loadTranslationFile';
|
|
||||||
|
|
||||||
const languages = listLanguages.reduce((acc, item: LanguageConfiguration) => {
|
const languages = listLanguages.reduce((acc, item: LanguageConfiguration) => {
|
||||||
acc[item.lng] = {
|
acc[item.lng] = {
|
||||||
translation:
|
translation:
|
||||||
item.lng === DEFAULT_LANGUAGE ? require(`./crowdin/ui.json`) : loadTranslationFile(item.lng),
|
item.lng === DEFAULT_LANGUAGE
|
||||||
|
? loadTranslationFile(DEFAULT_LANGUAGE)
|
||||||
|
: loadTranslationFile(item.lng),
|
||||||
};
|
};
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import * as Flags from 'country-flag-icons/react/3x2';
|
|||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
|
||||||
|
import loadTranslation from '@verdaccio/ui-i18n';
|
||||||
|
|
||||||
const DEFAULT_LANGUAGE = 'en-US';
|
const DEFAULT_LANGUAGE = 'en-US';
|
||||||
|
|
||||||
export const listLanguages = [
|
export const listLanguages = [
|
||||||
@@ -19,7 +21,7 @@ const whitelist = listLanguages.reduce((acc, item) => {
|
|||||||
|
|
||||||
const resources = listLanguages.reduce((acc, item) => {
|
const resources = listLanguages.reduce((acc, item) => {
|
||||||
// Use English for all languages
|
// Use English for all languages
|
||||||
acc[item.lng] = { translation: require(`./ui.json`) };
|
acc[item.lng] = { translation: loadTranslation(item.lng) };
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"@rematch/core": "2.2.0",
|
"@rematch/core": "2.2.0",
|
||||||
"@rematch/loading": "2.1.2",
|
"@rematch/loading": "2.1.2",
|
||||||
"@rematch/persist": "2.1.2",
|
"@rematch/persist": "2.1.2",
|
||||||
|
"@verdaccio/ui-i18n": "workspace:8.0.0-next-8.10",
|
||||||
"country-flag-icons": "1.5.16",
|
"country-flag-icons": "1.5.16",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "1.11.13",
|
||||||
"dompurify": "3.2.3",
|
"dompurify": "3.2.3",
|
||||||
|
|||||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -741,6 +741,8 @@ importers:
|
|||||||
specifier: workspace:13.0.0-next-8.3
|
specifier: workspace:13.0.0-next-8.3
|
||||||
version: link:../types
|
version: link:../types
|
||||||
|
|
||||||
|
packages/core/i18n: {}
|
||||||
|
|
||||||
packages/core/tarball:
|
packages/core/tarball:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@verdaccio/core':
|
'@verdaccio/core':
|
||||||
@@ -1228,6 +1230,9 @@ importers:
|
|||||||
'@verdaccio/ui-components':
|
'@verdaccio/ui-components':
|
||||||
specifier: workspace:4.0.0-next-8.5
|
specifier: workspace:4.0.0-next-8.5
|
||||||
version: link:../../ui-components
|
version: link:../../ui-components
|
||||||
|
'@verdaccio/ui-i18n':
|
||||||
|
specifier: workspace:8.0.0-next-8.10
|
||||||
|
version: link:../../core/i18n
|
||||||
'@vitejs/plugin-react':
|
'@vitejs/plugin-react':
|
||||||
specifier: 4.3.4
|
specifier: 4.3.4
|
||||||
version: 4.3.4(vite@5.3.1(@types/node@22.10.5)(sass@1.83.4)(terser@5.31.3))
|
version: 4.3.4(vite@5.3.1(@types/node@22.10.5)(sass@1.83.4)(terser@5.31.3))
|
||||||
@@ -1932,6 +1937,9 @@ importers:
|
|||||||
'@rematch/persist':
|
'@rematch/persist':
|
||||||
specifier: 2.1.2
|
specifier: 2.1.2
|
||||||
version: 2.1.2(@rematch/core@2.2.0(redux@4.2.1))(react@18.3.1)(redux@4.2.1)
|
version: 2.1.2(@rematch/core@2.2.0(redux@4.2.1))(react@18.3.1)(redux@4.2.1)
|
||||||
|
'@verdaccio/ui-i18n':
|
||||||
|
specifier: workspace:8.0.0-next-8.10
|
||||||
|
version: link:../core/i18n
|
||||||
country-flag-icons:
|
country-flag-icons:
|
||||||
specifier: 1.5.16
|
specifier: 1.5.16
|
||||||
version: 1.5.16
|
version: 1.5.16
|
||||||
@@ -26419,7 +26427,7 @@ snapshots:
|
|||||||
|
|
||||||
i18next@20.6.1:
|
i18next@20.6.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.21.0
|
'@babel/runtime': 7.26.7
|
||||||
|
|
||||||
iconv-lite@0.4.24:
|
iconv-lite@0.4.24:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user