diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-23 20:05:41 +0100 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-23 20:31:20 +0100 |
| commit | 52fa5e27fc37bc156ef722c8258646057a8a826d (patch) | |
| tree | dea6e5e3c78c808360d3fa36d96c89d31f75fc8b /src/i18n | |
| parent | 8a4964fbd8fe8064ee643f135e17fab640a48ce7 (diff) | |
Displays committee role
Diffstat (limited to 'src/i18n')
| -rw-r--r-- | src/i18n/translate.ts | 14 | ||||
| -rw-r--r-- | src/i18n/translations/enums/committeeRole.ts | 21 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/i18n/translate.ts b/src/i18n/translate.ts index a9415b2..8f27e4b 100644 --- a/src/i18n/translate.ts +++ b/src/i18n/translate.ts @@ -1,8 +1,12 @@ +import type CommitteeRole from '$enums/CommitteeRole'; import type Locale from '$types/Locale'; import type { TranslationsDictionary, Translation } from '$types/TranslationsDictionary'; import { defaultLocale } from './locales'; -type TranslationsDictionaryWith<Key extends string, Params> = TranslationsDictionary<{ +type TranslationsDictionaryWith< + Key extends string | CommitteeRole, + Params, +> = TranslationsDictionary<{ [key in Key]: { [locale in typeof defaultLocale]: Translation<Params> } & { [locale in Locale]?: Translation<Params>; }; @@ -14,6 +18,14 @@ export default function (locale: Locale) { Params, Dict extends TranslationsDictionaryWith<Key, Params>, >(dict: Dict, params: { key: Key } & { [Param in keyof Params]: string }) { + if (!(params.key in dict)) { + throw new Error(` + Could not find translation for key '${params.key}'. Available keys were: + ${Object.keys(dict) + .map((k) => `'${k}'`) + .join(', ')} + `); + } const translation = dict[params.key][locale] ?? dict[params.key][defaultLocale]; return translation(params); }; diff --git a/src/i18n/translations/enums/committeeRole.ts b/src/i18n/translations/enums/committeeRole.ts index 06b9980..0d13b18 100644 --- a/src/i18n/translations/enums/committeeRole.ts +++ b/src/i18n/translations/enums/committeeRole.ts @@ -1,27 +1,34 @@ import type { TranslationsDictionary } from '$types/TranslationsDictionary'; -import CommitteeRole from 'enums/CommitteeRole'; const tEnum = { - [CommitteeRole.Preses]: { + Preses: { sco: () => 'Preses', 'en-GB': () => 'President', }, - [CommitteeRole.Secretar]: { + Secretar: { sco: () => 'Secretar', - 'en-GB': () => 'Secretar', + 'en-GB': () => 'Secretary', }, - [CommitteeRole.Thesaurer]: { + Thesaurer: { sco: () => 'Thesaurer', 'en-GB': () => 'Treasurer', }, - [CommitteeRole.Wabmaister]: { + MemmershipSecretar: { + sco: () => 'Memmership Secretar', + 'en-GB': () => 'Membership Secretary', + }, + Wabmaister: { sco: () => 'Wabmaister', 'en-GB': () => 'Webmaster', }, - [CommitteeRole.LallansEiditor]: { + LallansEiditor: { sco: () => 'Lallans Eiditor', 'en-GB': () => 'Lallans Editor', }, + HonoraryPreses: { + sco: () => 'Honorary Preses', + 'en-GB': () => 'Honorary President', + }, }; type Raw = typeof tEnum; |
