i18n: improve translations

This commit is contained in:
Anthony Fu 2022-11-30 07:25:29 +08:00
parent acdd33ef7d
commit ccffe9daa8
15 changed files with 231 additions and 143 deletions

View file

@ -6,27 +6,19 @@ import { withoutProtocol } from 'ufo'
export const STATUS_VISIBILITIES = [
{
value: 'public',
label: 'Public',
icon: 'i-ri:global-line',
description: 'Visible for all',
},
{
value: 'unlisted',
label: 'Unlisted',
icon: 'i-ri:lock-unlock-line',
description: 'Visible for all, but opted-out of discovery features',
},
{
value: 'private',
label: 'Followers only',
icon: 'i-ri:lock-line',
description: 'Visible for followers only',
},
{
value: 'direct',
label: 'Mentioned people only',
icon: 'i-ri:at-line',
description: 'Visible for mentioned users only',
},
] as const

View file

@ -24,11 +24,12 @@ export const currentUserDrafts = computed(() => {
})
export function getDefaultDraft(options: Partial<Draft['params'] & Omit<Draft, 'params'>> = {}): Draft {
const { t } = useI18n()
const {
status = '',
inReplyToId,
visibility = 'public',
placeholder = 'What is on your mind?',
placeholder = t('placeholder.default_1'),
attachments = [],
} = options
return {
@ -52,11 +53,12 @@ export function getDraftFromStatus(status: Status, text?: null | string): Draft
}
export function getReplyDraft(status: Status) {
const { t } = useI18n()
return {
key: `reply-${status.id}`,
draft: () => getDefaultDraft({
inReplyToId: status!.id,
placeholder: `Reply to ${status?.account ? getDisplayName(status.account) : 'this thread'}`,
placeholder: t('placeholder.reply_to_account', [status?.account ? getDisplayName(status.account) : t('placeholder.the_thread')]),
visibility: status.visibility,
}),
}

View file

@ -4,7 +4,8 @@ export const useFormattedDateTime = (
value: MaybeComputedRef<string | Date | undefined | null>,
options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' },
) => {
const formatter = Intl.DateTimeFormat(undefined, options)
const { locale } = useI18n()
const formatter = Intl.DateTimeFormat(locale.value, options)
return computed(() => {
const v = resolveUnref(value)
return v ? formatter.format(new Date(v)) : ''