@@ -5,6 +5,7 @@ import * as db from '../db';
5
5
6
6
import { setBudget , getSheetValue , setGoal } from './actions' ;
7
7
import { parse } from './cleanup-template.pegjs' ;
8
+ import { useTranslation } from 'react-i18next' ;
8
9
9
10
export function cleanupTemplate ( { month } : { month : string } ) {
10
11
return processCleanup ( month ) ;
@@ -113,7 +114,8 @@ async function applyGroupCleanups(
113
114
} ) ;
114
115
}
115
116
} else {
116
- warnings . push ( groupName + ' has no matching sink categories.' ) ;
117
+ warnings . push ( t ( '{{groupname}} has no matching sink categories.' ,
118
+ { groupname : groupName } ) ) ;
117
119
}
118
120
sourceGroups = sourceGroups . filter ( c => c . group !== groupName ) ;
119
121
groupLength = sourceGroups . length ;
@@ -218,7 +220,8 @@ async function processCleanup(month: string): Promise<Notification> {
218
220
} ) ;
219
221
num_sources += 1 ;
220
222
} 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 } ) ) ;
222
225
}
223
226
const carryover = await db . first (
224
227
`SELECT carryover FROM zero_budgets WHERE month = ? and category = ?` ,
@@ -285,7 +288,7 @@ async function processCleanup(month: string): Promise<Notification> {
285
288
286
289
const budgetAvailable = await getSheetValue ( sheetName , `to-budget` ) ;
287
290
if ( budgetAvailable <= 0 ) {
288
- warnings . push ( 'Global: No funds are available to reallocate.' ) ;
291
+ warnings . push ( t ( 'Global: No funds are available to reallocate.' ) ) ;
289
292
}
290
293
291
294
//fill sinking categories
@@ -320,35 +323,36 @@ async function processCleanup(month: string): Promise<Notification> {
320
323
return {
321
324
type : 'error' ,
322
325
sticky : true ,
323
- message : 'There were errors interpreting some templates:' ,
326
+ message : t ( 'There were errors interpreting some templates:' ) ,
324
327
pre : errors . join ( '\n\n' ) ,
325
328
} ;
326
329
} else if ( warnings . length ) {
327
330
return {
328
331
type : 'warning' ,
329
- message : 'Global: Funds not available:' ,
332
+ message : t ( 'Global: Funds not available:' ) ,
330
333
pre : warnings . join ( '\n\n' ) ,
331
334
} ;
332
335
} else {
333
336
return {
334
337
type : 'message' ,
335
- message : 'All categories were up to date.' ,
338
+ message : t ( 'All categories were up to date.' ) ,
336
339
} ;
337
340
}
338
341
} 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 } ) ;
342
345
if ( errors . length ) {
343
346
return {
344
347
sticky : true ,
345
- message : `${ applied } There were errors interpreting some templates:` ,
348
+ message : applied + ' ' +
349
+ t ( 'There were errors interpreting some templates:' ) ,
346
350
pre : errors . join ( '\n\n' ) ,
347
351
} ;
348
352
} else if ( warnings . length ) {
349
353
return {
350
354
type : 'warning' ,
351
- message : 'Global: Funds not available:' ,
355
+ message : t ( 'Global: Funds not available:' ) ,
352
356
pre : warnings . join ( '\n\n' ) ,
353
357
} ;
354
358
} else {
0 commit comments