Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

[Question] ngx-translate support? #64

Open
pouletfou opened this issue Mar 25, 2019 · 3 comments
Open

[Question] ngx-translate support? #64

pouletfou opened this issue Mar 25, 2019 · 3 comments

Comments

@pouletfou
Copy link

Hello

I'd like to use this with ngx-translate.
Is this somewhere on your roadmap?

@Hesesses
Copy link

Same question here

@samiv22
Copy link

samiv22 commented Aug 13, 2019

Any ideas when this feature would be implemented?

@pepe19000
Copy link

Yes, you can use it easily.

In app.module.ts (before you have to config TranslateModule):
providers: [
TranslateService,
{
provide: CUSTOM_ERROR_MESSAGES,
useFactory: CustomErrorFactory,
deps: [TranslateService],
multi: true
}
],

xy.ts:
export const CustomErrorFactory = (translateService: TranslateService): ErrorMessage[] => {
return [
{
error: "required",
format: (label, error) => requiredFormat(label, error, translateService)
}
];
}

export function requiredFormat(label: string, error: any, translateService: TranslateService): string {
return translateService.instant('RequiredErrorMessage');
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants