diff --git a/crowdin.yaml b/crowdin.yaml index 923d935da..c6a2cd3ba 100644 --- a/crowdin.yaml +++ b/crowdin.yaml @@ -13,4 +13,4 @@ files: source: '/website/docs/**/*', translation: '/website/i18n/%locale%/docusaurus-plugin-content-docs/current/**/%original_file_name%', } - ] \ No newline at end of file + ] diff --git a/packages/plugins/ui-theme/i18n/config.ts b/packages/plugins/ui-theme/i18n/config.ts deleted file mode 100644 index 7410050dc..000000000 --- a/packages/plugins/ui-theme/i18n/config.ts +++ /dev/null @@ -1,94 +0,0 @@ -import i18n from 'i18next'; -import { initReactI18next } from 'react-i18next'; - -import translationCS from './translations/cs-CZ.json'; -import translationDE from './translations/de-DE.json'; -import translationEN from './translations/en-US.json'; -import translationES from './translations/es-ES.json'; -import translationFR from './translations/fr-FR.json'; -import translationJP from './translations/ja-JP.json'; -import translationKM from './translations/km-KH.json'; -import translationPT from './translations/pt-BR.json'; -import translationRU from './translations/ru-RU.json'; -import translationTR from './translations/tr-TR.json'; -import translationUA from './translations/uk-UA.json'; -import translationCN from './translations/zh-CN.json'; -import translatiobTW from './translations/zh-TW.json'; - -const languages = { - 'en-US': { - translation: translationEN, - }, - 'cs-CZ': { - translation: translationCS, - }, - 'pt-BR': { - translation: translationPT, - }, - 'es-ES': { - translation: translationES, - }, - 'de-DE': { - translation: translationDE, - }, - 'fr-FR': { - translation: translationFR, - }, - 'zh-CN': { - translation: translationCN, - }, - 'ja-JP': { - translation: translationJP, - }, - 'ru-RU': { - translation: translationRU, - }, - 'tr-TR': { - translation: translationTR, - }, - 'uk-UA': { - translation: translationUA, - }, - 'km-KH': { - translation: translationKM, - }, - 'zh-TW': { - translation: translatiobTW, - }, -}; - -type Language = keyof typeof languages; -i18n - // pass the i18n instance to react-i18next. - .use(initReactI18next) - // init i18next - // for all options read: https://www.i18next.com/overview/configuration-options - .init({ - // in case window.VEDACCIO_LANGUAGE is undefined,it will fall back to 'en-US' - lng: window?.__VERDACCIO_BASENAME_UI_OPTIONS?.language || 'en-US', - fallbackLng: 'en-US', - whitelist: [ - 'en-US', - 'cs-CZ', - 'pt-BR', - 'es-ES', - 'de-DE', - 'fr-FR', - 'zh-CN', - 'ja-JP', - 'ru-RU', - 'tr-TR', - 'uk-UA', - 'km-KH', - 'zh-TW', - ], - load: 'currentOnly', - resources: languages, - debug: false, - interpolation: { - escapeValue: false, // react already safes from xss - }, - }); - -export default i18n; -export { Language }; diff --git a/packages/plugins/ui-theme/package.json b/packages/plugins/ui-theme/package.json index 39f87de1c..e5588ef6f 100644 --- a/packages/plugins/ui-theme/package.json +++ b/packages/plugins/ui-theme/package.json @@ -48,8 +48,9 @@ "harmony-reflect": "1.6.2", "history": "4.10.1", "html-webpack-plugin": "5.3.2", - "i18next": "20.6.0", + "i18next": "20.6.1", "in-publish": "2.0.1", + "country-flag-icons": "1.4.10", "js-base64": "3.6.1", "js-yaml": "3.14.1", "localstorage-memory": "1.0.3", @@ -66,7 +67,7 @@ "react-dom": "17.0.2", "react-hook-form": "7.14.2", "react-hot-loader": "4.13.0", - "react-i18next": "11.11.4", + "react-i18next": "11.12.0", "react-router": "5.2.1", "react-router-dom": "5.3.0", "react-virtualized": "9.22.3", diff --git a/packages/plugins/ui-theme/src/App/App.tsx b/packages/plugins/ui-theme/src/App/App.tsx index ea23e9e13..ed3e17795 100644 --- a/packages/plugins/ui-theme/src/App/App.tsx +++ b/packages/plugins/ui-theme/src/App/App.tsx @@ -17,7 +17,7 @@ import AppRoute, { history } from './AppRoute'; import Footer from './Footer'; import Header from './Header'; -import '../../i18n/config'; +import '../i18n/config'; const StyledBox = styled(Box)<{ theme?: Theme }>(({ theme }) => ({ backgroundColor: theme?.palette.background.default, diff --git a/packages/plugins/ui-theme/src/App/Footer/Footer.tsx b/packages/plugins/ui-theme/src/App/Footer/Footer.tsx index d1c81fee4..3312ed2ed 100644 --- a/packages/plugins/ui-theme/src/App/Footer/Footer.tsx +++ b/packages/plugins/ui-theme/src/App/Footer/Footer.tsx @@ -1,18 +1,11 @@ +/* eslint-disable react/jsx-max-depth */ +/* eslint-disable react/jsx-pascal-case */ import styled from '@emotion/styled'; +import FlagsIcon from 'country-flag-icons/react/3x2'; import React from 'react'; import { useTranslation, Trans } from 'react-i18next'; -import { - Austria, - Brazil, - Earth, - Nicaragua, - Spain, - Germany, - India, - China, - Taiwan, -} from 'verdaccio-ui/components/Icons'; +import { Earth } from 'verdaccio-ui/components/Icons'; import Logo from 'verdaccio-ui/components/Logo'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; import { useConfig } from 'verdaccio-ui/providers/config'; @@ -32,14 +25,30 @@ const Footer = () => { - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -87,6 +96,10 @@ const Flags = styled('span')<{ theme?: Theme }>(({ theme }) => ({ }, })); +const Icon = styled('div')({ + width: '10px', +}); + const ToolTip = styled('span')({ position: 'relative', height: '18px', diff --git a/packages/plugins/ui-theme/src/App/Footer/__snapshots__/Footer.test.tsx.snap b/packages/plugins/ui-theme/src/App/Footer/__snapshots__/Footer.test.tsx.snap index ffb6cc125..deccbf8d2 100644 --- a/packages/plugins/ui-theme/src/App/Footer/__snapshots__/Footer.test.tsx.snap +++ b/packages/plugins/ui-theme/src/App/Footer/__snapshots__/Footer.test.tsx.snap @@ -111,8 +111,7 @@ exports[`