Skip to content

Commit 592c0f0

Browse files
committed
chore: update cleanup-template.ts for i18n
1 parent 58baf74 commit 592c0f0

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

packages/loot-core/src/server/budget/cleanup-template.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as db from '../db';
55

66
import { setBudget, getSheetValue, setGoal } from './actions';
77
import { parse } from './cleanup-template.pegjs';
8+
import { useTranslation } from 'react-i18next';
89

910
export function cleanupTemplate({ month }: { month: string }) {
1011
return processCleanup(month);
@@ -113,7 +114,8 @@ async function applyGroupCleanups(
113114
});
114115
}
115116
} else {
116-
warnings.push(groupName + ' has no matching sink categories.');
117+
warnings.push(t('{{groupname}} has no matching sink categories.',
118+
{ groupname: groupName }));
117119
}
118120
sourceGroups = sourceGroups.filter(c => c.group !== groupName);
119121
groupLength = sourceGroups.length;
@@ -218,7 +220,8 @@ async function processCleanup(month: string): Promise<Notification> {
218220
});
219221
num_sources += 1;
220222
} else {
221-
warnings.push(category.name + ' does not have available funds.');
223+
warnings.push(t('{{name}} does not have available funds.',
224+
{ name: category.name }));
222225
}
223226
const carryover = await db.first(
224227
`SELECT carryover FROM zero_budgets WHERE month = ? and category = ?`,
@@ -285,7 +288,7 @@ async function processCleanup(month: string): Promise<Notification> {
285288

286289
const budgetAvailable = await getSheetValue(sheetName, `to-budget`);
287290
if (budgetAvailable <= 0) {
288-
warnings.push('Global: No funds are available to reallocate.');
291+
warnings.push(t('Global: No funds are available to reallocate.'));
289292
}
290293

291294
//fill sinking categories
@@ -320,35 +323,36 @@ async function processCleanup(month: string): Promise<Notification> {
320323
return {
321324
type: 'error',
322325
sticky: true,
323-
message: 'There were errors interpreting some templates:',
326+
message: t('There were errors interpreting some templates:'),
324327
pre: errors.join('\n\n'),
325328
};
326329
} else if (warnings.length) {
327330
return {
328331
type: 'warning',
329-
message: 'Global: Funds not available:',
332+
message: t('Global: Funds not available:'),
330333
pre: warnings.join('\n\n'),
331334
};
332335
} else {
333336
return {
334337
type: 'message',
335-
message: 'All categories were up to date.',
338+
message: t('All categories were up to date.'),
336339
};
337340
}
338341
} else {
339-
const applied = `Successfully returned funds from ${num_sources} ${
340-
num_sources === 1 ? 'source' : 'sources'
341-
} and funded ${num_sinks} sinking ${num_sinks === 1 ? 'fund' : 'funds'}.`;
342+
const applied = t('Successfully returned funds from {{count}} sources ',
343+
{ count: num_sources }) +
344+
t(' and funded {{count}} sinking funds', { count: num_sinks });
342345
if (errors.length) {
343346
return {
344347
sticky: true,
345-
message: `${applied} There were errors interpreting some templates:`,
348+
message: applied + ' ' +
349+
t('There were errors interpreting some templates:'),
346350
pre: errors.join('\n\n'),
347351
};
348352
} else if (warnings.length) {
349353
return {
350354
type: 'warning',
351-
message: 'Global: Funds not available:',
355+
message: t('Global: Funds not available:'),
352356
pre: warnings.join('\n\n'),
353357
};
354358
} else {

0 commit comments

Comments
 (0)