Add "No." as translateable

To display user numbers, No. is now translateable
This commit is contained in:
Sean Engelhardt 2019-02-20 16:17:05 +01:00
parent 0975de7432
commit 53ea73ccde
4 changed files with 16 additions and 6 deletions

View File

@ -62,6 +62,7 @@
"@angular/cli": "^7.3.2",
"@angular/compiler-cli": "^7.2.5",
"@angular/language-service": "^7.2.5",
"@biesbjerg/ngx-translate-extract": "^2.3.4",
"@compodoc/compodoc": "^1.1.8",
"@types/jasmine": "^3.3.9",
"@types/jasminewd2": "^2.0.6",

View File

@ -1,8 +1,9 @@
// import { _ } from '@biesbjerg/ngx-translate-extract';
import { _ } from '@biesbjerg/ngx-translate-extract';
function _(key: string | string[]): string | string[] {
return key;
}
// see issue: 4078
// function _(key: string | string[]): string | string[] {
// return key;
// }
/**
* Add strings here that require translations but have never been declared

View File

@ -56,6 +56,10 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
viewUser.getVerboseName = (plural: boolean = false) => {
return this.translate.instant(plural ? 'Participants' : 'Participant');
};
viewUser.getNumberForName = (nr: number) => {
return `${this.translate.instant('No.')} ${nr}`;
};
return viewUser;
}

View File

@ -152,8 +152,7 @@ export class ViewUser extends BaseProjectableViewModel implements Searchable {
const number = this.number ? this.number.trim() : '';
if (number) {
// TODO Translate
additions.push('No. ' + number);
additions.push(this.getNumberForName(number));
}
if (additions.length > 0) {
@ -167,6 +166,11 @@ export class ViewUser extends BaseProjectableViewModel implements Searchable {
*/
public getVerboseName;
/**
* This is set by the repository. Translates the number string.
*/
public getNumberForName;
public constructor(user: User, groups?: ViewGroup[]) {
super(User.COLLECTIONSTRING);
this._user = user;