mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
rename translation file (#2445)
avoid ui translations are being uploaded
This commit is contained in:
parent
7af1e6cc84
commit
90818700a3
10 changed files with 14 additions and 17 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -34,9 +34,8 @@ packages/standalone/dist/
|
|||
|
||||
## ui
|
||||
packages/plugins/ui-theme/static
|
||||
/packages/plugins/ui-theme/src/i18n/crowdin/*
|
||||
!/packages/plugins/ui-theme/src/i18n/crowdin/en-US.json
|
||||
!/packages/plugins/ui-theme/src/i18n/crowdin/*.md
|
||||
/packages/plugins/ui-theme/src/i18n/download_translations/
|
||||
!/packages/plugins/ui-theme/src/i18n/crowdin/ui.json
|
||||
|
||||
|
||||
# CI Pnpm cache
|
||||
|
|
|
@ -207,8 +207,8 @@ If a language is not listed, ask for it in the [Discord](https://discord.gg/7qWJ
|
|||
For adding a new **language** on the UI follow these steps:
|
||||
|
||||
1. Ensure the **language** has been enabled, must be visible in the `crowdin` platform.
|
||||
2. Find in the explorer the file `en.US.json` in the path `packages/plugins/ui-theme/src/i18n/crowdin/en-US.json` and complete the translations, **not need to find approval on this**.
|
||||
3. Into the project, add a new field into `packages/plugins/ui-theme/src/i18n/crowdin/en-US.json` file, in the section `lng`, the new language, eg: `{ lng: {korean:"Korean"}}`. (This file is English based, once the PR has been merged, this string will be available in crowdin for translate to the targeted language).
|
||||
2. Find in the explorer the file `en.US.json` in the path `packages/plugins/ui-theme/src/i18n/crowdin/ui.json` and complete the translations, **not need to find approval on this**.
|
||||
3. Into the project, add a new field into `packages/plugins/ui-theme/src/i18n/crowdin/ui.json` file, in the section `lng`, the new language, eg: `{ lng: {korean:"Korean"}}`. (This file is English based, once the PR has been merged, this string will be available in crowdin for translate to the targeted language).
|
||||
4. Add the language, [flag icon](https://www.npmjs.com/package/country-flag-icons), and the menu key fort he new language eg: `menuKey: 'lng.korean'` to the file `packages/plugins/ui-theme/src/i18n/enabledLanguages.ts`.
|
||||
5. For local testing, read `packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md`.
|
||||
6. Add a `changeset` file, see more info below.
|
||||
|
|
|
@ -7,7 +7,7 @@ files:
|
|||
[
|
||||
{
|
||||
source: 'packages/plugins/ui-theme/src/i18n/crowdin/**/*',
|
||||
translation: '/packages/plugins/ui-theme/src/i18n/crowdin/%locale%/**/%original_file_name%',
|
||||
translation: '/packages/plugins/ui-theme/src/i18n/download_translations/%locale%/**/%original_file_name%',
|
||||
},
|
||||
{
|
||||
source: '/website/i18n/en/**/*',
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
} from 'verdaccio-ui/utils/test-react-testing-library';
|
||||
|
||||
import { AppContextProvider } from '../../App';
|
||||
import translationEN from '../../i18n/crowdin/en-US.json';
|
||||
import translationEN from '../../i18n/crowdin/ui.json';
|
||||
|
||||
import Header from './Header';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## Translate UI Strings
|
||||
|
||||
If you are willing to translate User Interfances strings, are located in the `crowdin` project which is available [here](https://crowdin.com/project/verdaccio) at `packages/plugins/src/i18n/crowdin/en-US.json`.
|
||||
If you are willing to translate User Interfances strings, are located in the `crowdin` project which is available [here](https://crowdin.com/project/verdaccio) at `packages/plugins/src/i18n/crowdin/ui.json`.
|
||||
|
||||
### Requirements
|
||||
|
||||
|
@ -10,4 +10,4 @@ If you are willing to translate User Interfances strings, are located in the `cr
|
|||
|
||||
- If the language is not available, ask in the Discord channel to enable it, that will be pretty fast.
|
||||
- After you have translated the strings, add to `packages/plugins/ui-theme/src/i18n/enabledLanguages.ts` the configuration for the new language.
|
||||
- In development mode the file must not be available since you need admin credentials to download translations, as a work around, create a folder withing the `crowdin` folder eg: `/packages/plugins/ui-theme/src/i18n/crowdin/fr-FR/en-US.json` and then will be available for testing. If the language is not found, will fallback to `en-US`.
|
||||
- In development mode the file must not be available since you need admin credentials to download translations, as a work around, create a folder withing the `crowdin` folder eg: `/packages/plugins/ui-theme/src/i18n/download_translations/fr-FR/ui.json` and then will be available for testing. If the language is not found, will fallback to `en-US`.
|
||||
|
|
|
@ -14,21 +14,19 @@ import {
|
|||
*/
|
||||
function loadTranslationFile(lng) {
|
||||
try {
|
||||
return require(`./crowdin/${lng}/en-US.json`);
|
||||
return require(`./download_translations/${lng}/ui.json`);
|
||||
} catch {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`language ${lng} file not found, fallback to en-US`);
|
||||
// in case the file is not there, fallback to en-US
|
||||
return require(`./crowdin/en-US.json`);
|
||||
return require(`./crowdin/ui.json`);
|
||||
}
|
||||
}
|
||||
|
||||
const languages = listLanguages.reduce((acc, item: LanguageConfiguration) => {
|
||||
acc[item.lng] = {
|
||||
translation:
|
||||
item.lng === DEFAULT_LANGUAGE
|
||||
? require(`./crowdin/en-US.json`)
|
||||
: loadTranslationFile(item.lng),
|
||||
item.lng === DEFAULT_LANGUAGE ? require(`./crowdin/ui.json`) : loadTranslationFile(item.lng),
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
|
|
@ -3,7 +3,7 @@ import { MemoryRouter } from 'react-router-dom';
|
|||
|
||||
import { render, cleanup } from 'verdaccio-ui/utils/test-react-testing-library';
|
||||
|
||||
import translationEN from '../../../../i18n/crowdin/en-US.json';
|
||||
import translationEN from '../../../../i18n/crowdin/ui.json';
|
||||
import { DetailContext } from '../../context';
|
||||
import { DetailContextProps } from '../../version-config';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { MemoryRouter } from 'react-router';
|
|||
|
||||
import { render } from 'verdaccio-ui/utils/test-react-testing-library';
|
||||
|
||||
import translationEN from '../../i18n/crowdin/en-US.json';
|
||||
import translationEN from '../../i18n/crowdin/ui.json';
|
||||
|
||||
import data from './__partials__/data.json';
|
||||
import { DetailContext } from './context';
|
||||
|
|
|
@ -17,7 +17,7 @@ jest.mock('verdaccio-ui/providers/API/api', () => ({
|
|||
}));
|
||||
|
||||
jest.mock('i18next', () => {
|
||||
const translationEN = require('../../i18n/translations/en-US.json');
|
||||
const translationEN = require('../../i18n/translations/ui.json');
|
||||
return {
|
||||
t: (key: string) => {
|
||||
const splittedKey = key.split('.');
|
||||
|
|
Loading…
Reference in a new issue