From df2d7d6357d9a9995b8c0f326b251d5bcc9681b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20=E2=80=9CStorm1er=E2=80=9D=20Decaunes?= Date: Thu, 19 Mar 2020 12:14:26 +0100 Subject: [PATCH] fix: #74 Reduce freezes due to translation. --- src/App.tsx | 5 +- src/components/LocaleSelectorModal.tsx | 4 +- src/components/PresetAutoApplyCards.tsx | 28 +++--- src/components/PresetButtons.tsx | 100 +++++++++++---------- src/components/PresetListEmpty.tsx | 21 +++-- src/components/PresetOnline.tsx | 39 +++++--- src/components/PresetOnlineButtons.tsx | 77 ++++++++-------- src/components/RyzenAdjBottomBar.tsx | 47 +++++----- src/components/SceneSelector.tsx | 39 +++----- src/components/SettingForm.tsx | 10 ++- src/components/SysInfoCards.tsx | 42 +++++---- src/components/TopBar.tsx | 7 +- src/contexts/AppVersion.tsx | 1 - src/contexts/LocaleContext.tsx | 32 ++++--- src/contexts/RyzenControllerAppContext.tsx | 25 +++--- src/locales/ch.json | 11 ++- src/locales/de.json | 11 ++- src/locales/en.json | 11 ++- src/locales/es.json | 13 ++- src/locales/fr.json | 11 ++- src/locales/tr.json | 11 ++- src/scenes/PresetsScene.tsx | 62 +++++++------ src/scenes/Scene.tsx | 10 ++- src/scenes/SettingsScene.tsx | 22 ++--- 24 files changed, 378 insertions(+), 261 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index aa5f731..70ccf58 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,12 +10,11 @@ import SysInfoContext, { } from "./contexts/SysInfoContext"; import LightModeContext, { lightModeSettingsKey } from "./contexts/LightModeContext"; import { checkNewVersion } from "./contexts/RyzenControllerAppContext"; -import LocaleContext, { getTranslation, localeSettingsKey } from "./contexts/LocaleContext"; +import LocaleContext, { localeSettingsKey } from "./contexts/LocaleContext"; import LocaleSelectorModal from "./components/LocaleSelectorModal"; const si = window.require("systeminformation"); const electronSettings = window.require("electron-settings"); - type AppState = { sysinfo: SysInfoState; lightMode: { @@ -25,7 +24,6 @@ type AppState = { locale: { is: AvailableLanguages; change(to: AvailableLanguages): void; - getTranslation(id: string, fallback?: string, variables?: Record): string; }; }; @@ -52,7 +50,6 @@ class App extends React.Component<{}, AppState> { locale: { is: this.getLatestLocale(), change: this.changeLocale.bind(this), - getTranslation: getTranslation, }, }; diff --git a/src/components/LocaleSelectorModal.tsx b/src/components/LocaleSelectorModal.tsx index b0fbc3f..e6029a0 100644 --- a/src/components/LocaleSelectorModal.tsx +++ b/src/components/LocaleSelectorModal.tsx @@ -1,13 +1,15 @@ import * as React from "react"; import LocaleContext, { getTranslation } from "../contexts/LocaleContext"; +const localeSelectorModalTitle = getTranslation("app.localeSelectorModalTitle", "Change language"); + export default function LocaleSelectorModal() { return ( {locale => (
-

{getTranslation("app.localeSelectorModalTitle", "Change language")}

+

{localeSelectorModalTitle}

- + {presetNames.map(presetName => { return (