From 962cec0875f8f35859ac6e91ac96fe2af91a7ef9 Mon Sep 17 00:00:00 2001 From: Artemy Date: Thu, 27 Apr 2023 18:50:27 +0300 Subject: [PATCH] refactor: get localisation file --- src/components/utils.js | 6 +++++- src/localisation/en.js | 4 +++- src/localisation/ru.js | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/utils.js b/src/components/utils.js index 43c75e6..2f89b78 100644 --- a/src/components/utils.js +++ b/src/components/utils.js @@ -44,4 +44,8 @@ function localesProcess(reRender) { if (reRender) reRenderPage(); } -export { printDate, reRenderPage, localesProcess }; +async function getNetLocale(lang, fileName) { + return (await (await fetch(`localisation/${lang}/${fileName}`)).text()) || ""; +} + +export { printDate, reRenderPage, localesProcess, getNetLocale }; diff --git a/src/localisation/en.js b/src/localisation/en.js index c078446..93193be 100644 --- a/src/localisation/en.js +++ b/src/localisation/en.js @@ -15,8 +15,10 @@ along with this program. If not, see . */ +import { getNetLocale } from "../components/utils"; + let en = { - about_md: (await (await fetch("localisation/en/about.md")).text()) || "", + about_md: await getNetLocale("en", "about.md"), Notes: "Notes", Write: "Write", Chat: "Chat", diff --git a/src/localisation/ru.js b/src/localisation/ru.js index f1effd2..cf4a5c1 100644 --- a/src/localisation/ru.js +++ b/src/localisation/ru.js @@ -15,8 +15,10 @@ along with this program. If not, see . */ +import { getNetLocale } from "../components/utils"; + let ru = { - about_md: (await (await fetch("localisation/ru/about.md")).text()) || "", + about_md: await getNetLocale("ru", "about.md"), Notes: "Заметки", Write: "Написать", Chat: "Чат",