diff --git a/.gitignore b/.gitignore index faf68fe8a..dda40d9ab 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf906acfc..83618c728 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/crowdin.yaml b/crowdin.yaml index c2d5a6fc6..b1f6f0ddd 100644 --- a/crowdin.yaml +++ b/crowdin.yaml @@ -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/**/*', diff --git a/packages/plugins/ui-theme/src/App/Header/Header.test.tsx b/packages/plugins/ui-theme/src/App/Header/Header.test.tsx index 6b5e15ab6..cdfd44f9e 100644 --- a/packages/plugins/ui-theme/src/App/Header/Header.test.tsx +++ b/packages/plugins/ui-theme/src/App/Header/Header.test.tsx @@ -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'; diff --git a/packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md b/packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md index e251a9949..13e08fed5 100644 --- a/packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md +++ b/packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md @@ -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`. diff --git a/packages/plugins/ui-theme/src/i18n/config.ts b/packages/plugins/ui-theme/src/i18n/config.ts index 1201d84b0..ba5cc18a5 100644 --- a/packages/plugins/ui-theme/src/i18n/config.ts +++ b/packages/plugins/ui-theme/src/i18n/config.ts @@ -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; }, {}); diff --git a/packages/plugins/ui-theme/src/i18n/crowdin/en-US.json b/packages/plugins/ui-theme/src/i18n/crowdin/ui.json similarity index 100% rename from packages/plugins/ui-theme/src/i18n/crowdin/en-US.json rename to packages/plugins/ui-theme/src/i18n/crowdin/ui.json diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/Versions.test.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/Versions.test.tsx index b109bbf17..8c3bb9ef7 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/Versions.test.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/Versions.test.tsx @@ -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'; diff --git a/packages/plugins/ui-theme/src/pages/Version/Version.test.tsx b/packages/plugins/ui-theme/src/pages/Version/Version.test.tsx index 04b5e8def..b49defb26 100644 --- a/packages/plugins/ui-theme/src/pages/Version/Version.test.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/Version.test.tsx @@ -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'; diff --git a/packages/plugins/ui-theme/src/utils/login.test.ts b/packages/plugins/ui-theme/src/utils/login.test.ts index 9c129f04b..6906dc03a 100644 --- a/packages/plugins/ui-theme/src/utils/login.test.ts +++ b/packages/plugins/ui-theme/src/utils/login.test.ts @@ -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('.');