From 4d757ccf667510e6645b9d62a5ea77bb479cde16 Mon Sep 17 00:00:00 2001 From: Manuel Ruwe Date: Wed, 24 Aug 2022 17:58:14 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20language=20switch,=20add=20ge?= =?UTF-8?q?rman?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next-i18next.config.js | 1 + public/imgs/flags/de.png | Bin 0 -> 151 bytes public/imgs/flags/en.png | Bin 0 -> 1669 bytes public/locales/de/common.json | 385 +----------------- .../de/layout/add-service-app-shelf.json | 118 ++++++ public/locales/de/layout/app-shelf-menu.json | 18 + public/locales/de/layout/app-shelf.json | 10 + .../de/modules/common-media-cards-module.json | 6 + public/locales/de/modules/dashdot-module.json | 32 ++ public/locales/de/modules/docker-module.json | 65 +++ .../locales/de/modules/downloads-module.json | 23 ++ .../locales/de/modules/overseerr-module.json | 26 ++ public/locales/de/modules/ping-module.json | 7 + public/locales/de/modules/search-module.json | 5 + public/locales/de/modules/weather-module.json | 20 + public/locales/de/settings/common.json | 14 + .../de/settings/customization/app-width.json | 3 + .../customization/color-selector.json | 3 + .../customization/opacity-selector.json | 3 + .../customization/page-appearance.json | 21 + .../customization/shade-selector.json | 3 + .../de/settings/general/color-schema.json | 3 + .../de/settings/general/config-changer.json | 34 ++ .../general/internationalization.json | 3 + .../de/settings/general/module-enabler.json | 3 + .../de/settings/general/search-engine.json | 11 + .../de/settings/general/theme-selector.json | 3 + .../de/settings/general/widget-positions.json | 3 + public/locales/en/common.json | 3 +- public/locales/en/layout/app-shelf-menu.json | 18 + .../locales/en/modules/downloads-module.json | 6 + public/locales/en/settings/common.json | 3 + .../en/settings/customization/app-width.json | 3 + .../customization/page-appearance.json | 3 + .../en/settings/general/config-changer.json | 3 +- src/components/AppShelf/AppShelfMenu.tsx | 15 +- .../Settings/AppCardWidthSelector.tsx | 4 +- src/components/Settings/CommonSettings.tsx | 7 +- src/components/Settings/LanguageSwitch.tsx | 74 ++-- src/components/layout/Tip.tsx | 6 +- src/languages/language.ts | 27 ++ src/modules/downloads/DownloadsModule.tsx | 4 +- .../downloads/TotalDownloadsModule.tsx | 6 +- src/pages/index.tsx | 2 + 44 files changed, 578 insertions(+), 429 deletions(-) create mode 100644 public/imgs/flags/de.png create mode 100644 public/imgs/flags/en.png create mode 100644 public/locales/de/layout/add-service-app-shelf.json create mode 100644 public/locales/de/layout/app-shelf-menu.json create mode 100644 public/locales/de/layout/app-shelf.json create mode 100644 public/locales/de/modules/common-media-cards-module.json create mode 100644 public/locales/de/modules/dashdot-module.json create mode 100644 public/locales/de/modules/docker-module.json create mode 100644 public/locales/de/modules/downloads-module.json create mode 100644 public/locales/de/modules/overseerr-module.json create mode 100644 public/locales/de/modules/ping-module.json create mode 100644 public/locales/de/modules/search-module.json create mode 100644 public/locales/de/modules/weather-module.json create mode 100644 public/locales/de/settings/common.json create mode 100644 public/locales/de/settings/customization/app-width.json create mode 100644 public/locales/de/settings/customization/color-selector.json create mode 100644 public/locales/de/settings/customization/opacity-selector.json create mode 100644 public/locales/de/settings/customization/page-appearance.json create mode 100644 public/locales/de/settings/customization/shade-selector.json create mode 100644 public/locales/de/settings/general/color-schema.json create mode 100644 public/locales/de/settings/general/config-changer.json create mode 100644 public/locales/de/settings/general/internationalization.json create mode 100644 public/locales/de/settings/general/module-enabler.json create mode 100644 public/locales/de/settings/general/search-engine.json create mode 100644 public/locales/de/settings/general/theme-selector.json create mode 100644 public/locales/de/settings/general/widget-positions.json create mode 100644 public/locales/en/layout/app-shelf-menu.json create mode 100644 public/locales/en/settings/customization/app-width.json create mode 100644 src/languages/language.ts diff --git a/next-i18next.config.js b/next-i18next.config.js index 875c03fc8..ae76b4355 100644 --- a/next-i18next.config.js +++ b/next-i18next.config.js @@ -4,6 +4,7 @@ module.exports = { i18n: { defaultLocale: 'en', locales: ['en', 'de'], + localeDetection: true, }, reloadOnPrerender: process.env.NODE_ENV === 'development', }; diff --git a/public/imgs/flags/de.png b/public/imgs/flags/de.png new file mode 100644 index 0000000000000000000000000000000000000000..c62776bf39ed351d09c30dc78cff64640fa4623c GIT binary patch literal 151 zcmeAS@N?(olHy`uVBq!ia0y~yU~~Yo4=^zUNe;`PP$0z_;1l9{7sy~>_F3N*lRBg&=BEjb%Ik8!b~9DG0$eANoe$N YiU;Ywl}mMuvID8`boFyt=akR{0FK!w1poj5 literal 0 HcmV?d00001 diff --git a/public/imgs/flags/en.png b/public/imgs/flags/en.png new file mode 100644 index 0000000000000000000000000000000000000000..e6a6dc8be17ee629fe2d9db0af7e46142072b06b GIT binary patch literal 1669 zcmZXVeN@u-9>;&EnOa`WOx(>{BxU0L+O5+z9}H1?cV#CWgAR4&C=yR|sLjC-H5L7(!6irAv3uoMz4S558bs ze;Spj)oOixQrh=mPLlJgtGXs8WTim*m( z3ETSjYMJ<0&($)h=7Cefx)J-!RhecPx}#8;129W~17Jopcbx38Q(IGKcfqQDrd200 zL{6kn29&UhuMbIy-(fp?lij&SHKw;0t&i4pK%I_aG0kLU4pCsa5AC>n{>6KtRUW&t zl77F?d9S;dSK;F$J|12)?;v@@rP;8i&78*bN`&E%JFU4fn@Wvy zC=pL?^xF?M!E9@%uG6qh9!*INXAT@_4uqnB50zEX?`TtHwDV1kE|TGxHbGUW6cYF` z!b(xk6G#vJ7uKExZJ<_JU@nrovxbFx$pm-r4Zj`NxeQynhVzE3j~=|R;10; z7w(c-r;?aqQU5NBL`h+)M{Y&rY$Jc4lG+t%b#_2}rVsk+R=&f2Q3P}dmLthb#?#yR zyAlpu9L%PC9uQwu+hQXx35k1aDgP)$=M8Lv!ElRACT~w3$to84`wcigQe2pJtaBL< zB19zXvu=kE4H76@13n-HjXUHBM*2T~t(v-D<&U_V=m+@vMQAh4^r&JwX8toCR)IB5;>ZHF*Zc@I;3&o*0CgIZ)RmN zqB4{siXEhD)yR4t9E|Z!rBJr9)ibF33A)@M=fa!Vj zSqN4I=5`mI@?oe0pkxpsf+kz{Tn@C7PYeBJx=cOU2KKm0T=8qMJzRXGMDc{bcN?f; z@}eswyFa|f@oQOQ-9i=FE{Oy9cd)|SJ-;QepZB2Z+k|6*Iq+ELIZI!3;Z?kMhT{H8 zeo}JHTx*>lY5tk>*`H}$sB)AD4#`hrMt<{X9^}tradj6(JR)d6Hp!8i4vA&C50Lp_ zR*DV&oZT~}!HZ$Sxwp}q*%WxM0yB~W_%*V^4ThrZ4vxputD5hZpw^Y(Tq+~8T56ES z!D%{=wT^$;%~ZeNV*i?sRT>^Qly82o47JGoYh{c5s!R$A?_x(HtrOna$XOc;3vP#h z(H6ytZGLhRH0G&sNRneT+)ijaTh2 zj@s})3df??oCJdgM4RcTJ;nMt`LKN>jP&rj)bvWWnTk)nxnP;_gLBea{52dYqzrY=BUGvu092wbo704x3VtwBBSr5#uXWvtW~AHT zD+T!Va7s`$9(*%xnQ-Wy!d85mzGD?FDCG3Kjb)d&K3?ojP4nea2QIL2S=4*4a@v{c zQ`@&Ih6(-^5r*!N&3C_ua`?^JwPBJ6)8%+l~bzWl8-+Dc7<+oJ!_u @@ -20,9 +21,9 @@ export default function AppShelfMenu(props: any) { radius="md" opened={props.opened || opened} onClose={() => setOpened(false)} - title="Modify a service" + title={t('modal.title')} > - + - Settings + {t('menu.labels.settings')} } onClick={() => setOpened(true)}> - Edit + {t('menu.actions.edit')} - Danger zone + {t('menu.labels.dangerZone')} { @@ -70,7 +71,7 @@ export default function AppShelfMenu(props: any) { }} icon={} > - Delete + {t('menu.actions.delete')} diff --git a/src/components/Settings/AppCardWidthSelector.tsx b/src/components/Settings/AppCardWidthSelector.tsx index 26b453cd3..a29ecc18a 100644 --- a/src/components/Settings/AppCardWidthSelector.tsx +++ b/src/components/Settings/AppCardWidthSelector.tsx @@ -1,9 +1,11 @@ import React from 'react'; import { Text, Slider, Stack } from '@mantine/core'; +import { useTranslation } from 'next-i18next'; import { useConfig } from '../../tools/state'; export function AppCardWidthSelector() { const { config, setConfig } = useConfig(); + const { t } = useTranslation('settings/customization/app-width'); const setappCardWidth = (appCardWidth: number) => { setConfig({ @@ -17,7 +19,7 @@ export function AppCardWidthSelector() { return ( - App Width + {t('label')} + {t('settings/common:tips.configTip')} ); } diff --git a/src/components/Settings/LanguageSwitch.tsx b/src/components/Settings/LanguageSwitch.tsx index a21e8e547..6acd18c10 100644 --- a/src/components/Settings/LanguageSwitch.tsx +++ b/src/components/Settings/LanguageSwitch.tsx @@ -4,29 +4,35 @@ import { IconLanguage } from '@tabler/icons'; import { forwardRef, useState } from 'react'; import { useTranslation } from 'next-i18next'; +import { useRouter } from 'next/router'; +import { getLanguageByCode, Language } from '../../languages/language'; export default function LanguageSwitch() { const { t, i18n } = useTranslation('settings/general/internationalization'); - /*const { language, languages, changeLanguage } = i18n; + const { changeLanguage } = i18n; - const [selectedLanguage, setSelectedLanguage] = useState(language); + const { locale, locales } = useRouter(); + const [selectedLanguage, setSelectedLanguage] = useState(locale); - const data = languages.map((language) => ({ - image: `https://countryflagsapi.com/png/${language.split('-').pop()}`, - label: 'JA', - value: language, - }));*/ + const data = locales + ? locales.map((localeItem) => ({ + value: localeItem, + label: getLanguageByCode(localeItem).originalName, + image: `imgs/flags/${localeItem}.png`, + language: getLanguageByCode(localeItem), + })) + : []; const onChangeSelect = (value: string) => { - //setSelectedLanguage(value); + setSelectedLanguage(value); - const languageName = 'JA IS HALZ SCHEISSE NE'; + const newLanguage = getLanguageByCode(value); - /*changeLanguage(value) + changeLanguage(value) .then(() => { showNotification({ title: 'Language changed', - message: `You changed the language to '${languageName}'`, + message: `You changed the language to '${newLanguage.originalName}'`, color: 'green', autoClose: 5000, }); @@ -34,31 +40,45 @@ export default function LanguageSwitch() { .catch((err) => { showNotification({ title: 'Failed to change language', - message: `Failed to change to '${languageName}', Error:'${err}`, + message: `Failed to change to '${newLanguage.originalName}', Error:'${err}`, color: 'red', autoClose: 5000, }); - });*/ + }); }; return (