summaryrefslogtreecommitdiff
path: root/src/i18n
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-18 18:43:46 +0100
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-18 18:43:46 +0100
commit5d3c0f6139eb53523966a254e89d8010c19dbb90 (patch)
tree1d9b88e6e7a3a99de0eeea443cc050d671f56a16 /src/i18n
parent7ec49f16a3c8f76dcbe1a12edb50e23096ae27ff (diff)
Better typing on long-date translations
Diffstat (limited to 'src/i18n')
-rw-r--r--src/i18n/translations/site.ts25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/i18n/translations/site.ts b/src/i18n/translations/site.ts
index f1f0cd3..7d48670 100644
--- a/src/i18n/translations/site.ts
+++ b/src/i18n/translations/site.ts
@@ -2,7 +2,6 @@ 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 tSite = {
title: {
@@ -55,18 +54,10 @@ const tSite = {
}
},
},
- 'long-date': Object.fromEntries(
- locales.map((locale) => {
- return [
- locale,
- ({ date }: { date: Date }) => `
- ${tSite['ordinal'][locale]({ n: date.slice(8) })}
- ${tSite['month'][locale]({ month: date.slice(5, 7) as Month })}
- ${date.slice(0, 4)}
- `,
- ];
- })
- ),
+ 'long-date': {
+ sco: longDate('sco'),
+ 'en-GB': longDate('en-GB'),
+ },
ordinal: {
sco: ({ n }: { n: string }) => {
const m = n.replace(/^0+/, '');
@@ -179,5 +170,13 @@ const tSite = {
},
};
+function longDate(locale: Locale) {
+ return ({ date }: { date: Date }) => `
+ ${tSite['ordinal'][locale]({ n: date.slice(8) })}
+ ${tSite['month'][locale]({ month: date.slice(5, 7) as Month })}
+ ${date.slice(0, 4)}
+ `;
+}
+
type Raw = typeof tSite;
export default tSite as TranslationsDictionary<Raw>;