Skip to content

Commit 9a4c1e1

Browse files
MMwandighatuxpiper
authored andcommitted
[USH-1699] Identify unlocalized strings in the web client and add them to en.json (#1494)
* Translations - Breadcrumbs * Translations - Login/Authentication * Translations: Post timelines, posts loading message, date shows up here text * Reverting timeline translations for now * Translation: OK Button, Uploading, Activty View * Translation: Data source subheading * Slight adjustment to solve 'Add webhook' json file conflicts * Translations: Survey & General Confirm Modal, snackbar, Survey Colorpicker, default settings header * Translations: Activity page * Translations: Adding more strings into en.json for map view options * Translations: Onboarding modals * Translations: Sources Filters * Translations: Timelines for post metadata and post conversations * Just a slight fix * Translations: showError() in survey-item, user-settings components and polling service * Translations: Close button in all snackbars * Translations: Location Select strings * Translations: Image uploader special characters text * Translations: Post edit component * Translations: Post not authorized to edit * Translations: Remaining strings * Renamed 'displayNane' to 'displayName'
1 parent 26681fe commit 9a4c1e1

File tree

45 files changed

+371
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+371
-164
lines changed

apps/web-mzima-client/src/app/activity/activity-timeline/activity-timeline.component.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { PostsService } from '@mzima-client/sdk';
3+
import { TranslateService } from '@ngx-translate/core';
34
import { LegendPosition, ScaleType } from '@swimlane/ngx-charts';
45
import { Color } from '@swimlane/ngx-charts/lib/utils/color-sets';
56
import { ManipulateType } from 'dayjs';
@@ -33,18 +34,23 @@ export class ActivityTimelineComponent implements OnInit {
3334
};
3435
public cumulativeTotal = true;
3536
public dateRange: ManipulateType;
36-
public filters = [
37-
{ displayNane: 'Show all posts', value: '' },
38-
{ displayNane: 'Categories', value: 'tags' },
39-
{ displayNane: 'Survey', value: 'form' },
40-
{ displayNane: 'Status', value: 'status' },
41-
];
37+
public filters: { displayName: string; value: string }[] = [];
4238

43-
constructor(private postsService: PostsService) {}
39+
constructor(private postsService: PostsService, private translate: TranslateService) {
40+
this.initializeFilters();
41+
}
4442

4543
ngOnInit() {
4644
this.getPostStatistics(this.selectedFilter);
4745
}
46+
private initializeFilters() {
47+
this.filters = [
48+
{ displayName: this.translate.instant('activity.show_all_posts'), value: '' },
49+
{ displayName: this.translate.instant('activity.categories'), value: 'tags' },
50+
{ displayName: this.translate.instant('activity.survey'), value: 'form' },
51+
{ displayName: this.translate.instant('activity.status'), value: 'status' },
52+
];
53+
}
4854

4955
public getPostStatistics(value: string) {
5056
const params = {

apps/web-mzima-client/src/app/activity/bar-chart/bar-chart.component.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { PostsService } from '@mzima-client/sdk';
3+
import { TranslateService } from '@ngx-translate/core';
34
import { ScaleType } from '@swimlane/ngx-charts';
45
import { Color } from '@swimlane/ngx-charts/lib/utils/color-sets';
56
import { ManipulateType } from 'dayjs';
@@ -19,18 +20,24 @@ export class BarChartComponent implements OnInit {
1920
domain: ['#FFEBBB'],
2021
};
2122
public dateRange: ManipulateType;
22-
public filters = [
23-
{ displayNane: 'Categories', value: 'tags' },
24-
{ displayNane: 'Survey', value: 'form' },
25-
{ displayNane: 'Status', value: 'status' },
26-
];
23+
public filters: { displayName: string; value: string }[] = [];
2724

28-
constructor(private postsService: PostsService) {}
25+
constructor(private postsService: PostsService, private translate: TranslateService) {
26+
this.initializeFilters();
27+
}
2928

3029
public ngOnInit() {
3130
this.getPostStatistics(this.selectedFilter);
3231
}
3332

33+
private initializeFilters() {
34+
this.filters = [
35+
{ displayName: this.translate.instant('activity.categories'), value: 'tags' },
36+
{ displayName: this.translate.instant('activity.survey'), value: 'form' },
37+
{ displayName: this.translate.instant('activity.status'), value: 'status' },
38+
];
39+
}
40+
3441
public getPostStatistics(value: any) {
3542
this.data = [];
3643
this.postsService.getPostStatistics({ group_by: value }).subscribe({

apps/web-mzima-client/src/app/activity/chart-head/chart-head.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ <h1>{{ title }}</h1>
66
<mat-select
77
name="filter"
88
disableOptionCentering
9-
placeholder="Select range"
9+
placeholder="{{ 'activity.select_range' | translate }}"
1010
[(ngModel)]="selectedRange"
1111
(selectionChange)="rangeChange($event)"
1212
>
1313
<mat-option [value]="filter.value" *ngFor="let filter of ranges">
14-
{{ filter.displayNane }}
14+
{{ filter.displayName }}
1515
</mat-option>
1616
</mat-select>
1717
</mat-form-field>
@@ -22,12 +22,12 @@ <h1>{{ title }}</h1>
2222
<mat-select
2323
name="filter"
2424
disableOptionCentering
25-
placeholder="Select filter"
25+
placeholder="{{ 'activity.select_filter' | translate }}"
2626
[(ngModel)]="selectedFilter"
2727
(selectionChange)="change($event)"
2828
>
2929
<mat-option [value]="filter.value" *ngFor="let filter of filters">
30-
{{ filter.displayNane }}
30+
{{ filter.displayName }}
3131
</mat-option>
3232
</mat-select>
3333
</mat-form-field>

apps/web-mzima-client/src/app/activity/chart-head/chart-head.component.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, EventEmitter, Input, Output } from '@angular/core';
22
import { MatSelectChange } from '@angular/material/select';
33
import { ManipulateType } from 'dayjs';
4+
import { TranslateService } from '@ngx-translate/core';
45

56
@Component({
67
selector: 'app-chart-head',
@@ -14,13 +15,20 @@ export class ChartHeadComponent {
1415
@Input() public selectedRange: ManipulateType;
1516
@Output() public filterChanged = new EventEmitter();
1617
@Output() public dateChanged = new EventEmitter();
18+
public ranges: { displayName: string; value: string | null }[] = [];
1719

18-
public ranges = [
19-
{ displayNane: 'All time', value: null },
20-
{ displayNane: 'Last week', value: 'w' },
21-
{ displayNane: 'Last month', value: 'm' },
22-
{ displayNane: 'Last year', value: 'y' },
23-
];
20+
constructor(private translate: TranslateService) {
21+
this.initializeRanges();
22+
}
23+
24+
private initializeRanges() {
25+
this.ranges = [
26+
{ displayName: this.translate.instant('activity.all_time'), value: null },
27+
{ displayName: this.translate.instant('activity.last_week'), value: 'w' },
28+
{ displayName: this.translate.instant('activity.last_month'), value: 'm' },
29+
{ displayName: this.translate.instant('activity.last_year'), value: 'y' },
30+
];
31+
}
2432

2533
public rangeChange(event: MatSelectChange): void {
2634
this.dateChanged.emit(event.value);

apps/web-mzima-client/src/app/auth/auth-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
33
import { ResetComponent } from '@auth';
44

55
const routes: Routes = [
6-
{ path: '', component: ResetComponent, data: { breadcrumb: 'Password recovery' } },
6+
{ path: '', component: ResetComponent, data: { breadcrumb: 'nav.password_recovery' } },
77
];
88

99
@NgModule({

apps/web-mzima-client/src/app/auth/reset/reset.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="form-page">
22
<div class="restore-password-form">
33
<ng-container *ngIf="!isPasswordRestored; else success">
4-
<h1>Enter your new password</h1>
4+
<h1>{{ 'user.enter_new_password' | translate }}</h1>
55
<app-restore-password-form (passwordRestored)="passwordRestored()">
66
</app-restore-password-form>
77
</ng-container>
@@ -12,8 +12,8 @@ <h1>Enter your new password</h1>
1212
<div class="success-msg">
1313
<app-lottie-animation class="visual" [path]="'/assets/lottie/success-animation.json'">
1414
</app-lottie-animation>
15-
<strong mat-dialog-title>Your password was successfully changed</strong>
16-
<p>Now you can login with new credentials</p>
15+
<strong mat-dialog-title>{{ 'user.password_change_success' | translate }}</strong>
16+
<p>{{ 'user.password_change_success_info' | translate }}</p>
1717
<mzima-client-button type="button" (buttonClick)="openLoginModal()" [expand]="false">
1818
{{ 'nav.login' | translate }}
1919
</mzima-client-button>

apps/web-mzima-client/src/app/core/handlers/errors-handler.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TranslateService } from '@ngx-translate/core';
55

66
@Injectable()
77
export class ErrorsHandlerService implements ErrorHandler {
8-
constructor(private injector: Injector) {}
8+
constructor(private injector: Injector, private translate: TranslateService) {}
99

1010
handleError(error: Error | HttpErrorResponse) {
1111
const translate = this.injector.get(TranslateService);
@@ -29,6 +29,9 @@ export class ErrorsHandlerService implements ErrorHandler {
2929

3030
private showError(message: string) {
3131
const snackBar = this.injector.get(MatSnackBar);
32-
snackBar.open(message, 'Close', { panelClass: ['error'], duration: 3000 });
32+
snackBar.open(message, this.translate.instant('notify.snackbar.close'), {
33+
panelClass: ['error'],
34+
duration: 3000,
35+
});
3336
}
3437
}

apps/web-mzima-client/src/app/core/helpers/search-form.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,43 @@ export const loggedOutStatuses = [statuses[0]];
2222

2323
export const sources = [
2424
{
25-
name: 'Web',
25+
name: 'global_filter.sources.web',
2626
value: 'web',
2727
total: 0,
2828
checked: true,
2929
},
3030
{
31-
name: 'Mobile',
31+
name: 'global_filter.sources.mobile',
3232
value: 'mobile',
3333
total: 0,
3434
checked: true,
3535
},
3636
{
37-
name: 'Email',
37+
name: 'global_filter.sources.email',
3838
value: 'email',
3939
total: 0,
4040
checked: true,
4141
},
4242
{
43-
name: 'SMS',
43+
name: 'global_filter.sources.sms',
4444
value: 'sms',
4545
total: 0,
4646
checked: true,
4747
},
4848
{
49-
name: 'Twitter',
49+
name: 'global_filter.sources.twitter',
5050
value: 'twitter',
5151
total: 0,
5252
checked: true,
5353
},
5454
{
55-
name: 'USSD',
55+
name: 'global_filter.sources.ussd',
5656
value: 'ussd',
5757
total: 0,
5858
checked: true,
5959
},
6060
{
61-
name: 'WhatsApp',
61+
name: 'global_filter.sources.whatsapp',
6262
value: 'whatsapp',
6363
total: 0,
6464
checked: true,
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
import { Pipe, PipeTransform } from '@angular/core';
2+
import { TranslateService } from '@ngx-translate/core';
3+
24
@Pipe({
35
name: 'dateAgo',
46
})
57
export class DateAgoPipe implements PipeTransform {
8+
constructor(private translate: TranslateService) {}
69
transform(value: any): unknown {
710
if (!value) {
8-
return 'a long time ago';
11+
return this.translate.instant('date.aLongTimeAgo');
912
}
1013
let time = (Date.now() - Date.parse(value)) / 1000;
1114
if (time < 10) {
12-
return 'just now';
15+
return this.translate.instant('date.justNow');
1316
} else if (time < 60) {
14-
return 'a moment ago';
17+
return this.translate.instant('date.aMomentAgo');
1518
}
16-
const divider = [60, 60, 24, 30, 12];
17-
const string = [' second', ' minute', ' hour', ' day', ' month', ' year'];
18-
let i;
19-
for (i = 0; Math.floor(time / divider[i]) > 0; i++) {
20-
time /= divider[i];
19+
20+
const dividers = [60, 60, 24, 30, 12];
21+
const string = ['second', 'minute', 'hour', 'day', 'month', 'year'];
22+
let i = 0;
23+
24+
// Calculate the appropriate unit
25+
while (i < dividers.length && Math.floor(time / dividers[i]) > 0) {
26+
time /= dividers[i];
27+
i++;
2128
}
22-
const plural = Math.floor(time) > 1 ? 's' : '';
23-
return Math.floor(time) + string[i] + plural + ' ago';
29+
30+
const roundedTime = Math.floor(time);
31+
const unit = string[i];
32+
const pluralization = roundedTime > 1 ? 'plural' : 'singular';
33+
34+
// Translate the string based on singular/plural
35+
return this.translate.instant(`date.${unit}.${pluralization}`, { time: roundedTime });
2436
}
2537
}

apps/web-mzima-client/src/app/core/services/notification.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
33
import { SnackbarComponent, SnackbarData } from '../../shared/components';
4+
import { TranslateService } from '@ngx-translate/core';
45

56
export interface SnackbarOptions extends MatSnackBarConfig {
67
wide?: boolean;
@@ -10,10 +11,13 @@ export interface SnackbarOptions extends MatSnackBarConfig {
1011
providedIn: 'root',
1112
})
1213
export class NotificationService {
13-
constructor(public snackBar: MatSnackBar) {}
14+
constructor(public snackBar: MatSnackBar, private translate: TranslateService) {}
1415

1516
showError(message: string) {
16-
this.snackBar.open(message, 'Close', { panelClass: ['error'], duration: 3000 });
17+
this.snackBar.open(message, this.translate.instant('notify.snackbar.close'), {
18+
panelClass: ['error'],
19+
duration: 3000,
20+
});
1721
}
1822

1923
showSnackbar(data?: SnackbarData, options?: SnackbarOptions) {

0 commit comments

Comments
 (0)