summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend/src/i18n/translate.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/frontend/src/i18n/translate.ts b/frontend/src/i18n/translate.ts
new file mode 100644
index 0000000..c0d5620
--- /dev/null
+++ b/frontend/src/i18n/translate.ts
@@ -0,0 +1,9 @@
+import type Locale from "../types/Locale";
+import type { TranslationsDictionary } from "../types/TranslationsDictionary";
+import { defaultLocale } from "./locales";
+
+export default function(locale: Locale) {
+ return function<T extends string>(dict: TranslationsDictionary<T>, key: T) {
+ return dict[key][locale] ?? dict[key][defaultLocale];
+ }
+} \ No newline at end of file