From 4e58be8cf0f64cb203d6a0fb80c761914421cae1 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Sat, 15 Apr 2023 17:14:09 -0700 Subject: [PATCH] chore: update translations --- .../budget-tool/src/app/store/budget.store.ts | 141 ++++++------------ libs/i18n/assets/en.json | 2 + libs/i18n/assets/ny.json | 2 + libs/i18n/assets/sw.json | 2 + libs/i18n/assets/tg.json | 2 + libs/i18n/templates/_template.csv | 2 + libs/i18n/templates/_template.json | 8 + 7 files changed, 63 insertions(+), 96 deletions(-) diff --git a/apps/picsa-tools/budget-tool/src/app/store/budget.store.ts b/apps/picsa-tools/budget-tool/src/app/store/budget.store.ts index 90f463b10..cd8db737f 100644 --- a/apps/picsa-tools/budget-tool/src/app/store/budget.store.ts +++ b/apps/picsa-tools/budget-tool/src/app/store/budget.store.ts @@ -1,32 +1,33 @@ import { Injectable, OnDestroy } from '@angular/core'; -import { toJS } from 'mobx'; -import { observable, action, computed } from 'mobx-angular'; +import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; +import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-marker'; +import { ConfigurationService, IConfiguration } from '@picsa/configuration'; +import { APP_VERSION } from '@picsa/environments'; +import { IAppMeta } from '@picsa/models'; +import { generateDBMeta, PicsaDbService } from '@picsa/shared/services/core/db'; +import { generateID } from '@picsa/shared/services/core/db/db.service'; +import { PrintProvider } from '@picsa/shared/services/native/print'; import merge from 'deepmerge'; +import { toJS } from 'mobx'; +import { action, computed, observable } from 'mobx-angular'; +import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; +import { BUDGET_CARDS } from '../data'; import { IBudget, - IBudgetPeriodData, + IBudgetBalance, IBudgetCard, - IBudgetMeta, IBudgetCardDB, IBudgetCardWithValues, - IBudgetValueScale, - IBudgetValueCounters, - IBudgetBalance, - IBudgetPeriodType, IBudgetCodeDoc, + IBudgetMeta, + IBudgetPeriodData, + IBudgetPeriodType, + IBudgetValueCounters, + IBudgetValueScale, } from '../models/budget-tool.models'; import { checkForBudgetUpgrades } from '../utils/budget.upgrade'; -import { NEW_BUDGET_TEMPLATE, MONTHS } from './templates'; -import { BUDGET_CARDS } from '../data'; -import { PicsaDbService, generateDBMeta } from '@picsa/shared/services/core/db'; -import { IAppMeta } from '@picsa/models'; -import { APP_VERSION } from '@picsa/environments'; -import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; -import { ConfigurationService, IConfiguration } from '@picsa/configuration'; -import { PrintProvider } from '@picsa/shared/services/native/print'; -import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; -import { generateID } from '@picsa/shared/services/core/db/db.service'; +import { MONTHS, NEW_BUDGET_TEMPLATE } from './templates'; const TYPE_CARDS_BASE: { [key in IBudgetPeriodType | 'enterprise' | 'other']: IBudgetCard[]; } = { @@ -39,20 +40,14 @@ const TYPE_CARDS_BASE: { other: [], }; const TYPE_LABELS: { [key in IBudgetPeriodType | 'summary']: string } = { - activities: 'Activities', - familyLabour: 'Family Labour', - inputs: 'Inputs', - outputs: 'Outputs', - produceConsumed: 'Produce Consumed', - summary: 'Summary', + activities: translateMarker('Activities'), + familyLabour: translateMarker('Family Labour'), + inputs: translateMarker('Inputs'), + outputs: translateMarker('Outputs'), + produceConsumed: translateMarker('Produce Consumed'), + summary: translateMarker('Summary'), }; -type IBudgetCounter = - | 'large' - | 'large-half' - | 'medium' - | 'medium-half' - | 'small' - | 'small-half'; +type IBudgetCounter = 'large' | 'large-half' | 'medium' | 'medium-half' | 'small' | 'small-half'; export type IBudgetCounterSVGIcons = Record; @Injectable({ @@ -76,9 +71,7 @@ export class BudgetStore implements OnDestroy { // get unique list of types in enterprise cards @computed get enterpriseTypeCards(): IBudgetCardDB[] { console.log('get enterprisetype cards'); - const enterpriseCards = this.budgetCards.filter( - (c) => c.type === 'enterprise' - ); + const enterpriseCards = this.budgetCards.filter((c) => c.type === 'enterprise'); return this._createCardGroupCards(enterpriseCards); } @observable budgetCardsByType = TYPE_CARDS_BASE; @@ -116,12 +109,9 @@ export class BudgetStore implements OnDestroy { ) { this.counterSVGIcons = this.createBudgetCounterSVGs(); // TODO store never destroyed so would be good to limit listeners - this.configurationService.activeConfiguration$ - .pipe(takeUntil(this.destroyed$)) - .subscribe((v) => { - this.settings = - this.configurationService.activeConfiguration.budgetTool; - }); + this.configurationService.activeConfiguration$.pipe(takeUntil(this.destroyed$)).subscribe((v) => { + this.settings = this.configurationService.activeConfiguration.budgetTool; + }); } ngOnDestroy(): void { this.destroyed$.next(true); @@ -133,9 +123,7 @@ export class BudgetStore implements OnDestroy { * ***************************************************************************/ getfilteredEnterprises(grouping: string) { - return this.budgetCards.filter( - (e) => e.type === 'enterprise' && e.groupings?.includes(grouping) - ); + return this.budgetCards.filter((e) => e.type === 'enterprise' && e.groupings?.includes(grouping)); } /************************************************************************** * Budget Values @@ -144,9 +132,7 @@ export class BudgetStore implements OnDestroy { // merge current budget with added data, optionally can merge deep to include // nested properties patchBudget(patch: Partial, deepMerge = false) { - const budget = deepMerge - ? merge(this.activeBudget, patch) - : { ...this.activeBudget, ...patch }; + const budget = deepMerge ? merge(this.activeBudget, patch) : { ...this.activeBudget, ...patch }; this.setActiveBudget(budget); this.saveBudget(); } @@ -192,18 +178,14 @@ export class BudgetStore implements OnDestroy { const svgPaths = { large: 'M479.99952 480.00078c-149.33319.00002-298.66639.00002-447.999582 0C106.66653 330.6673 181.33313 181.33382 255.99974 32.00035c74.66661 149.33347 149.3332 298.66695 223.99978 448.00043Z', - medium: - 'M41.695065 41.695068H470.30496c-.00001 142.869952 0 285.739912 0 428.609862H41.695065V41.695068z', + medium: 'M41.695065 41.695068H470.30496c-.00001 142.869952 0 285.739912 0 428.609862H41.695065V41.695068z', small: 'M460.09621 256c5.02545 132.35505-139.57369 238.73445-264.41078 194.98057C67.841246 416.64296 8.7177668 247.12958 87.552104 140.7586 158.13858 28.727575 337.53963 22.374453 415.87405 129.13175 444.36362 164.8484 460.20746 210.31914 460.09621 256Z', }; for (const [name, path] of Object.entries(svgPaths)) { const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); svg.setAttribute('viewBox', '0 0 512 512'); - const iconPath = document.createElementNS( - 'http://www.w3.org/2000/svg', - 'path' - ); + const iconPath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); iconPath.setAttribute('d', path); iconPath.setAttribute('fill', '#c5ceb2'); iconPath.setAttribute('stroke', '#77933c'); @@ -214,9 +196,7 @@ export class BudgetStore implements OnDestroy { // Create a half-style el where viewbox cuts off half of element const halfEl = svg.cloneNode(true) as SVGElement; halfEl.setAttribute('viewBox', '0 0 256 512'); - svgs[`${name}-half`] = this.sanitizer.bypassSecurityTrustHtml( - halfEl.outerHTML - ); + svgs[`${name}-half`] = this.sanitizer.bypassSecurityTrustHtml(halfEl.outerHTML); } return svgs; } @@ -235,11 +215,7 @@ export class BudgetStore implements OnDestroy { this.setActiveBudget(budget); } async saveBudget() { - await this.db.setDoc( - 'budgetTool/${GROUP}/budgets', - this.activeBudgetValue, - true - ); + await this.db.setDoc('budgetTool/${GROUP}/budgets', this.activeBudgetValue, true); await this.loadSavedBudgets(); } async loadBudgetByKey(key: string) { @@ -254,11 +230,7 @@ export class BudgetStore implements OnDestroy { } } async loadBudgetByShareCode(code: string) { - const codeDoc = await this.db.getDoc( - 'budgetTool/default/shareCodes', - code, - 'server' - ); + const codeDoc = await this.db.getDoc('budgetTool/default/shareCodes', code, 'server'); if (codeDoc) { return this.importBudget(codeDoc.budget_key); } else { @@ -275,31 +247,21 @@ export class BudgetStore implements OnDestroy { } private async loadSavedBudgets(): Promise { - const budgets = await this.db.getCollection( - 'budgetTool/${GROUP}/budgets' - ); - this.savedBudgets = budgets.sort((a, b) => - b._modified > a._modified ? 1 : -1 - ); + const budgets = await this.db.getCollection('budgetTool/${GROUP}/budgets'); + this.savedBudgets = budgets.sort((a, b) => (b._modified > a._modified ? 1 : -1)); } async deleteBudget(budget: IBudget) { await this.db.deleteDocs('budgetTool/${GROUP}/budgets', [budget._key]); if (budget.shareCode) { - await this.db.deleteDocs('budgetTool/default/shareCodes', [ - budget.shareCode, - ]); + await this.db.deleteDocs('budgetTool/default/shareCodes', [budget.shareCode]); } this.loadSavedBudgets(); } /** Duplicate a server budget and save locally */ private async importBudget(key: string): Promise { - const budget: IBudget = await this.db.getDoc( - 'budgetTool/${GROUP}/budgets', - key, - 'server' - ); + const budget: IBudget = await this.db.getDoc('budgetTool/${GROUP}/budgets', key, 'server'); if (budget) { // remove previous share code to allow re-share as new budget if (budget.shareCode) { @@ -317,11 +279,7 @@ export class BudgetStore implements OnDestroy { } public async shareAsImage() { - return this.printPrvdr.shareHtmlDom( - '#budget', - this.activeBudget.meta.title, - this.activeBudget.meta.title - ); + return this.printPrvdr.shareHtmlDom('#budget', this.activeBudget.meta.title, this.activeBudget.meta.title); } public async shareAsLink() { @@ -334,11 +292,7 @@ export class BudgetStore implements OnDestroy { _key: code, budget_key: this.activeBudget._key, }; - await this.db.setDoc( - 'budgetTool/default/shareCodes', - budgetCodeDoc, - true - ); + await this.db.setDoc('budgetTool/default/shareCodes', budgetCodeDoc, true); this.activeBudget.shareCode = code; } await this.saveBudget(); @@ -457,14 +411,9 @@ export class BudgetStore implements OnDestroy { } // group all enterprise cards and create new parent card that will be used to reveal group private _createCardGroupCards(cards: IBudgetCard[]): IBudgetCardDB[] { - const allGroupings: string[][] = cards.map( - (e) => toJS(e.groupings) as string[] - ); + const allGroupings: string[][] = cards.map((e) => toJS(e.groupings) as string[]); // eslint-disable-next-line prefer-spread - const mergedGroupings: string[] = ([] as any).concat.apply( - [], - allGroupings - ); + const mergedGroupings: string[] = ([] as any).concat.apply([], allGroupings); // NOTE - technically Array.from shouldn't be required but current issue with typescript // see https://stackoverflow.com/questions/33464504/using-spread-syntax-and-new-set-with-typescript/33464709 const uniqueGroups = [...Array.from(new Set(mergedGroupings))].sort(); diff --git a/libs/i18n/assets/en.json b/libs/i18n/assets/en.json index 0e8664fd8..5cc4293ea 100644 --- a/libs/i18n/assets/en.json +++ b/libs/i18n/assets/en.json @@ -89,6 +89,7 @@ "Description (optional)": "Description (optional)", "Enterprise": "Enterprise", "Family": "Family", + "Family Labour": "Family Labour", "Female Member": "Female Member", "How long is your budget for?": "How long is your budget for?", "Import Budget Code": "Import Budget Code", @@ -98,6 +99,7 @@ "Male Member": "Male Member", "Next": "Next", "Outputs": "Outputs", + "Produce Consumed": "Produce Consumed", "Quantity": "Quantity", "Save": "Save", "Save your budget": "Save your budget", diff --git a/libs/i18n/assets/ny.json b/libs/i18n/assets/ny.json index 9f129ad9b..98c3aadfe 100644 --- a/libs/i18n/assets/ny.json +++ b/libs/i18n/assets/ny.json @@ -1,8 +1,10 @@ { "Add Female Member": "", "Add Male Member": "", + "Family Labour": "", "Female Member": "", "Male Member": "", + "Produce Consumed": "", "Select Country": "", "Activities": "zochitika", "add custom": "onjezani mwambo", diff --git a/libs/i18n/assets/sw.json b/libs/i18n/assets/sw.json index 25b6df16e..98978f677 100644 --- a/libs/i18n/assets/sw.json +++ b/libs/i18n/assets/sw.json @@ -78,6 +78,7 @@ "End of Season": "Mwisho wa Msimu", "End of season is defined as the last day in the season (1st October - 30th April) with more than 10mm of rainfall.": "Mwisho wa msimu hufafanuliwa kama siku ya mwisho msimu (1 Oktoba - 30 Aprili) na zaidi ya 10mm ya mvua.", "Enterprise": "", + "Family Labour": "Kazi ya Familia", "family labour": "", "feed": "", "feeding livestock": "", @@ -116,6 +117,7 @@ "ploughing": "", "post-harvest handling": "", "pot for storage": "", + "Produce Consumed": "Kuzalisha Iliyotumiwa", "protective equipment": "", "provide supplements": "", "provide water": "", diff --git a/libs/i18n/assets/tg.json b/libs/i18n/assets/tg.json index 6d2cab08b..200becb20 100644 --- a/libs/i18n/assets/tg.json +++ b/libs/i18n/assets/tg.json @@ -78,6 +78,7 @@ "End of Season": "Охири мавсим", "End of season is defined as the last day in the season (1st October - 30th April) with more than 10mm of rainfall.": "Анҷоми мавсим ҳамчун рӯзи охир дар мавсими (1 октябр - 30 апрел) бо зиёда аз 10 миллион боришот муайян карда мешавад.", "Enterprise": "Корхона", + "Family Labour": "Меҳнати оила", "family labour": "меҳнати оила", "feed": "таъом", "feeding livestock": "таъом додани чорводорӣ", @@ -116,6 +117,7 @@ "ploughing": "шудгор кардан", "post-harvest handling": "Мавридҳои ҳосили пас аз", "pot for storage": "дег барои нигаҳдошт", + "Produce Consumed": "Маҳсулоти истеъмолшуда", "protective equipment": "Таҷҳизоти муҳофизатӣ", "provide supplements": "лавозимотро таъмин кунед", "provide water": "Таъмини об", diff --git a/libs/i18n/templates/_template.csv b/libs/i18n/templates/_template.csv index 25803c806..135220467 100644 --- a/libs/i18n/templates/_template.csv +++ b/libs/i18n/templates/_template.csv @@ -89,6 +89,7 @@ tool,context,text "budget",,"Description (optional)" "budget",,"Enterprise" "budget",,"Family" +"budget",,"Family Labour" "budget",,"Female Member" "budget",,"How long is your budget for?" "budget",,"Import Budget Code" @@ -98,6 +99,7 @@ tool,context,text "budget",,"Male Member" "budget",,"Next" "budget",,"Outputs" +"budget",,"Produce Consumed" "budget",,"Quantity" "budget",,"Save" "budget",,"Save your budget" diff --git a/libs/i18n/templates/_template.json b/libs/i18n/templates/_template.json index 9855c4eb4..a232cc744 100644 --- a/libs/i18n/templates/_template.json +++ b/libs/i18n/templates/_template.json @@ -437,6 +437,10 @@ "text": "Family", "tool": "budget" }, + { + "text": "Family Labour", + "tool": "budget" + }, { "text": "Female Member", "tool": "budget" @@ -473,6 +477,10 @@ "text": "Outputs", "tool": "budget" }, + { + "text": "Produce Consumed", + "tool": "budget" + }, { "text": "Quantity", "tool": "budget"