1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-24 21:15:51 +01:00

rename translation file (#2445)

avoid ui translations are being uploaded
This commit is contained in:
Juan Picado 2021-09-18 12:45:27 +02:00 committed by GitHub
parent 7af1e6cc84
commit 90818700a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 17 deletions

5
.gitignore vendored

@ -34,9 +34,8 @@ packages/standalone/dist/
## ui ## ui
packages/plugins/ui-theme/static packages/plugins/ui-theme/static
/packages/plugins/ui-theme/src/i18n/crowdin/* /packages/plugins/ui-theme/src/i18n/download_translations/
!/packages/plugins/ui-theme/src/i18n/crowdin/en-US.json !/packages/plugins/ui-theme/src/i18n/crowdin/ui.json
!/packages/plugins/ui-theme/src/i18n/crowdin/*.md
# CI Pnpm cache # 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: 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. 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**. 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/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). 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`. 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`. 5. For local testing, read `packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md`.
6. Add a `changeset` file, see more info below. 6. Add a `changeset` file, see more info below.

@ -7,7 +7,7 @@ files:
[ [
{ {
source: 'packages/plugins/ui-theme/src/i18n/crowdin/**/*', 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/**/*', source: '/website/i18n/en/**/*',

@ -10,7 +10,7 @@ import {
} from 'verdaccio-ui/utils/test-react-testing-library'; } from 'verdaccio-ui/utils/test-react-testing-library';
import { AppContextProvider } from '../../App'; import { AppContextProvider } from '../../App';
import translationEN from '../../i18n/crowdin/en-US.json'; import translationEN from '../../i18n/crowdin/ui.json';
import Header from './Header'; import Header from './Header';

@ -1,6 +1,6 @@
## Translate UI Strings ## 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 ### 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. - 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. - 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) { function loadTranslationFile(lng) {
try { try {
return require(`./crowdin/${lng}/en-US.json`); return require(`./download_translations/${lng}/ui.json`);
} catch { } catch {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(`language ${lng} file not found, fallback to en-US`); console.error(`language ${lng} file not found, fallback to en-US`);
// in case the file is not there, 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) => { const languages = listLanguages.reduce((acc, item: LanguageConfiguration) => {
acc[item.lng] = { acc[item.lng] = {
translation: translation:
item.lng === DEFAULT_LANGUAGE item.lng === DEFAULT_LANGUAGE ? require(`./crowdin/ui.json`) : loadTranslationFile(item.lng),
? require(`./crowdin/en-US.json`)
: loadTranslationFile(item.lng),
}; };
return acc; return acc;
}, {}); }, {});

@ -3,7 +3,7 @@ import { MemoryRouter } from 'react-router-dom';
import { render, cleanup } from 'verdaccio-ui/utils/test-react-testing-library'; 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 { DetailContext } from '../../context';
import { DetailContextProps } from '../../version-config'; 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 { 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 data from './__partials__/data.json';
import { DetailContext } from './context'; import { DetailContext } from './context';

@ -17,7 +17,7 @@ jest.mock('verdaccio-ui/providers/API/api', () => ({
})); }));
jest.mock('i18next', () => { jest.mock('i18next', () => {
const translationEN = require('../../i18n/translations/en-US.json'); const translationEN = require('../../i18n/translations/ui.json');
return { return {
t: (key: string) => { t: (key: string) => {
const splittedKey = key.split('.'); const splittedKey = key.split('.');