mirror of
https://github.com/SomboChea/ui
synced 2026-01-12 22:25:52 +07:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e3c006cbd | ||
|
|
f44abd7dd0 | ||
|
|
730c3471c2 | ||
|
|
25def6ccd5 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -2,6 +2,20 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [1.7.1](https://github.com/verdaccio/ui/compare/v1.7.0...v1.7.1) (2020-04-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **i18n:** fixed current locale ([#462](https://github.com/verdaccio/ui/issues/462)) ([f44abd7](https://github.com/verdaccio/ui/commit/f44abd7dd08a8d68b1bfc2bf0c053f3e80a343d0))
|
||||
|
||||
## [1.7.0](https://github.com/verdaccio/ui/compare/v1.6.0...v1.7.0) (2020-04-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add japanese translations ([#460](https://github.com/verdaccio/ui/issues/460)) ([25def6c](https://github.com/verdaccio/ui/commit/25def6ccd5a42d43af1c33e7ace4bd7fdbec0e64))
|
||||
|
||||
## [1.6.0](https://github.com/verdaccio/ui/compare/v1.5.0...v1.6.0) (2020-04-23)
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import translationES from './translations/es-ES.json';
|
||||
import translationDE from './translations/de-DE.json';
|
||||
import translationFR from './translations/fr-FR.json';
|
||||
import translationCN from './translations/zh-CN.json';
|
||||
import translationJP from './translations/ja-JP.json';
|
||||
|
||||
const languages = {
|
||||
'en-US': {
|
||||
@@ -27,6 +28,9 @@ const languages = {
|
||||
'zh-CN': {
|
||||
translation: translationCN,
|
||||
},
|
||||
'ja-JP': {
|
||||
translation: translationJP,
|
||||
},
|
||||
};
|
||||
|
||||
type Language = keyof typeof languages;
|
||||
@@ -40,7 +44,7 @@ i18n
|
||||
// in case window.VEDACCIO_LANGUAGE is undefined,it will fall back to 'en-US'
|
||||
lng: window?.__VERDACCIO_BASENAME_UI_OPTIONS?.language,
|
||||
fallbackLng: 'en-US',
|
||||
whitelist: ['en-US', 'pt-BR', 'es-ES', 'de-DE', 'fr-FR', 'zh-CN'],
|
||||
whitelist: ['en-US', 'pt-BR', 'es-ES', 'de-DE', 'fr-FR', 'zh-CN', 'ja-JP'],
|
||||
load: 'currentOnly',
|
||||
resources: languages,
|
||||
debug: false,
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
},
|
||||
"lng": {
|
||||
"english": "Englisch",
|
||||
"japanese": "Japanisch",
|
||||
"portuguese": "Portugiesisch",
|
||||
"spanish": "Spanisch",
|
||||
"german": "Deutsch",
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
},
|
||||
"lng": {
|
||||
"english": "English",
|
||||
"japanese": "Japanese",
|
||||
"portuguese": "Portuguese",
|
||||
"spanish": "Spanish",
|
||||
"german": "German",
|
||||
@@ -146,4 +147,4 @@
|
||||
},
|
||||
"help-to-translate": "Help to translate",
|
||||
"change-language": "Change language"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
},
|
||||
"lng": {
|
||||
"english": "Inglés",
|
||||
"japanese": "Japonés",
|
||||
"portuguese": "Portugués",
|
||||
"spanish": "Español",
|
||||
"german": "Alemán",
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
},
|
||||
"lng": {
|
||||
"english": "Anglaise",
|
||||
"japanese": "Japonaise",
|
||||
"portuguese": "Portugaise",
|
||||
"spanish": "Espagnol",
|
||||
"german": "Allemande",
|
||||
@@ -146,4 +147,4 @@
|
||||
},
|
||||
"help-to-translate": "Aide à traduire",
|
||||
"change-language": "Changer la langue"
|
||||
}
|
||||
}
|
||||
|
||||
150
i18n/translations/ja-JP.json
Normal file
150
i18n/translations/ja-JP.json
Normal file
@@ -0,0 +1,150 @@
|
||||
{
|
||||
"copy-to-clipboard": "クリップボードにコピー",
|
||||
"author-anonymous": "匿名",
|
||||
"action-bar-action": {
|
||||
"visit-home-page": "ホームページへ移動",
|
||||
"open-an-issue": "課題を開く",
|
||||
"download-tarball": "tar形式でダウンロード"
|
||||
},
|
||||
"dialog": {
|
||||
"registry-info": {
|
||||
"title": "レジストリの設定方法"
|
||||
}
|
||||
},
|
||||
"header": {
|
||||
"documentation": "ドキュメント",
|
||||
"registry-info": "レジストリ情報",
|
||||
"greetings": "こんにちは、"
|
||||
},
|
||||
"search": {
|
||||
"packages": "パッケージを検索"
|
||||
},
|
||||
"auto-complete": {
|
||||
"loading": "ロード中...",
|
||||
"no-results-found": "パッケージが見つかりませんでした"
|
||||
},
|
||||
"tab": {
|
||||
"uplinks": "アップリンク",
|
||||
"versions": "バージョン情報",
|
||||
"dependencies": "依存パッケージ",
|
||||
"readme": "Readme"
|
||||
},
|
||||
"uplinks": {
|
||||
"title": "アップリンク",
|
||||
"no-items": "{{name}}にアップリンクはありません"
|
||||
},
|
||||
"versions": {
|
||||
"current-tags": "タグ一覧",
|
||||
"version-history": "バージョン履歴",
|
||||
"not-available": "利用できません"
|
||||
},
|
||||
"package": {
|
||||
"published-on": "{{time}}に更新されました •",
|
||||
"version": "v{{version}}",
|
||||
"visit-home-page": "ホームページへ移動",
|
||||
"homepage": "ホームページ",
|
||||
"open-an-issue": "課題を開く",
|
||||
"bugs": "バグ",
|
||||
"download": "{{what}}ダウンロード",
|
||||
"the-tar-file": "tar形式のファイル",
|
||||
"tarball": "tar形式でダウンロード"
|
||||
},
|
||||
"dependencies": {
|
||||
"has-no-dependencies": "{{package}}に依存パッケージはありません",
|
||||
"dependency-block": "{{package}}@{{version}}"
|
||||
},
|
||||
"form": {
|
||||
"username": "ユーザ名",
|
||||
"password": "パスワード"
|
||||
},
|
||||
"form-placeholder": {
|
||||
"username": "あなたのユーザ名",
|
||||
"password": "あなたのパスワード"
|
||||
},
|
||||
"form-validation": {
|
||||
"required-field": "この項目は必ず入力して下さい",
|
||||
"required-min-length": "この項目は{{length}}文字以上入力して下さい",
|
||||
"unable-to-sign-in": "サインインできません",
|
||||
"username-or-password-cant-be-empty": "ユーザ名とパスワードは空にできません"
|
||||
},
|
||||
"help": {
|
||||
"title": "まだパッケージが登録されていません",
|
||||
"sub-title": "以下の手順で最初のパッケージを登録しましょう",
|
||||
"first-step": "1. ログイン",
|
||||
"first-step-command-line": "npm adduser --registry {{registryUrl}}",
|
||||
"second-step": "2. 登録",
|
||||
"second-step-command-line": "npm publish --registry {{registryUrl}}",
|
||||
"third-step": "3. このページを再読み込みして下さい"
|
||||
},
|
||||
"sidebar": {
|
||||
"detail": {
|
||||
"latest-version": "最新バージョンは{{version}}です",
|
||||
"version": "v{{version}}"
|
||||
},
|
||||
"installation": {
|
||||
"title": "インストール方法",
|
||||
"install-using-yarn": "yarnでインストール",
|
||||
"install-using-yarn-command": "yarn add {{packageName}}",
|
||||
"install-using-npm": "npmでインストール",
|
||||
"install-using-npm-command": "npm install {{packageName}}",
|
||||
"install-using-pnpm": "pnpmでインストール",
|
||||
"install-using-pnpm-command": "pnpm install {{packageName}}"
|
||||
},
|
||||
"repository": {
|
||||
"title": "リポジトリ"
|
||||
},
|
||||
"author": {
|
||||
"title": "作者"
|
||||
},
|
||||
"distribution": {
|
||||
"title": "最新の配信内容",
|
||||
"license": "ライセンス",
|
||||
"size": "サイズ",
|
||||
"file-count": "ファイル数"
|
||||
},
|
||||
"maintainers": {
|
||||
"title": "パッケージメンテナ"
|
||||
},
|
||||
"contributors": {
|
||||
"title": "コントリビューター"
|
||||
},
|
||||
"engines": {
|
||||
"npm-version": "NPM Version",
|
||||
"node-js": "NODE JS"
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"powered-by": "Powered by",
|
||||
"made-with-love-on": "Made with <0>♥</0> on"
|
||||
},
|
||||
"button": {
|
||||
"close": "閉じる",
|
||||
"cancel": "キャンセル",
|
||||
"login": "ログイン",
|
||||
"logout": "ログアウト",
|
||||
"go-to-the-home-page": "トップページに戻る",
|
||||
"learn-more": "もっと知る",
|
||||
"fund-this-package": "このパッケージに<0>投資</0>"
|
||||
},
|
||||
"error": {
|
||||
"unspecific": "何か問題が発生したようです。",
|
||||
"404": {
|
||||
"page-not-found": "404 - Page not found",
|
||||
"sorry-we-could-not-find-it": "残念ながら、ご指定のページはありませんでした…。"
|
||||
},
|
||||
"app-context-not-correct-used": "AppContextが正しく使用されませんでした",
|
||||
"theme-context-not-correct-used": "ThemeContextが正しく使用されませんでした",
|
||||
"package-meta-is-required-at-detail-context": "DetailContextではpackageMetaが必要です"
|
||||
},
|
||||
"lng": {
|
||||
"english": "英語",
|
||||
"japanese": "日本語",
|
||||
"portuguese": "ポルトガル語",
|
||||
"spanish": "スペイン語",
|
||||
"german": "ドイツ語",
|
||||
"chinese": "中国語",
|
||||
"french": "フランス語"
|
||||
},
|
||||
"help-to-translate": "翻訳を助ける",
|
||||
"change-language": "言語を変更"
|
||||
}
|
||||
@@ -138,6 +138,7 @@
|
||||
},
|
||||
"lng": {
|
||||
"english": "Inglês",
|
||||
"japanese": "Japonês",
|
||||
"portuguese": "Português",
|
||||
"spanish": "Espanhol",
|
||||
"german": "Alemão",
|
||||
@@ -146,4 +147,4 @@
|
||||
},
|
||||
"help-to-translate": "Ajude a traduzir",
|
||||
"change-language": "Mudar idioma"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
},
|
||||
"lng": {
|
||||
"english": "英語",
|
||||
"japanese": "日語",
|
||||
"portuguese": "葡萄牙語",
|
||||
"spanish": "西班牙文",
|
||||
"german": "德語",
|
||||
@@ -145,4 +146,4 @@
|
||||
},
|
||||
"help-to-translate": "幫助翻譯",
|
||||
"change-language": "改變語言"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/ui-theme",
|
||||
"version": "1.6.0",
|
||||
"version": "1.7.1",
|
||||
"description": "Verdaccio User Interface",
|
||||
"author": {
|
||||
"name": "Verdaccio Core Team",
|
||||
|
||||
@@ -55,6 +55,12 @@ function loadDayJSLocale() {
|
||||
dayjs.locale('zh-cn');
|
||||
}
|
||||
break;
|
||||
case 'ja-jp':
|
||||
{
|
||||
require('dayjs/locale/ja');
|
||||
dayjs.locale('ja');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import austria from './img/austria.svg';
|
||||
import spain from './img/spain.svg';
|
||||
import usa from './img/usa.svg';
|
||||
import france from './img/france.svg';
|
||||
import japan from './img/japan.svg';
|
||||
import earth from './img/earth.svg';
|
||||
import verdaccio from './img/verdaccio.svg';
|
||||
import filebinary from './img/filebinary.svg';
|
||||
@@ -32,6 +33,7 @@ export interface IconsMap {
|
||||
france: string;
|
||||
germany: string;
|
||||
india: string;
|
||||
japan: string;
|
||||
earth: string;
|
||||
verdaccio: string;
|
||||
license: string;
|
||||
@@ -60,6 +62,7 @@ export const Icons: IconsMap = {
|
||||
germany,
|
||||
usa,
|
||||
france,
|
||||
japan,
|
||||
};
|
||||
|
||||
export interface Props {
|
||||
|
||||
1
src/components/Icon/img/japan.svg
Normal file
1
src/components/Icon/img/japan.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" id="japan"><path d="M473.655 88.275H38.345C17.167 88.275 0 105.442 0 126.62v258.76c0 21.177 17.167 38.345 38.345 38.345h435.31c21.177 0 38.345-17.167 38.345-38.345V126.62c0-21.178-17.167-38.345-38.345-38.345z" fill="#f5f5f5"/><circle cx="256" cy="255.999" r="97.1" fill="#ff4b55"/></svg>
|
||||
|
After Width: | Height: | Size: 350 B |
@@ -9,7 +9,6 @@ import Grow from '@material-ui/core/Grow';
|
||||
import Popper from '@material-ui/core/Popper';
|
||||
import MenuList from '@material-ui/core/MenuList';
|
||||
import styled from '@emotion/styled';
|
||||
import { css } from '@emotion/core';
|
||||
|
||||
import { Language } from '../../../i18n/config';
|
||||
import ThemeContext from '../../design-tokens/ThemeContext';
|
||||
@@ -25,34 +24,48 @@ import Icon from '../Icon';
|
||||
|
||||
const VERDACCIO_UI_GITHUB_REPOSITORY = 'https://github.com/verdaccio/ui';
|
||||
|
||||
const getTranslatedCurrentLanguage = (
|
||||
t: TFunction
|
||||
): { [key: string]: { translation: string; icon: React.ComponentProps<typeof Icon>['name'] } } => ({
|
||||
'en-us': {
|
||||
translation: t('lng.english'),
|
||||
icon: 'usa',
|
||||
},
|
||||
'fr-fr': {
|
||||
translation: t('lng.french'),
|
||||
icon: 'france',
|
||||
},
|
||||
'pt-br': {
|
||||
translation: t('lng.portuguese'),
|
||||
icon: 'brazil',
|
||||
},
|
||||
'de-de': {
|
||||
translation: t('lng.german'),
|
||||
icon: 'germany',
|
||||
},
|
||||
'es-es': {
|
||||
translation: t('lng.spanish'),
|
||||
icon: 'spain',
|
||||
},
|
||||
'zh-cn': {
|
||||
translation: t('lng.chinese'),
|
||||
icon: 'china',
|
||||
},
|
||||
});
|
||||
const getTranslatedCurrentLanguageDetails = (
|
||||
t: TFunction,
|
||||
currentLanguage: string
|
||||
): { translation: string; icon: React.ComponentProps<typeof Icon>['name'] } => {
|
||||
switch (currentLanguage) {
|
||||
case 'fr-FR':
|
||||
return {
|
||||
translation: t('lng.french'),
|
||||
icon: 'france',
|
||||
};
|
||||
case 'pt-BR':
|
||||
return {
|
||||
translation: t('lng.portuguese'),
|
||||
icon: 'brazil',
|
||||
};
|
||||
case 'de-DE':
|
||||
return {
|
||||
translation: t('lng.german'),
|
||||
icon: 'germany',
|
||||
};
|
||||
case 'es-ES':
|
||||
return {
|
||||
translation: t('lng.spanish'),
|
||||
icon: 'spain',
|
||||
};
|
||||
case 'zh-CN':
|
||||
return {
|
||||
translation: t('lng.chinese'),
|
||||
icon: 'china',
|
||||
};
|
||||
case 'ja-JP':
|
||||
return {
|
||||
translation: t('lng.japanese'),
|
||||
icon: 'japan',
|
||||
};
|
||||
default:
|
||||
return {
|
||||
translation: t('lng.english'),
|
||||
icon: 'usa',
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const LanguageSwitch = () => {
|
||||
const themeContext = useContext(ThemeContext);
|
||||
@@ -65,9 +78,9 @@ const LanguageSwitch = () => {
|
||||
}
|
||||
|
||||
const languages = (i18next.options.resources ? Object.keys(i18next.options.resources) : []) as Array<Language>;
|
||||
const currentLanguage: Language = i18next.language || i18next.options?.fallbackLng?.[0];
|
||||
const currentLanguage = themeContext.language;
|
||||
|
||||
const { translation: userLanguage } = getTranslatedCurrentLanguage(t)[currentLanguage.toLowerCase()];
|
||||
const { translation: userLanguage } = getTranslatedCurrentLanguageDetails(t, currentLanguage);
|
||||
|
||||
const handleToggle = useCallback(() => {
|
||||
setOpen(prevOpen => !prevOpen);
|
||||
@@ -124,7 +137,7 @@ const LanguageSwitch = () => {
|
||||
{languages
|
||||
.filter(language => language !== currentLanguage)
|
||||
.map(language => {
|
||||
const { icon, translation } = getTranslatedCurrentLanguage(t)[language.toLowerCase()];
|
||||
const { icon, translation } = getTranslatedCurrentLanguageDetails(t, language);
|
||||
return (
|
||||
<StyledMenuItem
|
||||
key={language}
|
||||
|
||||
@@ -3,15 +3,13 @@ import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles';
|
||||
import { ThemeProvider as EmotionThemeProvider } from 'emotion-theming';
|
||||
import i18next from 'i18next';
|
||||
|
||||
import { Language } from '../../i18n/config';
|
||||
|
||||
import ThemeContext from './ThemeContext';
|
||||
import { getTheme, ThemeMode } from './theme';
|
||||
import useLocalStorage from './useLocalStorage';
|
||||
|
||||
const ThemeProvider: React.FC = ({ children }) => {
|
||||
const isDarkModeDefault = window?.__VERDACCIO_BASENAME_UI_OPTIONS?.darkMode;
|
||||
const currentLanguage: Language = i18next.language || i18next.options?.fallbackLng?.[0];
|
||||
const currentLanguage = i18next.languages?.[0];
|
||||
|
||||
const [isDarkMode, setIsDarkMode] = useLocalStorage('darkMode', !!isDarkModeDefault);
|
||||
const [language, setLanguage] = useLocalStorage('language', currentLanguage);
|
||||
|
||||
Reference in New Issue
Block a user