From 3098c31049e17dfdcdf451e843f6c4bdcf5b2fa1 Mon Sep 17 00:00:00 2001 From: Joe Carstairs <65492573+Sycamost@users.noreply.github.com> Date: Sat, 5 Aug 2023 21:16:45 +0100 Subject: Moves to root folder --- src/i18n/translate.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/i18n/translate.ts (limited to 'src/i18n/translate.ts') diff --git a/src/i18n/translate.ts b/src/i18n/translate.ts new file mode 100644 index 0000000..c0d5620 --- /dev/null +++ b/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