📚 More translations for rules and fields (#4635)

* More translations

* md

* more places
This commit is contained in:
lelemm
2025-03-17 10:43:45 -03:00
committed by GitHub
parent 0cc817f2ef
commit 78e763659e
9 changed files with 64 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
import React from 'react';
import { Trans } from 'react-i18next';
import { Button } from '@actual-app/components/button';
import { SvgFilter } from '@actual-app/components/icons/v1';
@@ -9,7 +10,7 @@ export function FiltersButton({ onPress }: { onPress: () => void }) {
<SvgFilter
style={{ width: 12, height: 12, marginRight: 5, flexShrink: 0 }}
/>{' '}
Filter
<Trans>Filter</Trans>
</Button>
);
}

View File

@@ -384,7 +384,7 @@ export function FilterButton({ onApply, compact, hover, exclude }) {
.sort()
.map(([name, text]) => ({
name,
text: titleFirst(text),
text: titleFirst(mapField(text)),
}))}
/>
</Popover>

View File

@@ -311,7 +311,7 @@ function ScheduleDescription({ id }) {
);
const {
schedules,
statuses: scheduleStatuses,
statusLabels,
isLoading: isSchedulesLoading,
} = useSchedules({ query: scheduleQuery });
@@ -324,7 +324,7 @@ function ScheduleDescription({ id }) {
}
const [schedule] = schedules;
const status = schedule && scheduleStatuses.get(schedule.id);
const status = schedule && statusLabels.get(schedule.id);
return (
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>

View File

@@ -67,7 +67,7 @@ export function Value<T>({
function formatValue(value) {
if (value == null || value === '') {
return '(nothing)';
return t('(nothing)');
} else if (typeof value === 'boolean') {
return value ? 'true' : 'false';
} else {
@@ -104,7 +104,7 @@ export function Value<T>({
if (item) {
return describe(item);
} else {
return '(deleted)';
return t('(deleted)');
}
}

View File

@@ -310,7 +310,7 @@ function MonthlyPatterns({
>
<Select
options={[
[-1, 'Last'],
[-1, t('Last')],
Menu.line,
...DAY_OF_MONTH_OPTIONS.map(opt => [opt, String(opt)] as const),
]}
@@ -327,7 +327,7 @@ function MonthlyPatterns({
/>
<Select
options={[
['day', 'Day'],
['day', t('Day')],
Menu.line,
...DAY_OF_WEEK_OPTIONS.map(opt => [opt.id, opt.name] as const),
]}

View File

@@ -1,4 +1,5 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Input } from '@actual-app/components/input';
import { View } from '@actual-app/components/view';
@@ -35,6 +36,7 @@ export function GenericInput({
onChange,
op = undefined,
}) {
const { t } = useTranslation();
const { grouped: categoryGroups } = useCategories();
const { data: savedReports } = useReports();
const saved = useSelector(state => state.queries.saved);
@@ -63,7 +65,7 @@ export function GenericInput({
<Input
inputRef={inputRef}
defaultValue={value || ''}
placeholder="nothing"
placeholder={t('nothing')}
onEnter={e => onChange(e.target.value)}
onBlur={e => onChange(e.target.value)}
/>
@@ -95,7 +97,7 @@ export function GenericInput({
onSelect={onChange}
inputProps={{
inputRef,
...(showPlaceholder ? { placeholder: 'nothing' } : null),
...(showPlaceholder ? { placeholder: t('nothing') } : null),
}}
/>
);
@@ -116,7 +118,7 @@ export function GenericInput({
onSelect={onChange}
inputProps={{
inputRef,
...(showPlaceholder ? { placeholder: 'nothing' } : null),
...(showPlaceholder ? { placeholder: t('nothing') } : null),
}}
/>
);
@@ -135,7 +137,7 @@ export function GenericInput({
showHiddenCategories={false}
inputProps={{
inputRef,
...(showPlaceholder ? { placeholder: 'nothing' } : null),
...(showPlaceholder ? { placeholder: t('nothing') } : null),
}}
/>
);
@@ -157,7 +159,7 @@ export function GenericInput({
onSelect={onChange}
inputProps={{
inputRef,
...(showPlaceholder ? { placeholder: 'nothing' } : null),
...(showPlaceholder ? { placeholder: t('nothing') } : null),
}}
/>
);
@@ -172,7 +174,7 @@ export function GenericInput({
onSelect={onChange}
inputProps={{
inputRef,
...(showPlaceholder ? { placeholder: 'nothing' } : null),
...(showPlaceholder ? { placeholder: t('nothing') } : null),
}}
/>
);
@@ -261,7 +263,7 @@ export function GenericInput({
<Input
inputRef={inputRef}
defaultValue={value || ''}
placeholder="nothing"
placeholder={t('nothing')}
onEnter={e => onChange(e.target.value)}
onBlur={e => onChange(e.target.value)}
/>

View File

@@ -12,7 +12,11 @@ import React, {
import { useSyncedPref } from '@actual-app/web/src/hooks/useSyncedPref';
import { q, type Query } from '../../shared/query';
import { getHasTransactionsQuery, getStatus } from '../../shared/schedules';
import {
getHasTransactionsQuery,
getStatus,
getStatusLabel,
} from '../../shared/schedules';
import {
type AccountEntity,
type ScheduleEntity,
@@ -24,6 +28,12 @@ import { type LiveQuery, liveQuery } from '../query-helpers';
export type ScheduleStatusType = ReturnType<typeof getStatus>;
export type ScheduleStatuses = Map<ScheduleEntity['id'], ScheduleStatusType>;
export type ScheduleStatusLabelType = ReturnType<typeof getStatusLabel>;
export type ScheduleStatusLabels = Map<
ScheduleEntity['id'],
ScheduleStatusLabelType
>;
function loadStatuses(
schedules: readonly ScheduleEntity[],
onData: (data: ScheduleStatuses) => void,
@@ -58,6 +68,7 @@ type UseSchedulesProps = {
type ScheduleData = {
schedules: readonly ScheduleEntity[];
statuses: ScheduleStatuses;
statusLabels: ScheduleStatusLabels;
};
type UseSchedulesResult = ScheduleData & {
readonly isLoading: boolean;
@@ -72,6 +83,7 @@ export function useSchedules({
const [data, setData] = useState<ScheduleData>({
schedules: [],
statuses: new Map(),
statusLabels: new Map(),
});
const [upcomingLength] = useSyncedPref('upcomingScheduledTransactionLength');
@@ -108,7 +120,16 @@ export function useSchedules({
schedules,
(statuses: ScheduleStatuses) => {
if (!isUnmounted) {
setData({ schedules, statuses });
setData({
schedules,
statuses,
statusLabels: new Map(
[...statuses.keys()].map(key => [
key,
getStatusLabel(statuses.get(key)),
]),
),
});
setIsLoading(false);
}
},

View File

@@ -34,6 +34,23 @@ export function getStatus(
}
}
export function getStatusLabel(status: string) {
switch (status) {
case 'completed':
return t('completed');
case 'paid':
return t('paid');
case 'due':
return t('due');
case 'upcoming':
return t('upcoming');
case 'missed':
return t('missed');
case 'scheduled':
return t('scheduled');
}
}
export function getHasTransactionsQuery(schedules) {
const filters = schedules.map(schedule => {
const dateCond = schedule._conditions.find(c => c.field === 'date');

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [lelemm]
---
More translations for rules and fields