Skip to content

Commit d164ce1

Browse files
committed
refactor: Translate strings on dialog components
1 parent 0ca961d commit d164ce1

File tree

20 files changed

+46
-138
lines changed

20 files changed

+46
-138
lines changed

projects/hslayers/common/confirm/confirm-dialog.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<div class="modal-content">
44
<div class="modal-header">
55
<h4 class="modal-title">
6-
{{data.title}}
6+
{{data.title | translateHs}}
77
</h4>
88
<button type="button" (click)="no()" class="btn-close" data-dismiss="modal"
99
[attr.aria-label]="'COMMON.close' | translateHs "></button>
1010
</div>
1111
<div class="modal-body" style="overflow-y:auto">
12-
<p class="fw-bold h6">{{data.message}}</p>
13-
<p class="h6 small">{{data.note}}</p>
12+
<p class="fw-bold h6">{{data.message | translateHs}}</p>
13+
<p class="h6 small">{{data.note | translateHs}}</p>
1414
</div>
1515
<div class="modal-footer">
1616
<button type="button" class="btn btn-primary" (click)="yes()" [title]="'COMMON.yes' | translateHs"

projects/hslayers/common/confirm/confirm-dialog.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import {
55
HsDialogContainerService,
66
HsDialogItem,
77
} from 'hslayers-ng/common/dialogs';
8+
import {TranslateCustomPipe} from 'hslayers-ng/shared/language';
89

910
@Component({
1011
selector: 'hs-confirm-dialog',
1112
templateUrl: './confirm-dialog.component.html',
13+
standalone: true,
14+
imports: [TranslateCustomPipe],
1215
})
1316
export class HsConfirmDialogComponent implements HsDialogComponent {
1417
dialogItem: HsDialogItem;

projects/hslayers/common/confirm/confirm.module.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './confirm-dialog.component';
2-
export * from './confirm.module';

projects/hslayers/common/dialogs/compositions-warning/warning-dialog.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h4 class="modal-title">{{'COMMON.warning' | translateHs }}</h4>
1010
<div class="modal-body" style="max-height: 600px; overflow-y: auto">
1111
<br>{{'COMMON.name' | translateHs }}: <b>{{data.composition_title}}</b>
1212
<hr>
13-
<br>{{data.message}}
13+
<br>{{data.message | translateHs}}
1414
<br>{{'COMPOSITIONS.dialogWarning.toContinue' | translateHs }}
1515
</div>
1616
<div class="modal-footer">

projects/hslayers/common/query-popup/widgets/clear-layer.component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import {getTitle} from 'hslayers-ng/common/extensions';
1818
})
1919
export class HsClearLayerComponent
2020
extends HsQueryPopupWidgetBaseComponent
21-
implements OnInit
22-
{
21+
implements OnInit {
2322
@Input() data: {
2423
layerDescriptor: any;
2524
service: HsQueryPopupServiceModel;
@@ -48,10 +47,7 @@ export class HsClearLayerComponent
4847
message: this.hsLanguageService
4948
.getTranslation('QUERY.reallyDeleteAllFeaturesFrom', undefined)
5049
.replace('{0}', getTitle(layer)),
51-
title: this.hsLanguageService.getTranslation(
52-
'QUERY.confirmClear',
53-
undefined,
54-
),
50+
title: 'QUERY.confirmClear',
5551
},
5652
);
5753
const confirmed = await dialog.waitResult();

projects/hslayers/common/query-popup/widgets/feature-info.component.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import {
2424
})
2525
export class HsFeatureInfoComponent
2626
extends HsQueryPopupWidgetBaseComponent
27-
implements OnInit
28-
{
27+
implements OnInit {
2928
layerDescriptor: any;
3029
attributesForHover: any[] = [];
3130
name = 'feature-info';
@@ -84,14 +83,8 @@ export class HsFeatureInfoComponent
8483
const dialog = this.hsDialogContainerService.create(
8584
HsConfirmDialogComponent,
8685
{
87-
message: this.hsLanguageService.getTranslation(
88-
'QUERY.reallyDelete',
89-
undefined,
90-
),
91-
title: this.hsLanguageService.getTranslation(
92-
'QUERY.confirmDelete',
93-
undefined,
94-
),
86+
message: 'QUERY.reallyDelete',
87+
title: 'QUERY.confirmDelete',
9588
},
9689
);
9790
const confirmed = await dialog.waitResult();

projects/hslayers/common/remove-multiple/remove-layer-dialog.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="modal-content">
44
<div class="modal-header">
55
<h4 class="modal-title">
6-
{{data.title}}
6+
{{data.title | translateHs}}
77
</h4>
88
<button type="button" (click)="no()" class="btn-close" data-dismiss="modal"
99
[attr.aria-label]="'COMMON.close' | translateHs "></button>
@@ -19,9 +19,9 @@ <h4 class="modal-title">
1919
option)}}</button>
2020
</div>
2121
</div>
22-
<p *ngIf="deleteFrom === 'catalogue'" class="h6 small">{{data.note}}</p>
22+
<p *ngIf="deleteFrom === 'catalogue'" class="h6 small">{{data.note | translateHs}}</p>
2323
<div *ngIf="deleteFrom && data.multiple">
24-
<p class="fw-bold h6">{{data.message}}</p>
24+
<p class="fw-bold h6">{{data.message | translateHs}}</p>
2525

2626
<div style="max-height: 65vh;" *ngIf="data.items?.length > 0">
2727
<div class="d-flex w-100 justify-content-center">

projects/hslayers/common/remove-multiple/remove-layer-dialog.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export class HsRemoveLayerDialogService {
3636
HsRmLayerDialogComponent,
3737
{
3838
multiple: false,
39-
message: this.translate('DRAW.reallyDeleteThisLayer'),
39+
message: 'DRAW.reallyDeleteThisLayer',
4040
note: this.getDeleteNote(),
41-
title: this.translate('COMMON.confirmDelete'),
41+
title: 'COMMON.confirmDelete',
4242
},
4343
);
4444
const confirmed: HsRmLayerDialogResponse = await dialog.waitResult();
@@ -65,9 +65,9 @@ export class HsRemoveLayerDialogService {
6565
HsRmLayerDialogComponent,
6666
{
6767
multiple: true,
68-
message: this.translate('DRAW.pleaseCheckTheLayers'),
68+
message: 'DRAW.pleaseCheckTheLayers',
6969
note: this.getDeleteNote(true),
70-
title: this.translate('COMMON.selectAndConfirmToDeleteMultiple'),
70+
title: 'COMMON.selectAndConfirmToDeleteMultiple',
7171
items: items,
7272
},
7373
);
@@ -151,7 +151,9 @@ export class HsRemoveLayerDialogService {
151151

152152
getDeleteNote(plural?: boolean): string {
153153
return this.hsDrawService.isAuthenticated
154-
? this.translate(plural ? 'DRAW.deleteNotePlural' : 'DRAW.deleteNote')
154+
? plural
155+
? 'DRAW.deleteNotePlural'
156+
: 'DRAW.deleteNote'
155157
: '';
156158
}
157159
}

projects/hslayers/components/add-data/add-data.component.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {HsAddDataUrlService} from 'hslayers-ng/shared/add-data';
88
import {HsDialogContainerService} from 'hslayers-ng/common/dialogs';
99
import {HsEventBusService} from 'hslayers-ng/shared/event-bus';
1010
import {HsGetCapabilitiesErrorComponent} from './common/capabilities-error-dialog/capabilities-error-dialog.component';
11-
import {HsLanguageService} from 'hslayers-ng/shared/language';
1211
import {HsLayoutService} from 'hslayers-ng/shared/layout';
1312
import {HsPanelBaseComponent} from 'hslayers-ng/common/panels';
1413
import {HsShareUrlService} from 'hslayers-ng/components/share';
@@ -26,7 +25,6 @@ export class HsAddDataComponent
2625

2726
constructor(
2827
public hsAddDataService: HsAddDataService,
29-
public hsLanguageService: HsLanguageService,
3028
public hsShareUrlService: HsShareUrlService,
3129
public hsLayoutService: HsLayoutService,
3230
public hsEventBusService: HsEventBusService,
@@ -59,23 +57,11 @@ export class HsAddDataComponent
5957
.subscribe((e) => {
6058
let error = e.toString();
6159
if (error?.includes('Unsuccessful OAuth2')) {
62-
error = this.hsLanguageService.getTranslationIgnoreNonExisting(
63-
'COMMON',
64-
'Authentication failed. Login to the catalogue.',
65-
undefined,
66-
);
60+
error = 'COMMON.Authentication failed. Login to the catalogue.';
6761
} else if (error.includes('property')) {
68-
error = this.hsLanguageService.getTranslationIgnoreNonExisting(
69-
'ADDLAYERS',
70-
'serviceTypeNotMatching',
71-
undefined,
72-
);
62+
error = 'ADDLAYERS.serviceTypeNotMatching';
7363
} else {
74-
error = this.hsLanguageService.getTranslationIgnoreNonExisting(
75-
'ADDLAYERS',
76-
error,
77-
undefined,
78-
);
64+
error = `ADDLAYERS.${error}`;
7965
}
8066
this.hsDialogContainerService.create(HsGetCapabilitiesErrorComponent, {
8167
error: error,

0 commit comments

Comments
 (0)