mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Update i18next type
This commit is contained in:
@@ -28,7 +28,7 @@ const TimelineActions: React.FC = () => {
|
||||
if (!queryKey || !status || disableDetails) return null
|
||||
|
||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
||||
const { t } = useTranslation('componentTimeline')
|
||||
const { t } = useTranslation(['common', 'componentTimeline'])
|
||||
const { colors, theme } = useTheme()
|
||||
const iconColor = colors.secondary
|
||||
|
||||
@@ -54,13 +54,13 @@ const TimelineActions: React.FC = () => {
|
||||
queryClient.invalidateQueries(tempQueryKey)
|
||||
}
|
||||
},
|
||||
onError: (err: any, params, oldData) => {
|
||||
onError: (err: any, params) => {
|
||||
const correctParam = params as MutationVarsTimelineUpdateStatusProperty
|
||||
displayMessage({
|
||||
theme,
|
||||
type: 'error',
|
||||
message: t('common:message.error.message', {
|
||||
function: t(`shared.actions.${correctParam.payload.property}.function`)
|
||||
function: t(`componentTimeline:shared.actions.${correctParam.payload.property}.function`)
|
||||
}),
|
||||
...(err.status &&
|
||||
typeof err.status === 'number' &&
|
||||
@@ -94,10 +94,10 @@ const TimelineActions: React.FC = () => {
|
||||
if (!status.reblogged) {
|
||||
showActionSheetWithOptions(
|
||||
{
|
||||
title: t('shared.actions.reblogged.options.title'),
|
||||
title: t('componentTimeline:shared.actions.reblogged.options.title'),
|
||||
options: [
|
||||
t('shared.actions.reblogged.options.public'),
|
||||
t('shared.actions.reblogged.options.unlisted'),
|
||||
t('componentTimeline:shared.actions.reblogged.options.public'),
|
||||
t('componentTimeline:shared.actions.reblogged.options.unlisted'),
|
||||
t('common:buttons.cancel')
|
||||
],
|
||||
cancelButtonIndex: 2,
|
||||
@@ -269,7 +269,7 @@ const TimelineActions: React.FC = () => {
|
||||
<Pressable
|
||||
{...(highlighted
|
||||
? {
|
||||
accessibilityLabel: t('shared.actions.reply.accessibilityLabel'),
|
||||
accessibilityLabel: t('componentTimeline:shared.actions.reply.accessibilityLabel'),
|
||||
accessibilityRole: 'button'
|
||||
}
|
||||
: { accessibilityLabel: '' })}
|
||||
@@ -281,7 +281,9 @@ const TimelineActions: React.FC = () => {
|
||||
<Pressable
|
||||
{...(highlighted
|
||||
? {
|
||||
accessibilityLabel: t('shared.actions.reblogged.accessibilityLabel'),
|
||||
accessibilityLabel: t(
|
||||
'componentTimeline:shared.actions.reblogged.accessibilityLabel'
|
||||
),
|
||||
accessibilityRole: 'button'
|
||||
}
|
||||
: { accessibilityLabel: '' })}
|
||||
@@ -296,7 +298,9 @@ const TimelineActions: React.FC = () => {
|
||||
<Pressable
|
||||
{...(highlighted
|
||||
? {
|
||||
accessibilityLabel: t('shared.actions.favourited.accessibilityLabel'),
|
||||
accessibilityLabel: t(
|
||||
'componentTimeline:shared.actions.favourited.accessibilityLabel'
|
||||
),
|
||||
accessibilityRole: 'button'
|
||||
}
|
||||
: { accessibilityLabel: '' })}
|
||||
@@ -308,7 +312,9 @@ const TimelineActions: React.FC = () => {
|
||||
<Pressable
|
||||
{...(highlighted
|
||||
? {
|
||||
accessibilityLabel: t('shared.actions.bookmarked.accessibilityLabel'),
|
||||
accessibilityLabel: t(
|
||||
'componentTimeline:shared.actions.bookmarked.accessibilityLabel'
|
||||
),
|
||||
accessibilityRole: 'button'
|
||||
}
|
||||
: { accessibilityLabel: '' })}
|
||||
|
@@ -15,7 +15,7 @@ export interface FilteredProps {
|
||||
|
||||
const TimelineFiltered: React.FC<FilteredProps> = ({ filterResults }) => {
|
||||
const { colors } = useTheme()
|
||||
const { t } = useTranslation('componentTimeline')
|
||||
const { t } = useTranslation(['common', 'componentTimeline'])
|
||||
|
||||
const main = () => {
|
||||
if (!filterResults?.length) {
|
||||
@@ -23,18 +23,27 @@ const TimelineFiltered: React.FC<FilteredProps> = ({ filterResults }) => {
|
||||
}
|
||||
switch (typeof filterResults[0]) {
|
||||
case 'string': // v1 filter
|
||||
return <>{t('shared.filtered.match', { context: 'v1', phrase: filterResults[0] })}</>
|
||||
return (
|
||||
<>
|
||||
{t('componentTimeline:shared.filtered.match', {
|
||||
defaultValue: 'v1',
|
||||
context: 'v1',
|
||||
phrase: filterResults[0]
|
||||
})}
|
||||
</>
|
||||
)
|
||||
default:
|
||||
return (
|
||||
<>
|
||||
{t('shared.filtered.match', {
|
||||
{t('componentTimeline:shared.filtered.match', {
|
||||
defaultValue: 'v2',
|
||||
context: 'v2',
|
||||
count: filterResults.length,
|
||||
filters: filterResults.map(result => result.title).join(t('common:separator'))
|
||||
})}
|
||||
<CustomText
|
||||
style={{ color: colors.blue }}
|
||||
children={`\n${t('shared.filtered.reveal')}`}
|
||||
children={`\n${t('componentTimeline:shared.filtered.reveal')}`}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
|
@@ -22,7 +22,7 @@ const HeaderConversation = ({ conversation }: Props) => {
|
||||
if (!queryKey) return null
|
||||
|
||||
const { colors, theme } = useTheme()
|
||||
const { t } = useTranslation('componentTimeline')
|
||||
const { t } = useTranslation(['common', 'componentTimeline'])
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const mutation = useTimelineMutation({
|
||||
@@ -32,7 +32,7 @@ const HeaderConversation = ({ conversation }: Props) => {
|
||||
theme,
|
||||
type: 'error',
|
||||
message: t('common:message.error.message', {
|
||||
function: t(`shared.header.conversation.delete.function`)
|
||||
function: t(`componentTimeline:shared.header.conversation.delete.function`)
|
||||
}),
|
||||
...(err.status &&
|
||||
typeof err.status === 'number' &&
|
||||
@@ -53,7 +53,7 @@ const HeaderConversation = ({ conversation }: Props) => {
|
||||
numberOfLines={1}
|
||||
style={{ ...StyleConstants.FontStyle.M, color: colors.secondary }}
|
||||
>
|
||||
<CustomText>{t('shared.header.conversation.withAccounts')}</CustomText>
|
||||
<CustomText>{t('componentTimeline:shared.header.conversation.withAccounts')}</CustomText>
|
||||
{conversation.accounts.map((account, index) => (
|
||||
<CustomText key={account.id} numberOfLines={1}>
|
||||
{index !== 0 ? t('common:separator') : undefined}
|
||||
|
@@ -33,7 +33,7 @@ const TimelinePoll: React.FC = () => {
|
||||
const poll = status.poll
|
||||
|
||||
const { colors, theme } = useTheme()
|
||||
const { t } = useTranslation('componentTimeline')
|
||||
const { t } = useTranslation(['common', 'componentTimeline'])
|
||||
|
||||
const [allOptions, setAllOptions] = useState(new Array(status.poll.options.length).fill(false))
|
||||
|
||||
@@ -58,8 +58,7 @@ const TimelinePoll: React.FC = () => {
|
||||
theme,
|
||||
type: 'error',
|
||||
message: t('common:message.error.message', {
|
||||
// @ts-ignore
|
||||
function: t(`shared.poll.meta.button.${theParams.payload.type}`)
|
||||
function: t(`componentTimeline:shared.poll.meta.button.${theParams.payload.type}` as any)
|
||||
}),
|
||||
...(err.status &&
|
||||
typeof err.status === 'number' &&
|
||||
@@ -95,7 +94,7 @@ const TimelinePoll: React.FC = () => {
|
||||
})
|
||||
}
|
||||
type='text'
|
||||
content={t('shared.poll.meta.button.vote')}
|
||||
content={t('componentTimeline:shared.poll.meta.button.vote')}
|
||||
loading={mutation.isLoading}
|
||||
disabled={allOptions.filter(o => o !== false).length === 0}
|
||||
/>
|
||||
@@ -120,7 +119,7 @@ const TimelinePoll: React.FC = () => {
|
||||
})
|
||||
}
|
||||
type='text'
|
||||
content={t('shared.poll.meta.button.refresh')}
|
||||
content={t('componentTimeline:shared.poll.meta.button.refresh')}
|
||||
loading={mutation.isLoading}
|
||||
/>
|
||||
</View>
|
||||
@@ -233,20 +232,25 @@ const TimelinePoll: React.FC = () => {
|
||||
|
||||
const pollVoteCounts = () => {
|
||||
if (poll.voters_count !== null) {
|
||||
return t('shared.poll.meta.count.voters', { count: poll.voters_count }) + ' • '
|
||||
return (
|
||||
t('componentTimeline:shared.poll.meta.count.voters', { count: poll.voters_count }) + ' • '
|
||||
)
|
||||
} else if (poll.votes_count !== null) {
|
||||
return t('shared.poll.meta.count.votes', { count: poll.votes_count }) + ' • '
|
||||
return (
|
||||
t('componentTimeline:shared.poll.meta.count.votes', { count: poll.votes_count }) + ' • '
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const pollExpiration = () => {
|
||||
if (poll.expired) {
|
||||
return t('shared.poll.meta.expiration.expired')
|
||||
return t('componentTimeline:shared.poll.meta.expiration.expired')
|
||||
} else {
|
||||
if (poll.expires_at) {
|
||||
return (
|
||||
<Trans
|
||||
i18nKey='componentTimeline:shared.poll.meta.expiration.until'
|
||||
ns='componentTimeline'
|
||||
i18nKey='shared.poll.meta.expiration.until'
|
||||
components={[<RelativeTime time={poll.expires_at} />]}
|
||||
/>
|
||||
)
|
||||
|
@@ -16,7 +16,7 @@ const TimelineTranslate = () => {
|
||||
const { status, highlighted, rawContent, detectedLanguage } = useContext(StatusContext)
|
||||
if (!status || !highlighted || !rawContent?.current.length) return null
|
||||
|
||||
const { t } = useTranslation('componentTimeline')
|
||||
const { t } = useTranslation(['componentTimeline'])
|
||||
const { colors } = useTheme()
|
||||
|
||||
const [detected, setDetected] = useState<{
|
||||
@@ -101,15 +101,15 @@ const TimelineTranslate = () => {
|
||||
}}
|
||||
>
|
||||
{isError
|
||||
? t('shared.translate.failed')
|
||||
? t('componentTimeline:shared.translate.failed')
|
||||
: isSuccess
|
||||
? typeof data?.error === 'string'
|
||||
? t(`shared.translate.${data.error}`)
|
||||
: t('shared.translate.succeed', {
|
||||
? t(`componentTimeline:shared.translate.${data.error}` as any)
|
||||
: t('componentTimeline:shared.translate.succeed', {
|
||||
provider: data?.provider,
|
||||
source: data?.sourceLanguage
|
||||
})
|
||||
: t('shared.translate.default')}
|
||||
: t('componentTimeline:shared.translate.default')}
|
||||
</CustomText>
|
||||
{isFetching ? (
|
||||
<Circle
|
||||
|
Reference in New Issue
Block a user