Skip to content

Commit

Permalink
feat: update i18next to load language files from locales
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Jan 28, 2024
1 parent 0c4e05a commit a81d1b1
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
64 changes: 60 additions & 4 deletions src/i18n/i18next.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
import {moment} from "obsidian";
import { moment } from "obsidian";

import * as en from "./locales/en.json";
import * as fr from "./locales/fr.json";
import af from "./locales/af.json";
import ar from "./locales/ar.json";
import ca from "./locales/ca.json";
import cs from "./locales/cs.json";
import da from "./locales/da.json";
import de from "./locales/de.json";
import el from "./locales/el.json";
import en from "./locales/en.json";
import es from "./locales/es.json";
import fi from "./locales/fi.json";
import fr from "./locales/fr.json";
import he from "./locales/he.json";
import it from "./locales/it.json";
import ja from "./locales/ja.json";
import ko from "./locales/ko.json";
import nl from "./locales/nl.json";
import no from "./locales/no.json";
import pl from "./locales/pl.json";
import pt from "./locales/pt.json";
import ptBR from "./locales/pt-BR.json";
import ro from "./locales/ro.json";
import ru from "./locales/ru.json";
import sr from "./locales/sr.json";
import sv from "./locales/sv.json";
import tr from "./locales/tr.json";
import uk from "./locales/uk.json";
import vi from "./locales/vi.json";
import zhCN from "./locales/zh-CN.json";
import zhTW from "./locales/zh-TW.json";

export const resources = {
en: { translation: en },
fr: { translation: fr },
af: { translation: af },
ar: { translation: ar },
ca: { translation: ca },
cs: { translation: cs },
da: { translation: da },
de: { translation: de },
el: { translation: el },
es: { translation: es },
fi: { translation: fi },
he: { translation: he },
it: { translation: it },
ja: { translation: ja },
ko: { translation: ko },
nl: { translation: nl },
no: { translation: no },
pl: { translation: pl },
pt: { translation: pt },
"pt-BR": { translation: ptBR },
ru: { translation: ru },
ro: { translation: ro },
sr: { translation: sr },
sv: { translation: sv },
tr: { translation: tr },
uk: { translation: uk },
vi: { translation: vi },
"zh-TW": { translation: zhTW },
"zh-CN": { translation: zhCN },
} as const;

export const translationLanguage = Object.keys(resources).find(i => i==moment.locale()) ? moment.locale() : "en";
export const translationLanguage = Object.keys(resources).find(i => i.toLocaleLowerCase() == moment.locale()) ? moment.locale() : "en";
console.log(`[i18n] Using ${translationLanguage} as translation language.`);
console.log(moment.locale());
File renamed without changes.
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export default class GithubPublisher extends Plugin {
resources,
returnNull: false,
});
console.log(`[i18n] Using ${translationLanguage} as translation language. LANG: ${i18next.language}, LOADED: ${i18next.languages.join(", ")}`);



Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"isolatedModules": true,
"resolveJsonModule": true,
"strict":true,
"allowSyntheticDefaultImports": true,
"lib": [
"DOM",
"ES5",
Expand Down

0 comments on commit a81d1b1

Please sign in to comment.