summaryrefslogtreecommitdiff
path: root/src/i18n/translate.ts
blob: c0d56201374571bb50033f48b358354847f74f4e (plain)
1
2
3
4
5
6
7
8
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];
  }
}