forked from akai/readest
Add i18n support (#46)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user