From bfdcb0ab536c03d03e0c69cc883f9a2934ec4fb0 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Fri, 4 Aug 2023 18:35:06 +0100 Subject: Defines translation function --- frontend/src/i18n/translate.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 frontend/src/i18n/translate.ts (limited to 'frontend/src') 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(dict: TranslationsDictionary, key: T) { + return dict[key][locale] ?? dict[key][defaultLocale]; + } +} \ No newline at end of file -- cgit v1.2.3