Skip to content

Commit e046232

Browse files
4manasamanasa
andauthored
Added Localization fixes (#290)
Co-authored-by: manasa <manasa.mashetty@in.pega.com>
1 parent cb1ed12 commit e046232

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

packages/angular-sdk-components/src/lib/_components/template/list-view/list-view.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ <h3 *ngIf="label" class="label" style="font-weight: bold">
180180
<tr mat-header-row *matHeaderRowDef="displayedColumns$"></tr>
181181
</table>
182182
</div>
183-
<div class="psdk-no-records" *ngIf="repeatListData?.length === 0">No Records Found.</div>
183+
<div class="psdk-no-records" *ngIf="repeatListData?.length === 0">
184+
{{ utils.getGenericFieldsLocalizedValue('CosmosFields.fields.lists', 'No records found.') }}
185+
</div>
184186
</div>
185187
</div>
186188
</div>

packages/angular-sdk-components/src/lib/_components/template/list-view/list-view.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class ListViewComponent implements OnInit, OnDestroy {
165165

166166
constructor(
167167
private psService: ProgressSpinnerService,
168-
private utils: Utils
168+
public utils: Utils
169169
) {}
170170

171171
ngOnInit(): void {

packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ <h3 *ngIf="label" className="label" style="font-weight: bold">
5757
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
5858
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
5959
<tr class="mat-row psdk-no-records" *matNoDataRow>
60-
<td class="mat-cell" [attr.colspan]="displayedColumns.length">No Records Found.</td>
60+
<td class="mat-cell" [attr.colspan]="displayedColumns.length">
61+
{{ utils.getGenericFieldsLocalizedValue('CosmosFields.fields.lists', 'No records found.') }}
62+
</td>
6163
</tr>
6264
</table>
6365
<table *ngIf="editableMode && !allowEditingInModal" mat-table [dataSource]="elementsData" class="mat-elevation-z8" id="editable-table">
@@ -87,11 +89,15 @@ <h3 *ngIf="label" className="label" style="font-weight: bold">
8789
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
8890
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
8991
<tr class="mat-row psdk-no-records" *matNoDataRow>
90-
<td class="mat-cell" [attr.colspan]="displayedColumns.length">No Records Found.</td>
92+
<td class="mat-cell" [attr.colspan]="displayedColumns.length">
93+
{{ utils.getGenericFieldsLocalizedValue('CosmosFields.fields.lists', 'No records found.') }}
94+
</td>
9195
</tr>
9296
</table>
9397
</div>
94-
<button *ngIf="showAddRowButton" mat-button color="primary" style="font-size: 16px" (click)="addRecord()">+ Add</button>
98+
<button *ngIf="showAddRowButton" mat-button color="primary" style="font-size: 16px" (click)="addRecord()">
99+
+ {{ localizedVal('Add', localeCategory) }}
100+
</button>
95101
</ng-container>
96102

97103
<!-- pop overs for filters-->

packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
160160

161161
isInitialized = false;
162162
targetClassLabel: string;
163-
163+
localizedVal = PCore.getLocaleUtils().getLocaleValue;
164+
localeCategory = 'SimpleTable';
164165
constructor(
165166
private angularPConnect: AngularPConnectService,
166-
private utils: Utils,
167+
public utils: Utils,
167168
private dataPageService: DatapageService
168169
) {}
169170

packages/angular-sdk-components/src/lib/_helpers/utils.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,28 @@ export class Utils {
427427
static isEmptyObject(obj: Object): boolean {
428428
return Object.keys(obj).length === 0;
429429
}
430+
431+
/**
432+
* Get a localized value from the Generic Fields
433+
* @param path - The path within Generic Fields (e.g., 'CosmosFields.fields.lists')
434+
* @param key - The key of the string to localize
435+
* @returns The localized string or the key itself if no translation is found
436+
*/
437+
getGenericFieldsLocalizedValue(path: string, key: string): string {
438+
const GENERIC_BUNDLE_KEY = PCore.getLocaleUtils().GENERIC_BUNDLE_KEY;
439+
const localeStore = PCore.getLocaleUtils().localeStore[GENERIC_BUNDLE_KEY];
440+
441+
if (!localeStore) return key;
442+
443+
// Split the path and traverse the object
444+
const pathParts = path.split('.');
445+
let currentObj = localeStore;
446+
447+
for (const part of pathParts) {
448+
if (!currentObj[part]) return key;
449+
currentObj = currentObj[part];
450+
}
451+
452+
return currentObj[key] || key;
453+
}
430454
}

0 commit comments

Comments
 (0)