mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: using ui translations from crowdin (#2442)
* refactor: using ui translations from crowdin * move tasks * fix tests
This commit is contained in:
parent
531289f59d
commit
8d6d6097c6
21 changed files with 45 additions and 5 deletions
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
@ -83,6 +83,7 @@ jobs:
|
||||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: pnpm format:check
|
run: pnpm format:check
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: build
|
name: build
|
||||||
|
@ -101,6 +102,12 @@ jobs:
|
||||||
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||||
- name: Install
|
- name: Install
|
||||||
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
run: pnpm recursive install --frozen-lockfile --ignore-scripts
|
||||||
|
- name: crowdin download
|
||||||
|
env:
|
||||||
|
CROWDIN_VERDACCIO_PROJECT_ID: ${{ secrets.CROWDIN_VERDACCIO_PROJECT_ID }}
|
||||||
|
CROWDIN_VERDACCIO_API_KEY: ${{ secrets.CROWDIN_VERDACCIO_API_KEY }}
|
||||||
|
CONTEXT: production
|
||||||
|
run: pnpm crowdin:download
|
||||||
- name: build
|
- name: build
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
- name: tar packages
|
- name: tar packages
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -36,6 +36,8 @@ packages/standalone/dist/
|
||||||
packages/plugins/ui-theme/static
|
packages/plugins/ui-theme/static
|
||||||
/packages/plugins/ui-theme/src/i18n/crowdin/*
|
/packages/plugins/ui-theme/src/i18n/crowdin/*
|
||||||
!/packages/plugins/ui-theme/src/i18n/crowdin/en-US.json
|
!/packages/plugins/ui-theme/src/i18n/crowdin/en-US.json
|
||||||
|
!/packages/plugins/ui-theme/src/i18n/crowdin/*.md
|
||||||
|
|
||||||
|
|
||||||
# CI Pnpm cache
|
# CI Pnpm cache
|
||||||
.pnpm-store/
|
.pnpm-store/
|
||||||
|
|
|
@ -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/translations/en-US.json';
|
import translationEN from '../../i18n/crowdin/en-US.json';
|
||||||
|
|
||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,27 @@ import {
|
||||||
listLanguagesAsString,
|
listLanguagesAsString,
|
||||||
} from './enabledLanguages';
|
} from './enabledLanguages';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In development mode translations files might be not available,
|
||||||
|
* crowdin translations are only available in CI.
|
||||||
|
*/
|
||||||
|
function loadTranslationFile(lng) {
|
||||||
|
try {
|
||||||
|
return require(`./crowdin/${lng}/en-US.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`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const languages = listLanguages.reduce((acc, item: LanguageConfiguration) => {
|
const languages = listLanguages.reduce((acc, item: LanguageConfiguration) => {
|
||||||
acc[item.lng] = {
|
acc[item.lng] = {
|
||||||
translation: require(`./translations/${item.lng}.json`),
|
translation:
|
||||||
|
item.lng === DEFAULT_LANGUAGE
|
||||||
|
? require(`./crowdin/en-US.json`)
|
||||||
|
: loadTranslationFile(item.lng),
|
||||||
};
|
};
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
## 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`.
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
- Need a crowdin account, use your GitHub account for fast access as an option.
|
||||||
|
|
||||||
|
### Adding a new language to the UI
|
||||||
|
|
||||||
|
- 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`.
|
|
@ -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/translations/en-US.json';
|
import translationEN from '../../../../i18n/crowdin/en-US.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/translations/en-US.json';
|
import translationEN from '../../i18n/crowdin/en-US.json';
|
||||||
|
|
||||||
import data from './__partials__/data.json';
|
import data from './__partials__/data.json';
|
||||||
import { DetailContext } from './context';
|
import { DetailContext } from './context';
|
||||||
|
|
|
@ -133,7 +133,7 @@ exports[`<Help /> component should load the component in default state 1`] = `
|
||||||
<span
|
<span
|
||||||
class="MuiTypography-root MuiTypography-body2"
|
class="MuiTypography-root MuiTypography-body2"
|
||||||
>
|
>
|
||||||
3. Refresh this page.
|
3. Refresh this page
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Reference in a new issue