mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-28 10:33:02 -05:00
📚 More Translations (#5812)
* Translations * linter * Add release notes for PR #5812 * actions trigger * md category change * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * typecheck fix * linter * more linter * omg * Fixes * [autofix.ci] apply automated fixes * Code review change --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Leandro Menezes <leandro.menezes@fusionflowsoftware.com>
This commit is contained in:
@@ -212,10 +212,28 @@ export const moveCategoryGroup = createAppAsyncThunk(
|
||||
},
|
||||
);
|
||||
|
||||
function translateCategories(
|
||||
categories: CategoryEntity[] | undefined,
|
||||
): CategoryEntity[] | undefined {
|
||||
return categories?.map(cat => ({
|
||||
...cat,
|
||||
name:
|
||||
cat.name?.toLowerCase() === 'starting balances'
|
||||
? t('Starting Balances')
|
||||
: cat.name,
|
||||
}));
|
||||
}
|
||||
|
||||
export const getCategories = createAppAsyncThunk(
|
||||
`${sliceName}/getCategories`,
|
||||
async () => {
|
||||
const categories: CategoryViews = await send('get-categories');
|
||||
categories.list = translateCategories(categories.list) as CategoryEntity[];
|
||||
categories.grouped.forEach(group => {
|
||||
group.categories = translateCategories(
|
||||
group.categories,
|
||||
) as CategoryEntity[];
|
||||
});
|
||||
return categories;
|
||||
},
|
||||
{
|
||||
@@ -233,6 +251,12 @@ export const reloadCategories = createAppAsyncThunk(
|
||||
`${sliceName}/reloadCategories`,
|
||||
async () => {
|
||||
const categories: CategoryViews = await send('get-categories');
|
||||
categories.list = translateCategories(categories.list) as CategoryEntity[];
|
||||
categories.grouped.forEach(group => {
|
||||
group.categories = translateCategories(
|
||||
group.categories,
|
||||
) as CategoryEntity[];
|
||||
});
|
||||
return categories;
|
||||
},
|
||||
);
|
||||
@@ -556,6 +580,7 @@ export const getCategoriesById = memoizeOne(
|
||||
res[cat.id] = cat;
|
||||
});
|
||||
});
|
||||
|
||||
return res;
|
||||
},
|
||||
);
|
||||
@@ -584,6 +609,12 @@ function _loadCategories(
|
||||
categories: BudgetState['categories'],
|
||||
) {
|
||||
state.categories = categories;
|
||||
categories.list = translateCategories(categories.list) as CategoryEntity[];
|
||||
categories.grouped.forEach(group => {
|
||||
group.categories = translateCategories(
|
||||
group.categories,
|
||||
) as CategoryEntity[];
|
||||
});
|
||||
state.isCategoriesLoading = false;
|
||||
state.isCategoriesLoaded = true;
|
||||
state.isCategoriesDirty = false;
|
||||
|
||||
@@ -96,7 +96,9 @@ export function EnvelopeBudgetMonthMenuModal({
|
||||
}}
|
||||
>
|
||||
<Notes
|
||||
notes={originalNotes?.length > 0 ? originalNotes : 'No notes'}
|
||||
notes={
|
||||
originalNotes?.length > 0 ? originalNotes : t('No notes')
|
||||
}
|
||||
editable={false}
|
||||
focused={false}
|
||||
getStyle={() => ({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useResponsive } from '@actual-app/components/hooks/useResponsive';
|
||||
|
||||
@@ -21,6 +22,7 @@ const timeout = 10000;
|
||||
export function useUndo(): UndoActions {
|
||||
const dispatch = useDispatch();
|
||||
const { isNarrowWidth } = useResponsive();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const showUndoNotification = useCallback(
|
||||
(notification: Notification) => {
|
||||
@@ -34,7 +36,7 @@ export function useUndo(): UndoActions {
|
||||
type: 'message',
|
||||
timeout,
|
||||
button: {
|
||||
title: 'Undo',
|
||||
title: t('Undo'),
|
||||
action: undo,
|
||||
},
|
||||
...notification,
|
||||
@@ -42,7 +44,7 @@ export function useUndo(): UndoActions {
|
||||
}),
|
||||
);
|
||||
},
|
||||
[dispatch, isNarrowWidth],
|
||||
[dispatch, isNarrowWidth, t],
|
||||
);
|
||||
|
||||
const showRedoNotification = useCallback(
|
||||
@@ -57,7 +59,7 @@ export function useUndo(): UndoActions {
|
||||
type: 'message',
|
||||
timeout,
|
||||
button: {
|
||||
title: 'Redo',
|
||||
title: t('Redo'),
|
||||
action: redo,
|
||||
},
|
||||
...notification,
|
||||
@@ -65,7 +67,7 @@ export function useUndo(): UndoActions {
|
||||
}),
|
||||
);
|
||||
},
|
||||
[dispatch, isNarrowWidth],
|
||||
[dispatch, isNarrowWidth, t],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { t } from 'i18next';
|
||||
import memoizeOne from 'memoize-one';
|
||||
|
||||
import { send } from 'loot-core/platform/client/fetch';
|
||||
@@ -100,6 +101,18 @@ type CreatePayeePayload = {
|
||||
name: PayeeEntity['name'];
|
||||
};
|
||||
|
||||
function translatePayees(
|
||||
payees: PayeeEntity[] | null | undefined,
|
||||
): PayeeEntity[] | null | undefined {
|
||||
return (
|
||||
payees?.map(payee =>
|
||||
payee.name === 'Starting Balance'
|
||||
? { ...payee, name: t('Starting Balance') }
|
||||
: payee,
|
||||
) ?? payees
|
||||
);
|
||||
}
|
||||
|
||||
export const createPayee = createAppAsyncThunk(
|
||||
`${sliceName}/createPayee`,
|
||||
async ({ name }: CreatePayeePayload) => {
|
||||
@@ -114,7 +127,7 @@ export const getCommonPayees = createAppAsyncThunk(
|
||||
`${sliceName}/getCommonPayees`,
|
||||
async () => {
|
||||
const payees: PayeeEntity[] = await send('common-payees-get');
|
||||
return payees;
|
||||
return translatePayees(payees) as PayeeEntity[];
|
||||
},
|
||||
{
|
||||
condition: (_, { getState }) => {
|
||||
@@ -131,7 +144,7 @@ export const reloadCommonPayees = createAppAsyncThunk(
|
||||
`${sliceName}/reloadCommonPayees`,
|
||||
async () => {
|
||||
const payees: PayeeEntity[] = await send('common-payees-get');
|
||||
return payees;
|
||||
return translatePayees(payees) as PayeeEntity[];
|
||||
},
|
||||
);
|
||||
|
||||
@@ -139,7 +152,7 @@ export const getPayees = createAppAsyncThunk(
|
||||
`${sliceName}/getPayees`,
|
||||
async () => {
|
||||
const payees: PayeeEntity[] = await send('payees-get');
|
||||
return payees;
|
||||
return translatePayees(payees) as PayeeEntity[];
|
||||
},
|
||||
{
|
||||
condition: (_, { getState }) => {
|
||||
@@ -156,7 +169,7 @@ export const reloadPayees = createAppAsyncThunk(
|
||||
`${sliceName}/reloadPayees`,
|
||||
async () => {
|
||||
const payees: PayeeEntity[] = await send('payees-get');
|
||||
return payees;
|
||||
return translatePayees(payees) as PayeeEntity[];
|
||||
},
|
||||
);
|
||||
|
||||
@@ -164,18 +177,21 @@ export const getActivePayees = memoizeOne(
|
||||
(payees: PayeeEntity[], accounts: AccountEntity[]) => {
|
||||
const accountsById = getAccountsById(accounts);
|
||||
|
||||
return payees.filter(payee => {
|
||||
if (payee.transfer_acct) {
|
||||
const account = accountsById[payee.transfer_acct];
|
||||
return account != null && !account.closed;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return translatePayees(
|
||||
payees.filter(payee => {
|
||||
if (payee.transfer_acct) {
|
||||
const account = accountsById[payee.transfer_acct];
|
||||
return account != null && !account.closed;
|
||||
}
|
||||
return true;
|
||||
}) as PayeeEntity[],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
export const getPayeesById = memoizeOne(
|
||||
(payees: PayeeEntity[] | null | undefined) => groupById(payees),
|
||||
(payees: PayeeEntity[] | null | undefined) =>
|
||||
groupById(translatePayees(payees)),
|
||||
);
|
||||
|
||||
export const { name, reducer, getInitialState } = payeesSlice;
|
||||
@@ -195,14 +211,14 @@ function _loadCommonPayees(
|
||||
state: PayeesState,
|
||||
commonPayees: PayeesState['commonPayees'],
|
||||
) {
|
||||
state.commonPayees = commonPayees;
|
||||
state.commonPayees = translatePayees(commonPayees) as PayeeEntity[];
|
||||
state.isCommonPayeesLoading = false;
|
||||
state.isCommonPayeesLoaded = true;
|
||||
state.isCommonPayeesDirty = false;
|
||||
}
|
||||
|
||||
function _loadPayees(state: PayeesState, payees: PayeesState['payees']) {
|
||||
state.payees = payees;
|
||||
state.payees = translatePayees(payees) as PayeeEntity[];
|
||||
state.isPayeesLoading = false;
|
||||
state.isPayeesLoaded = true;
|
||||
state.isPayeesDirty = false;
|
||||
|
||||
7
upcoming-release-notes/5812.md
Normal file
7
upcoming-release-notes/5812.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [lelemm]
|
||||
---
|
||||
|
||||
Add more translations to enhance multilingual support across the application.
|
||||
|
||||
Reference in New Issue
Block a user