diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2023-08-04 18:35:06 +0100 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2023-08-04 18:35:06 +0100 |
| commit | bfdcb0ab536c03d03e0c69cc883f9a2934ec4fb0 (patch) | |
| tree | 68ab63d409e8dee8aa58117573f490e716a49334 /frontend/src/i18n | |
| parent | c74568bccde457dd089a4df5b7b97edabd95a56e (diff) | |
Defines translation function
Diffstat (limited to 'frontend/src/i18n')
| -rw-r--r-- | frontend/src/i18n/translate.ts | 9 |
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 |
