0.0.15 • Published 4 years ago

@medrecord/frontend-translations-middleware v0.0.15

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

Medrecord Translations Middleware

This is a translation middleware for loading and using translations.

Installation

Add TranslateModule from @ngx-translate/core. It requires HttpClientModule.

app.module.ts

@NgModule({
  ...
  imports: [
    ...
    HttpClientModule,
    TranslationMiddlewareModule.forRoot(),
    })
    ...
  ],
  ...
})
export class AppModule { }

Usage

Inject TranslationMiddlewareService into your component. Use method: addTranslation for extending translations list.
Use translationMiddleware instead of translation.

API

TranslationMiddlewareService

MethodDescriptionDefaultValues
translationsGetter for displaying all loaded and added translations{}--
languageGetter for displaying selected language.'en''en','nl','it','fr','es','de'
setTranslationsReplace all loaded translations. Custom translations will stay unchanged---
extendTranslationsExtend loaded translations by another load----
addTranslationAdd custom translation. If key will be same as loaded, this translations will be major.----
setLanguageSwitch language. It will trigger listenLanguage$----
listenLanguage$Observable value for getting language updates----
translateGet current language translation by key and with params if required.----

Troubleshooting

If you have no i18n folder in your assets or en.json file you will start getting 404 error in your console. Ignore it or add i18n/en.json as default file.

0.0.15

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago