backend-error-translations
v0.0.8
Published
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.0.
Downloads
10
Maintainers
Readme
to use error-translations library:
- run
npm i backend-error-translations
- import
ErrorTranslationsModule
to your@NgModule
imports[] this should import it as follow:import { ErrorTranslationsModule } from "error-translations";
- to use
translateError
pipe:<p [innerHTML]="errorKey | translateError:locale"></p>"
make sure thatlocale
is a validLocale
value that you can import from your component as well should be imported from:import { Locale } from "error-translations";
errorKey
should be Uppercase, dot separated key path like'INVALID.CREDENTIALS_PROVIDED'
, you can find locales files in langs/.json- to use
humanize()
function: injectErrorTranslationsService
also fromerror-translations
and use the function as follow:.humanize(errorKey: string, locale: Locale)
with the specified types
to add language support
- add a json file in projects/error-translations/src/lib/translations like:
fr.json
- re-run the script
npm run build:lib
to publish the library
npm run publish
it builds the lib and publish its dist folder