Skip to content

Commit

Permalink
chore: update translations
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Jan 17, 2024
1 parent b219d73 commit ae33619
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) => {
Expand Down Expand Up @@ -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<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);
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,59 @@
<div class="container">
<h2>{{'Crops Seasonal calender' | translate }}</h2>
<h2>{{ 'Crops Seasonal calender' | translate }}</h2>
<div class="box">
<h2>{{'Calender name' | translate}}</h2>
<input class="inputField" [(ngModel)]="calenderTitle" placeholder="Season of 85" />
<seasonal-calendar-error-display [displayError]="showMessageFlag && calenderTitle===''" errorMsg="Please add the calender title">
<h2>{{ 'Calender name' | translate }}</h2>
<input class="inputField" [(ngModel)]="calenderTitle" placeholder="Season of 85" />
<seasonal-calendar-error-display
[displayError]="showMessageFlag && calenderTitle === ''"
errorMsg="Please add the calender title"
>
</seasonal-calendar-error-display>
</div>

<!-- Crops -->
<div class="box">
<h2>{{"Season Crops" | translate}}</h2>
<h2>{{ 'Season Crops' | translate }}</h2>
<div class="select-box">
<div class="select-input-field">
<picsa-form-crop-select [(ngModel)]="userCrops"></picsa-form-crop-select>
</div>
<seasonal-calendar-error-display [displayError]="showMessageFlag && userCrops.length<1" errorMsg="Please select a crop">
<seasonal-calendar-error-display
[displayError]="showMessageFlag && userCrops.length < 1"
errorMsg="Please select a crop"
>
</seasonal-calendar-error-display>
</div>
</div>

<!-- Calendar Time -->
<div>
<h2>{{'Calendar Time' | translate}}</h2>
<h2>{{ 'Calendar Time' | translate }}</h2>
<div class="calender-box">
<div>
<div class="form-group">
<label for="startMonth">{{'Start Month '| translate}} :</label>
<select id="startMonth" [(ngModel)]="startMonth">
<option value="" disabled selected>{{'Select start month' | translate}}</option>
<option *ngFor="let month of months" [value]="month">{{ month }}</option>
</select>
<div class="form-group">
<label for="startMonth">{{ 'Start Month ' | translate }} :</label>
<select id="startMonth" [(ngModel)]="startMonth">
<option value="" disabled selected>{{ 'Select start month' | translate }}</option>
<option *ngFor="let month of months" [value]="month">{{ month }}</option>
</select>
</div>
<seasonal-calendar-error-display
[displayError]="showMessageFlag && startMonth === ''"
errorMsg="Please select a start month"
>
</seasonal-calendar-error-display>
</div>
<seasonal-calendar-error-display [displayError]="showMessageFlag && startMonth ===''" errorMsg="Please select a start month">
</seasonal-calendar-error-display>
</div>
<div>
<div class="form-group">
<label for="numberOfMonths">{{ 'Number of Months Needed' | translate }}:</label>
<input type="number" class="inputField" id="numberOfMonths" [(ngModel)]="numMonths" />
<div>
<div class="form-group">
<label for="numberOfMonths">{{ 'Number of Months Needed' | translate }}:</label>
<input type="number" class="inputField" id="numberOfMonths" [(ngModel)]="numMonths" />
</div>
<seasonal-calendar-error-display
[displayError]="showMessageFlag && numMonths < 1"
errorMsg="Please enter the required number of months"
>
</seasonal-calendar-error-display>
</div>
<seasonal-calendar-error-display [displayError]="showMessageFlag && numMonths <1 " errorMsg="Please enter the required number of months">
</seasonal-calendar-error-display>
</div>
</div>
<h4 *ngIf="calendarMonths.length > 0">{{ "Enter the selected month's weather condition" | translate }}</h4>
<div class="monthsGrid">
Expand All @@ -54,7 +66,9 @@ <h4 *ngIf="calendarMonths.length > 0">{{ "Enter the selected month's weather con
</div>
</div>
<div class="submit-button">
<button class="" mat-button mat-raised-button (click)="onSubmition()" color="primary">{{'Create calender '| translate }}</button>
<button class="" mat-button mat-raised-button (click)="onSubmition()" color="primary">
{{ 'Create calender ' | translate }}
</button>
</div>
<div class="flag-message" *ngIf="showMessageFlag">
<p>{{ message | translate }}</p>
Expand Down
2 changes: 1 addition & 1 deletion libs/i18n/assets/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
"Cassava": "Cassava",
"Cotton": "Cotton",
"Cowpeas": "Cowpeas",
"Demo": "Demo",
"Edit Profiles": "Edit Profiles",
"Extension": "Extension",
"Farmer": "Farmer",
Expand Down Expand Up @@ -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.",
Expand Down
5 changes: 2 additions & 3 deletions libs/i18n/src/generate.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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, '../../');
Expand Down
2 changes: 1 addition & 1 deletion libs/i18n/templates/_template.csv
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ tool,context,text
"common",,"Cassava"
"common",,"Cotton"
"common",,"Cowpeas"
"common",,"Demo"
"common",,"Edit Profiles"
"common",,"Extension"
"common",,"Farmer"
Expand Down Expand Up @@ -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."
Expand Down
8 changes: 4 additions & 4 deletions libs/i18n/templates/_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,10 @@
"text": "Cowpeas",
"tool": "common"
},
{
"text": "Demo",
"tool": "common"
},
{
"text": "Edit Profiles",
"tool": "common"
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 2 additions & 9 deletions libs/utils/angular.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
Expand Down
42 changes: 40 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit ae33619

Please sign in to comment.