From ae336199a2f4ae8929361eb0d83f1b892bd5a1a8 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Wed, 17 Jan 2024 10:33:44 -0800 Subject: [PATCH] chore: update translations --- .../calendar-table.component.ts | 45 +++++++------- .../create-calendar.component.html | 62 ++++++++++++------- libs/i18n/assets/en.json | 2 +- libs/i18n/src/generate.ts | 5 +- libs/i18n/templates/_template.csv | 2 +- libs/i18n/templates/_template.json | 8 +-- libs/utils/angular.ts | 11 +--- package.json | 2 +- yarn.lock | 42 ++++++++++++- 9 files changed, 110 insertions(+), 69 deletions(-) diff --git a/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/calender-table/calendar-table.component.ts b/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/calender-table/calendar-table.component.ts index 4a79b4c56..3e7806b46 100644 --- a/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/calender-table/calendar-table.component.ts +++ b/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/calender-table/calendar-table.component.ts @@ -17,13 +17,11 @@ import { SeasonCalenderService } from './../../services/calender.data.service'; export class CalendarTableComponent implements OnInit { calendarData: any; months: string[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September']; - // crops: string[] = ['Maize', 'Beans', 'Peas']; selectedCrop = ''; customCrop = ''; showCropAdder = false; userCropNames: string[] = []; - constructor( private route: ActivatedRoute, private dialog: MatDialog, @@ -33,10 +31,9 @@ export class CalendarTableComponent implements OnInit { ) {} async ngOnInit() { - await this.service.ready(); this.route.params.subscribe((params) => { - const {id} = params; + const { id } = params; if (id) { this.fetchData(id) .then((resData) => { @@ -137,32 +134,32 @@ export class CalendarTableComponent implements OnInit { if (cropIndex !== -1) { this.calendarData.crops.splice(cropIndex, 1); //update db - this.autoDbUpdate() + this.autoDbUpdate(); } } }); } - autoDbUpdate(){ - //upadate db - this.service.addORUpdateData(this.calendarData, 'update'); - //refreash crop names - this.userCropNames = this.calendarData.crops.map((crop: any) => crop.name); + autoDbUpdate() { + //upadate db + this.service.addORUpdateData(this.calendarData, 'update'); + //refreash crop names + this.userCropNames = this.calendarData.crops.map((crop: any) => crop.name); } - + addNewCrop() { - for(let i =0; i ({ - month: monthData.month, - activities: [], - })), - extraInformation: '', - }; - this.calendarData.crops.push(newCrop); - } + for (let i = 0; i < this.userCropNames.length; i++) + //skip crops that already exist + if (!this.isCropNameDuplicate(this.userCropNames[i])) { + const newCrop: Crop = { + name: this.userCropNames[i], + months: this.calendarData.timeAndConditions.map((monthData) => ({ + month: monthData.month, + activities: [], + })), + extraInformation: '', + }; + this.calendarData.crops.push(newCrop); + } this.autoDbUpdate(); this.showCropAdder = false; } diff --git a/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/create-calendar/create-calendar.component.html b/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/create-calendar/create-calendar.component.html index 29fd4c3a7..c06bc370d 100644 --- a/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/create-calendar/create-calendar.component.html +++ b/apps/picsa-tools/seasonal-calendar-tool/src/app/pages/create-calendar/create-calendar.component.html @@ -1,47 +1,59 @@
-

{{'Crops Seasonal calender' | translate }}

+

{{ 'Crops Seasonal calender' | translate }}

-

{{'Calender name' | translate}}

- - +

{{ 'Calender name' | translate }}

+ +
-

{{"Season Crops" | translate}}

+

{{ 'Season Crops' | translate }}

- +
-

{{'Calendar Time' | translate}}

+

{{ 'Calendar Time' | translate }}

-
- - +
+ + +
+ +
- - -
-
-
- - +
+
+ + +
+ +
- - -

{{ "Enter the selected month's weather condition" | translate }}

@@ -54,7 +66,9 @@

{{ "Enter the selected month's weather con

- +

{{ message | translate }}

diff --git a/libs/i18n/assets/en.json b/libs/i18n/assets/en.json index 750247245..8c406a0b5 100644 --- a/libs/i18n/assets/en.json +++ b/libs/i18n/assets/en.json @@ -198,6 +198,7 @@ "Cassava": "Cassava", "Cotton": "Cotton", "Cowpeas": "Cowpeas", + "Demo": "Demo", "Edit Profiles": "Edit Profiles", "Extension": "Extension", "Farmer": "Farmer", @@ -226,7 +227,6 @@ "Crop probabilities depend on when the season starts.\nHere you can see the probabilities of the season starting at different dates": "Crop probabilities depend on when the season starts.\nHere you can see the probabilities of the season starting at different dates", "Crop water requirement (mm)": "Crop water requirement (mm)", "Days to maturity": "Days to maturity", - "Demo": "Demo", "Each row contains information about crop, variety, days to maturity and water requirement. Probabilities of receiving requirements are shown for different planting dates": "Each row contains information about crop, variety, days to maturity and water requirement. Probabilities of receiving requirements are shown for different planting dates", "Here we can see information for a specific crop variety": "Here we can see information for a specific crop variety", "In the crop information table, you will be able to see the probabilities for different crops through the different seasons.": "In the crop information table, you will be able to see the probabilities for different crops through the different seasons.", diff --git a/libs/i18n/src/generate.ts b/libs/i18n/src/generate.ts index cb28d8f19..fa09c27ce 100644 --- a/libs/i18n/src/generate.ts +++ b/libs/i18n/src/generate.ts @@ -1,6 +1,5 @@ -import { arrayToHashmap } from '@picsa/utils'; +import { arrayToHashmap } from '@picsa/utils/data'; import { spawnSync } from 'child_process'; -// import { spawnSync } from 'child_process'; import { emptyDirSync, ensureDirSync, @@ -15,7 +14,7 @@ import { tmpdir } from 'os'; import { resolve } from 'path'; import { EXTRACTED_PROJECTS, HARDCODED_DATA } from './hardcoded'; -import { ITranslationEntry } from './types'; +import type { ITranslationEntry } from './types'; const I18N_DIR = resolve(__dirname, '../'); const PROJECT_ROOT = resolve(I18N_DIR, '../../'); diff --git a/libs/i18n/templates/_template.csv b/libs/i18n/templates/_template.csv index 45341007f..375637627 100644 --- a/libs/i18n/templates/_template.csv +++ b/libs/i18n/templates/_template.csv @@ -198,6 +198,7 @@ tool,context,text "common",,"Cassava" "common",,"Cotton" "common",,"Cowpeas" +"common",,"Demo" "common",,"Edit Profiles" "common",,"Extension" "common",,"Farmer" @@ -226,7 +227,6 @@ tool,context,text "crop-probability",,"Crop probabilities depend on when the season starts.\nHere you can see the probabilities of the season starting at different dates" "crop-probability",,"Crop water requirement (mm)" "crop-probability",,"Days to maturity" -"crop-probability",,"Demo" "crop-probability",,"Each row contains information about crop, variety, days to maturity and water requirement. Probabilities of receiving requirements are shown for different planting dates" "crop-probability",,"Here we can see information for a specific crop variety" "crop-probability",,"In the crop information table, you will be able to see the probabilities for different crops through the different seasons." diff --git a/libs/i18n/templates/_template.json b/libs/i18n/templates/_template.json index c22d663f9..3167cc03a 100644 --- a/libs/i18n/templates/_template.json +++ b/libs/i18n/templates/_template.json @@ -927,6 +927,10 @@ "text": "Cowpeas", "tool": "common" }, + { + "text": "Demo", + "tool": "common" + }, { "text": "Edit Profiles", "tool": "common" @@ -1039,10 +1043,6 @@ "text": "Days to maturity", "tool": "crop-probability" }, - { - "text": "Demo", - "tool": "crop-probability" - }, { "text": "Each row contains information about crop, variety, days to maturity and water requirement. Probabilities of receiving requirements are shown for different planting dates", "tool": "crop-probability" diff --git a/libs/utils/angular.ts b/libs/utils/angular.ts index 188c23ba8..e7555d708 100644 --- a/libs/utils/angular.ts +++ b/libs/utils/angular.ts @@ -1,11 +1,5 @@ -import { - NavigationEnd, - type ActivatedRoute, - type ActivatedRouteSnapshot, - type Params, - type Route, - type Router, -} from '@angular/router'; +import { NavigationEnd } from '@angular/router'; +import type { ActivatedRoute, ActivatedRouteSnapshot, Route, Router } from '@angular/router'; import { filter, map, startWith } from 'rxjs'; export function throwIfAlreadyLoaded(parentModule: any, moduleName: string) { @@ -58,7 +52,6 @@ function mergeRouterSnapshots(router: Router) { * Subscribe to snapshot across all active routers * This may be useful in cases where a service wants to subscribe to route parameter changes * (default behaviour would only detect changes to top-most route) - * * Adapted from https://github.com/angular/angular/issues/46891#issuecomment-1190590046 */ export function ngRouterMergedSnapshot$(router: Router) { diff --git a/package.json b/package.json index 437dc9808..8cf0cc56a 100644 --- a/package.json +++ b/package.json @@ -185,7 +185,7 @@ "supabase": "1.115.4", "tailwindcss": "^3.0.2", "ts-jest": "29.1.1", - "ts-node": "10.9.1", + "ts-node": "10.9.2", "typescript": "5.2.2" }, "packageManager": "yarn@3.6.3", diff --git a/yarn.lock b/yarn.lock index 7eeeaaac2..5cfed63ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16472,7 +16472,7 @@ __metadata: "leaflet-draw@github:enketo/Leaflet.draw#ff730785db7fcccbf2485ffcf4dffe1238a7c617": version: 1.0.4 resolution: "leaflet-draw@https://github.com/enketo/Leaflet.draw.git#commit=ff730785db7fcccbf2485ffcf4dffe1238a7c617" - checksum: 253998170af27f886d05b245c85429767e272647221daaf8d94ff5b86f75b8cbb96cc76a8a88492243166a214bc3b66b3ae704a81f74c862f09ac6c9495f731e + checksum: b08b88994769667f11f2b6a8937656c89cea34dafd4661abab0b48b4b97f3bddbdce7b23ddfdb8d7c6335e065530e32a70e281314afa34afa134bf68597945fc languageName: node linkType: hard @@ -19086,7 +19086,7 @@ __metadata: supabase: 1.115.4 tailwindcss: ^3.0.2 ts-jest: 29.1.1 - ts-node: 10.9.1 + ts-node: 10.9.2 tslib: ^2.5.0 typescript: 5.2.2 zone.js: 0.14.2 @@ -22179,6 +22179,44 @@ __metadata: languageName: node linkType: hard +"ts-node@npm:10.9.2": + version: 10.9.2 + resolution: "ts-node@npm:10.9.2" + dependencies: + "@cspotcode/source-map-support": ^0.8.0 + "@tsconfig/node10": ^1.0.7 + "@tsconfig/node12": ^1.0.7 + "@tsconfig/node14": ^1.0.0 + "@tsconfig/node16": ^1.0.2 + acorn: ^8.4.1 + acorn-walk: ^8.1.1 + arg: ^4.1.0 + create-require: ^1.1.0 + diff: ^4.0.1 + make-error: ^1.1.1 + v8-compile-cache-lib: ^3.0.1 + yn: 3.1.1 + peerDependencies: + "@swc/core": ">=1.2.50" + "@swc/wasm": ">=1.2.50" + "@types/node": "*" + typescript: ">=2.7" + peerDependenciesMeta: + "@swc/core": + optional: true + "@swc/wasm": + optional: true + bin: + ts-node: dist/bin.js + ts-node-cwd: dist/bin-cwd.js + ts-node-esm: dist/bin-esm.js + ts-node-script: dist/bin-script.js + ts-node-transpile-only: dist/bin-transpile.js + ts-script: dist/bin-script-deprecated.js + checksum: fde256c9073969e234526e2cfead42591b9a2aec5222bac154b0de2fa9e4ceb30efcd717ee8bc785a56f3a119bdd5aa27b333d9dbec94ed254bd26f8944c67ac + languageName: node + linkType: hard + "tsconfig-paths-webpack-plugin@npm:4.0.0": version: 4.0.0 resolution: "tsconfig-paths-webpack-plugin@npm:4.0.0"