aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorsecondl1ght <[email protected]>2022-08-24 18:47:21 -0400
committersecondl1ght <[email protected]>2022-08-24 18:47:21 -0400
commit8f8f85983d2f4cb734ed15b33ebc140028711733 (patch)
tree1bb87287c2dbeb681be1fb83971eea945fe19926 /src/lib
parent80d2b8db2b85829ee539814c176ebcf354939ad6 (diff)
parente54f0cf98d65e71153c4613a1e9a9b845b9f8f87 (diff)
downloadcoinos-ui-8f8f85983d2f4cb734ed15b33ebc140028711733.tar.gz
coinos-ui-8f8f85983d2f4cb734ed15b33ebc140028711733.zip
Merge branch 'master' of github.com:coinos/coinos-ui-v2
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/translations/index.js39
-rw-r--r--src/lib/translations/lang.json2
-rw-r--r--src/lib/utils.js2
3 files changed, 40 insertions, 3 deletions
diff --git a/src/lib/translations/index.js b/src/lib/translations/index.js
index 023da884..dc03c0b6 100644
--- a/src/lib/translations/index.js
+++ b/src/lib/translations/index.js
@@ -1,9 +1,44 @@
import i18n from 'sveltekit-i18n';
-import translations from './translations';
+import lang from './lang.json';
+
+// setup loaders & translations from lang.json data
+function createLocaleLoader(localeCode) {
+ return {
+ locale: localeCode,
+ key: '',
+ loader: async () => (
+ await import(`../../locales/${localeCode}.json`)
+ ).default
+ };
+}
+
+const availableLocales = Object.keys(lang);
+const translations = {};
+for (let i = 0; i < availableLocales.length; i++) {
+ translations[availableLocales[i]] = { lang };
+}
+const loaders = availableLocales.map(createLocaleLoader);
const config = {
initLocale: 'en',
- translations
+ fallbackLocale: 'en',
+ translations: translations,
+ loaders: [
+ {
+ locale: 'en',
+ key: '',
+ loader: async () => (
+ await import("../../locales/en.json")
+ ).default
+ },
+ {
+ locale: 'fr',
+ key: '',
+ loader: async () => (
+ await import("../../locales/fr.json")
+ ).default
+ }
+ ]
};
export const { t, l, locales, locale } = new i18n(config);
diff --git a/src/lib/translations/lang.json b/src/lib/translations/lang.json
index 6cf55908..b01c522b 100644
--- a/src/lib/translations/lang.json
+++ b/src/lib/translations/lang.json
@@ -1,4 +1,4 @@
{
"en": "English",
- "fr": "French"
+ "fr": "Français"
}
diff --git a/src/lib/utils.js b/src/lib/utils.js
index a1bdf8d7..65025c3a 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -47,6 +47,8 @@ export const put = (url, body, headers) => {
method: 'PUT',
body: JSON.stringify(body),
headers
+ }).then(async (r) => {
+ if (!r.ok) throw new Error('put failed');
});
};