diff options
Diffstat (limited to 'src/i18n')
| -rw-r--r-- | src/i18n/locales.ts | 16 | ||||
| -rw-r--r-- | src/i18n/translate.ts | 9 | ||||
| -rw-r--r-- | src/i18n/translations/pages/furthsettins.ts | 11 | ||||
| -rw-r--r-- | src/i18n/translations/pages/home.ts | 11 | ||||
| -rw-r--r-- | src/i18n/translations/site.ts | 19 |
5 files changed, 66 insertions, 0 deletions
diff --git a/src/i18n/locales.ts b/src/i18n/locales.ts new file mode 100644 index 0000000..4192e3f --- /dev/null +++ b/src/i18n/locales.ts @@ -0,0 +1,16 @@ +import type Locale from '../types/Locale'; + +// Use the magic of TypeScript to guarantee completeness +const localesHash: { [key in Locale]: 1 } = { + 'sco': 1, + 'en-GB': 1, +}; + +// Use the magic of TypeScript to guarantee that the +// default locale is a locale, but also have const +// string type +const defaultLocaleAsLocale: Locale = 'sco'; +const defaultLocale: 'sco' = defaultLocaleAsLocale; + +export { defaultLocale }; +export default Object.keys(localesHash) as Locale[];
\ No newline at end of file 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<T extends string>(dict: TranslationsDictionary<T>, key: T) { + return dict[key][locale] ?? dict[key][defaultLocale]; + } +}
\ No newline at end of file diff --git a/src/i18n/translations/pages/furthsettins.ts b/src/i18n/translations/pages/furthsettins.ts new file mode 100644 index 0000000..c46e2ad --- /dev/null +++ b/src/i18n/translations/pages/furthsettins.ts @@ -0,0 +1,11 @@ +import type { TranslationsDictionary } from "../../../types/TranslationsDictionary"; + +const furthsettinsTranslations = { + 'title': { + 'sco': 'Furthsettins', + 'en-GB': 'Publications', + }, +}; + +type Keys = keyof typeof furthsettinsTranslations; +export default furthsettinsTranslations as TranslationsDictionary<Keys>;
\ No newline at end of file diff --git a/src/i18n/translations/pages/home.ts b/src/i18n/translations/pages/home.ts new file mode 100644 index 0000000..1415024 --- /dev/null +++ b/src/i18n/translations/pages/home.ts @@ -0,0 +1,11 @@ +import type { TranslationsDictionary } from "../../../types/TranslationsDictionary"; + +const homeTranslations = { + 'title': { + 'sco': 'Hame', + 'en-GB': 'Home', + }, +}; + +type Keys = keyof typeof homeTranslations; +export default homeTranslations as TranslationsDictionary<Keys>;
\ No newline at end of file diff --git a/src/i18n/translations/site.ts b/src/i18n/translations/site.ts new file mode 100644 index 0000000..6699619 --- /dev/null +++ b/src/i18n/translations/site.ts @@ -0,0 +1,19 @@ +import type { TranslationsDictionary } from "../../types/TranslationsDictionary"; + +const siteTranslations = { + 'title': { + 'sco': 'Scots Leid Associe', + 'en-GB': 'Scots Language Society', + }, + 'description': { + 'sco': 'The wabsteid o the Scots Leid Associe', + 'en-GB': 'The website of the Scots Language Society', + }, + 'lallans': { + 'sco': 'Lallans', + 'en-GB': 'Lallans', + } +}; + +type Keys = keyof typeof siteTranslations; +export default siteTranslations as TranslationsDictionary<Keys>;
\ No newline at end of file |
