From 79144f41681f2979cc95c53791a0ebbc7bea6f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20=E2=80=9CStorm1er=E2=80=9D=20Decaunes?= Date: Mon, 16 Mar 2020 09:27:10 +0100 Subject: [PATCH] fix: Translation minor performance improvement. --- src/contexts/LocaleContext.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/contexts/LocaleContext.tsx b/src/contexts/LocaleContext.tsx index f39dabe..596c4c1 100644 --- a/src/contexts/LocaleContext.tsx +++ b/src/contexts/LocaleContext.tsx @@ -2,6 +2,8 @@ import { createContext } from "react"; import LocaleTranslations from "../locales/LocaleTranslations"; const fs = window.require("fs"); +const electronSettings = window.require("electron-settings"); + const LocaleContext = createContext({ is: "en", change: (to: AvailableLanguages): void => {}, @@ -71,7 +73,6 @@ function addKeyToLocale(_id: string, _currentLocale: string, _fallback: string | * @param variables Variables to replace in the sentence */ function getTranslation(id: string, fallback?: string, variables?: Record): string { - const electronSettings = window.require("electron-settings"); const currentLocale = electronSettings.get("locale") ? (electronSettings.get("locale") as AvailableLanguages) : "en"; var sentence: string | undefined = LocaleTranslations[currentLocale][id];