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;
};
+6 -4
View File
@@ -1,8 +1,10 @@
import { stubTranslation as _ } from '@/hooks/useTranslation';
export const FILE_REVEAL_LABELS = {
macos: 'Reveal in Finder',
windows: 'Reveal in File Explorer',
linux: 'Reveal in Folder',
default: 'Reveal in Folder',
macos: _('Reveal in Finder'),
windows: _('Reveal in File Explorer'),
linux: _('Reveal in Folder'),
default: _('Reveal in Folder'),
};
export type FILE_REVEAL_PLATFORMS = keyof typeof FILE_REVEAL_LABELS;