Add i18n support (#46)

This commit is contained in:
Huang Xin
2024-12-26 23:29:54 +01:00
committed by GitHub
parent dc500c5bb4
commit 4612730474
48 changed files with 2016 additions and 128 deletions
+18
View File
@@ -80,3 +80,21 @@ export const formatAuthors = (
export const formatTitle = (title: string | LanguageMap) => {
return typeof title === 'string' ? title : formatLanguageMap(title);
};
export const formatDate = (date: string | number | Date | undefined) => {
if (!date) return;
try {
return new Date(date).toLocaleDateString(userLang, {
year: 'numeric',
month: 'long',
day: 'numeric',
});
} catch {
return;
}
};
export const formatSubject = (subject: string | string[] | undefined) => {
if (!subject) return '';
return Array.isArray(subject) ? subject.join(', ') : subject;
};