From b0f1c4bd201ef397e41fc20149473ff9423e4be2 Mon Sep 17 00:00:00 2001 From: kacan98 Date: Mon, 15 Apr 2024 01:15:40 +0200 Subject: [PATCH] Fix small translation mistakes --- i18next-scanner.config.cjs | 3 ++- public/i18n/cz/translation.json | 5 +++- public/i18n/de/translation.json | 5 +++- public/i18n/dk/translation.json | 5 +++- public/i18n/en/translation.json | 5 +++- public/i18n/ro/translation.json | 5 +++- public/i18n/se/translation.json | 5 +++- src/components/result/buyingChart.tsx | 26 ++++++++++++-------- src/components/settingsDialog.tsx | 3 ++- src/main.tsx | 2 -- src/services/useAlternativeInvestment.ts | 2 +- store/calculatorSlices/useCalculatorSlice.ts | 1 + store/index.ts | 20 +++++++++++---- 13 files changed, 61 insertions(+), 26 deletions(-) diff --git a/i18next-scanner.config.cjs b/i18next-scanner.config.cjs index bba2991..53c4cc7 100644 --- a/i18next-scanner.config.cjs +++ b/i18next-scanner.config.cjs @@ -10,11 +10,12 @@ module.exports = { list: ["t"], // Include the 't' function extensions: [".ts", ".tsx"], // Scan TypeScript and TSX files }, - lngs: ["en", "de", "cz", "dk", "se"], + lngs: ["en", "de", "cz", "dk", "se", "ro"], defaultLng: "en", resource: { loadPath: "i18n/{{lng}}/{{ns}}.json", savePath: "i18n/{{lng}}/{{ns}}.json", + override: false, // Do not override the existing JSON files }, }, }; diff --git a/public/i18n/cz/translation.json b/public/i18n/cz/translation.json index e88af26..cb2fdb0 100644 --- a/public/i18n/cz/translation.json +++ b/public/i18n/cz/translation.json @@ -61,5 +61,8 @@ "Capital from selling details": "Detaily kapitálu z prodeje", "Currency": "Měna", "Start over": "Začít znovu", - "Select currency": "Vyberte měnu" + "Select currency": "Vyberte měnu", + "Language": "Jazyk", + "Select language": "Vyberte jazyk", + "Monthly costs of buying": "Měsíční náklady na koupi" } diff --git a/public/i18n/de/translation.json b/public/i18n/de/translation.json index 1682485..b19c580 100644 --- a/public/i18n/de/translation.json +++ b/public/i18n/de/translation.json @@ -61,5 +61,8 @@ "Capital from selling details": "Details zum Kapital aus dem Verkauf", "Currency": "Währung", "Start over": "Neu starten", - "Select currency": "Währung auswählen" + "Select currency": "Währung auswählen", + "Language": "Sprache", + "Select language": "Sprache auswählen", + "Monthly costs of buying": "Monatliche Kosten des Kaufens" } diff --git a/public/i18n/dk/translation.json b/public/i18n/dk/translation.json index ab31f27..b071ff8 100644 --- a/public/i18n/dk/translation.json +++ b/public/i18n/dk/translation.json @@ -61,5 +61,8 @@ "Capital from selling details": "Detaljer om kapital fra salg", "Currency": "Valuta", "Start over": "Start forfra", - "Select currency": "Vælg valuta" + "Select currency": "Vælg valuta", + "Language": "Sprog", + "Select language": "Vælg sprog", + "Monthly costs of buying": "Månedlige omkostninger ved køb" } diff --git a/public/i18n/en/translation.json b/public/i18n/en/translation.json index 848f6bd..7157a8c 100644 --- a/public/i18n/en/translation.json +++ b/public/i18n/en/translation.json @@ -61,5 +61,8 @@ "Capital from selling details": "Details of Capital from Selling", "Currency": "Currency", "Start over": "Start Over", - "Select currency": "Select Currency" + "Select currency": "Select Currency", + "Language": "Language", + "Select language": "Select Language", + "Monthly costs of buying": "Monthly Costs of Buying" } diff --git a/public/i18n/ro/translation.json b/public/i18n/ro/translation.json index e93fb7a..9975a2e 100644 --- a/public/i18n/ro/translation.json +++ b/public/i18n/ro/translation.json @@ -61,5 +61,8 @@ "Capital from selling details": "Detalii capital din vânzare", "Currency": "Monedă", "Start over": "Începe din nou", - "Select currency": "Selectează moneda" + "Select currency": "Selectează moneda", + "Language": "Limba", + "Select language": "Selectează limba", + "Monthly costs of buying": "Costuri lunare de cumpărare" } diff --git a/public/i18n/se/translation.json b/public/i18n/se/translation.json index 349d41d..09d0640 100644 --- a/public/i18n/se/translation.json +++ b/public/i18n/se/translation.json @@ -61,5 +61,8 @@ "Capital from selling details": "Detaljer om kapital från försäljning", "Currency": "Valuta", "Start over": "Börja om", - "Select currency": "Välj valuta" + "Select currency": "Välj valuta", + "Language": "Språk", + "Select language": "Välj språk", + "Monthly costs of buying": "Månadskostnader för köp" } diff --git a/src/components/result/buyingChart.tsx b/src/components/result/buyingChart.tsx index 8c8d433..c87e916 100644 --- a/src/components/result/buyingChart.tsx +++ b/src/components/result/buyingChart.tsx @@ -1,6 +1,7 @@ import { LineChart } from "@mui/x-charts"; import { PeriodValueChange } from "../../services/buying/buying.model.ts"; import { useTranslation } from "react-i18next"; +import { Typography } from "@mui/material"; function BuyingChart({ graphData }: { graphData: PeriodValueChange[] }) { const { t } = useTranslation(); @@ -58,16 +59,21 @@ function BuyingChart({ graphData }: { graphData: PeriodValueChange[] }) { if (graphData.length === 0) return <>; return ( - value.toString(), - data: years, - }, - ]} - series={labelObjects} - {...customize} - /> + <> + + {t("Monthly costs of buying")}: + + value.toString(), + data: years, + }, + ]} + series={labelObjects} + {...customize} + /> + ); } diff --git a/src/components/settingsDialog.tsx b/src/components/settingsDialog.tsx index f22662d..1fe24ea 100644 --- a/src/components/settingsDialog.tsx +++ b/src/components/settingsDialog.tsx @@ -53,9 +53,9 @@ export function SettingsDialog(props: SimpleDialogProps) { if (value) { i18n.changeLanguage(value); dispatch(setLocale(value)); - toggleLanguageDialog(false); onClose(); } + toggleLanguageDialog(false); }; const settings: { @@ -95,6 +95,7 @@ export function SettingsDialog(props: SimpleDialogProps) { break; case "startOver": localStorage.removeItem("state"); + localStorage.removeItem("i18nextLng"); //refresh page window.location.reload(); break; diff --git a/src/main.tsx b/src/main.tsx index f33b2f1..c34ca7c 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -12,8 +12,6 @@ import { CssBaseline } from "@mui/material"; import { I18nextProvider } from "react-i18next"; import i18n from "./i18n.ts"; -console.log(i18n); - ReactDOM.createRoot(document.getElementById("root")!).render( diff --git a/src/services/useAlternativeInvestment.ts b/src/services/useAlternativeInvestment.ts index 9f8ec68..d0f4f7f 100644 --- a/src/services/useAlternativeInvestment.ts +++ b/src/services/useAlternativeInvestment.ts @@ -38,7 +38,7 @@ export function useAlternativeInvestmentReturns() { const { totalAtTheEnd, monthlyValues, valueAdded, allMonthlyInvestment } = calculateInvestmentReturns({ initialInvestment: initialCash, - monthlyInvestment: moneyAvailablePerMonth, + monthlyInvestment: moneyAvailablePerMonth * 12, numberOfPeriods: yearsStaying, appreciationRate: alternativeInvestmentReturnPercentage / 100, }); diff --git a/store/calculatorSlices/useCalculatorSlice.ts b/store/calculatorSlices/useCalculatorSlice.ts index aa9af49..23336b5 100644 --- a/store/calculatorSlices/useCalculatorSlice.ts +++ b/store/calculatorSlices/useCalculatorSlice.ts @@ -19,6 +19,7 @@ export default function useCalculatorSlice( const createFloatStateUpdateFc = (fieldName: keyof CalculatorState[T]) => { return (e: React.ChangeEvent) => { + // @ts-expect-error - this is a hack to get around the fact that the type of the action is not known at compile time const action = createAction[sliceName]; const value = parseFloat(e.target.value || "0"); dispatch( diff --git a/store/index.ts b/store/index.ts index e266d3b..7873ffa 100644 --- a/store/index.ts +++ b/store/index.ts @@ -1,4 +1,4 @@ -import { combineReducers, configureStore } from "@reduxjs/toolkit"; +import { combineReducers, configureStore, Store } from "@reduxjs/toolkit"; import { buyingSlice } from "./calculatorSlices/buying.ts"; import { futurePredictionsSlice } from "./calculatorSlices/futurePreditions.ts"; import { rentingSlice } from "./calculatorSlices/renting.ts"; @@ -12,15 +12,25 @@ const calculatorReducers = combineReducers({ }); const persistedState = loadFromLocalStorage(); + const reducer = combineReducers({ calculator: calculatorReducers, settings: settingsSlice.reducer, }); -export const store = configureStore({ - reducer, - preloadedState: persistedState, -}); +export let store: Store; + +try { + store = configureStore({ + reducer, + preloadedState: persistedState, + }); +} catch (e) { + console.error(e); + store = configureStore({ + reducer, + }); +} store.subscribe(() => saveToLocalStorage(store.getState()));