fix profile names
This commit is contained in:
parent
d2eb8fd261
commit
0f528ac7e0
@ -65,30 +65,34 @@ export class I18nService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get(key, args: string[]): string {
|
get(key, args: string[]): string {
|
||||||
return this.getInternal(key, args, this.i18n, "");
|
return this.getInternal(key, args, this.i18n, "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInternal(key, args: string[], from, path): string {
|
getEmpty(key, args: string[]): string {
|
||||||
|
return this.getInternal(key, args, this.i18n, "", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
getInternal(key, args: string[], from, path, empty : boolean): string {
|
||||||
key += '';
|
key += '';
|
||||||
if (!from) {
|
if (!from) {
|
||||||
return this.empty(key, args, path);
|
return empty ? this.empty(key, args, path) : key;
|
||||||
} else if (from[ key ]) {
|
} else if (from[ key ]) {
|
||||||
if (typeof from[ key ] === 'object') {
|
if (typeof from[ key ] === 'object') {
|
||||||
if (from[ key ][ "." ]) {
|
if (from[ key ][ "." ]) {
|
||||||
return this.insertArguments(from[ key ][ "." ], args);
|
return this.insertArguments(from[ key ][ "." ], args);
|
||||||
}
|
}
|
||||||
return this.empty(key, args, path);
|
return empty ? this.empty(key, args, path) : key;
|
||||||
}
|
}
|
||||||
return this.insertArguments(from[ key ], args);
|
return this.insertArguments(from[ key ], args);
|
||||||
} else {
|
} else {
|
||||||
let keys = key.split(".");
|
let keys = key.split(".");
|
||||||
if (from[ keys[ 0 ] ]) {
|
if (from[ keys[ 0 ] ]) {
|
||||||
key = keys.slice(1, keys.length).join(".");
|
key = keys.slice(1, keys.length).join(".");
|
||||||
return this.getInternal(key, args, from[ keys[ 0 ] ], path + keys[ 0 ] + ".")
|
return this.getInternal(key, args, from[ keys[ 0 ] ], path + keys[ 0 ] + ".", empty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.empty(key, args, path);
|
return empty ? this.empty(key, args, path) : key;
|
||||||
}
|
}
|
||||||
|
|
||||||
empty(key, args: string[], path: string): string {
|
empty(key, args: string[], path: string): string {
|
||||||
|
@ -14,7 +14,7 @@ export class ConfirmDialog {
|
|||||||
constructor(private i18nService: I18nService,
|
constructor(private i18nService: I18nService,
|
||||||
public dialogRef: MatDialogRef<ConfirmDialog>,
|
public dialogRef: MatDialogRef<ConfirmDialog>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||||
this.text = i18nService.get(data.label, data.args);
|
this.text = data.empty ? i18nService.getEmpty(data.label, data.args) : i18nService.get(data.label, data.args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<h1 mat-dialog-title>{{'profileField.name.' + profileField.name | i18n}}</h1>
|
<h1 mat-dialog-title>{{'profileField.name.' + profileField.name | i18nEmpty}}</h1>
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<pre>
|
<pre>
|
||||||
{{profileField.blob}}
|
{{profileField.blob}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<h1 mat-dialog-title>{{'profileField.name.' + profileField.name | i18n}}</h1>
|
<h1 mat-dialog-title>{{'profileField.name.' + profileField.name | i18nEmpty}}</h1>
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<form [formGroup]="form">
|
<form [formGroup]="form">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header="name"> {{'profileField.name' | i18n}} </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header="name"> {{'profileField.name' | i18n}} </th>
|
||||||
<td mat-cell *matCellDef="let profileField"> {{'profileField.name.' + profileField.name | i18n}} </td>
|
<td mat-cell *matCellDef="let profileField"> {{'profileField.name.' + profileField.name | i18nEmpty}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="value">
|
<ng-container matColumnDef="value">
|
||||||
|
@ -61,7 +61,7 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
this.profileFields = data.sort((a, b) => {
|
this.profileFields = data.sort((a, b) => {
|
||||||
const isAsc = sort.direction === 'asc';
|
const isAsc = sort.direction === 'asc';
|
||||||
switch(sort.active) {
|
switch(sort.active) {
|
||||||
case 'name': return this.compare(this.i18n.get('profileField.name.' + a.name, []), this.i18n.get('profileField.name.' + b.name, []), isAsc);
|
case 'name': return this.compare(this.i18n.getEmpty('profileField.name.' + a.name, []), this.i18n.getEmpty('profileField.name.' + b.name, []), isAsc);
|
||||||
case 'value': return this.compare(a.value, b.value, isAsc);
|
case 'value': return this.compare(a.value, b.value, isAsc);
|
||||||
case 'index': return this.compare(a.index, b.index, isAsc);
|
case 'index': return this.compare(a.index, b.index, isAsc);
|
||||||
case 'visibility': return this.compare(this.i18n.get('visibility.' + a.visibility, []), this.i18n.get('visibility.' + b.visibility, []), isAsc);
|
case 'visibility': return this.compare(this.i18n.get('visibility.' + a.visibility, []), this.i18n.get('visibility.' + b.visibility, []), isAsc);
|
||||||
@ -105,6 +105,7 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
const dialogRef = this.dialog.open(ConfirmDialog, {
|
const dialogRef = this.dialog.open(ConfirmDialog, {
|
||||||
data: {
|
data: {
|
||||||
'label': 'profileField.confirmDelete',
|
'label': 'profileField.confirmDelete',
|
||||||
|
'empty' : true,
|
||||||
'args': ['profileField.name.' + profileField.name]
|
'args': ['profileField.name.' + profileField.name]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -16,3 +16,16 @@ export class I18nPipe implements PipeTransform {
|
|||||||
return this.i18n.get(value, args);
|
return this.i18n.get(value, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'i18nEmpty'
|
||||||
|
})
|
||||||
|
export class I18nEmptyPipe implements PipeTransform {
|
||||||
|
|
||||||
|
constructor(private i18n: I18nService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
transform(value: String, ...args: any[]): String {
|
||||||
|
return this.i18n.getEmpty(value, args);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user