diff options
Diffstat (limited to 'src/i18n/translations/site.ts')
| -rw-r--r-- | src/i18n/translations/site.ts | 133 |
1 files changed, 131 insertions, 2 deletions
diff --git a/src/i18n/translations/site.ts b/src/i18n/translations/site.ts index 25598f1..6c16f8f 100644 --- a/src/i18n/translations/site.ts +++ b/src/i18n/translations/site.ts @@ -1,5 +1,8 @@ -import type Locale from '../../types/Locale'; -import type { TranslationsDictionary } from '../../types/TranslationsDictionary'; +import type Date from '$types/Date'; +import type Month from '$types/Month'; +import type Locale from '$types/Locale'; +import type { TranslationsDictionary } from '$types/TranslationsDictionary'; +import locales from '../locales'; const siteTranslations = { title: { @@ -14,6 +17,10 @@ const siteTranslations = { sco: () => 'Lallans', 'en-GB': () => 'Lallans', }, + scotsoun: { + sco: () => 'Scotsoun', + 'en-GB': () => 'Scotsoun', + }, 'scots-leid-associe': { sco: () => 'Scots Leid Associe', 'en-GB': () => 'Scots Language Society', @@ -40,6 +47,128 @@ const siteTranslations = { } }, }, + 'long-date': Object.fromEntries( + locales.map((locale) => { + return [ + locale, + ({ date }: { date: Date }) => ` + ${siteTranslations['ordinal'][locale]({ n: date.slice(8) })} + ${siteTranslations['month'][locale]({ month: date.slice(5, 7) as Month })} + ${date.slice(0, 4)} + `, + ]; + }) + ), + ordinal: { + sco: ({ n }: { n: string }) => { + const m = n.replace(/^0+/, ''); + switch (m.at(-1)) { + case '1': + // Exception for numbers ending in eleven + if (m.length > 1 && m.at(-2) === '1') { + return `${m}t`; + } + return `${m}st`; + case '2': + // Exception for numbers ending in twelve + if (m.length > 1 && m.at(-2) === '1') { + return `${m}t`; + } + return `${m}nt`; + case '3': + // Exception for numbers ending in thirteen + if (m.length > 1 && m.at(-2) === '1') { + return `${m}t`; + } + return `${m}rd`; + default: + return `${m}t`; + } + }, + 'en-GB': ({ n }: { n: string }) => { + const m = n.replace(/^0+/, ''); + switch (m.at(-1)) { + case '1': + // Exception for numbers ending in eleven + if (m.length > 1 && m.at(-2) === '1') { + return `${m}th`; + } + return `${m}st`; + case '2': + // Exception for numbers ending in twelve + if (m.length > 1 && m.at(-2) === '1') { + return `${m}th`; + } + return `${m}nd`; + case '3': + // Exception for numbers ending in thirteen + if (m.length > 1 && m.at(-2) === '1') { + return `${m}th`; + } + return `${m}rd`; + default: + return `${m}th`; + } + }, + }, + month: { + sco: ({ month }: { month: Month }) => { + switch (month) { + case '01': + return 'Januar'; + case '02': + return 'Februar'; + case '03': + return 'Mairch'; + case '04': + return 'April'; + case '05': + return 'Mey'; + case '06': + return 'June'; + case '07': + return 'July'; + case '08': + return 'August'; + case '09': + return 'Septemmer'; + case '10': + return 'October'; + case '11': + return 'Novemmer'; + case '12': + return 'Decemmer'; + } + }, + 'en-GB': ({ month }: { month: Month }) => { + switch (month) { + case '01': + return 'January'; + case '02': + return 'February'; + case '03': + return 'March'; + case '04': + return 'April'; + case '05': + return 'May'; + case '06': + return 'June'; + case '07': + return 'July'; + case '08': + return 'August'; + case '09': + return 'September'; + case '10': + return 'October'; + case '11': + return 'November'; + case '12': + return 'December'; + } + }, + }, }; type Raw = typeof siteTranslations; |
