Language API
A list of TranslocoService language-related API methods and their usages
getDefaultLang()
getDefaultLang()Returns the default language of the application.
app.component.ts
export class AppComponent {
constructor(private translocoService: TranslocoService) {
const defaultLang = translocoService.getDefaultLang();
console.log(defaultLang);
}
}setDefaultLang()
setDefaultLang()Sets the default language.
app.component.ts
export class AppComponent {
constructor(private translocoService: TranslocoService) {
translocoService.setDefaultLang('es');
}
}getActiveLang()
getActiveLang()Returns the current active language.
setActiveLang()
setActiveLang()Sets the active language for the application.
getAvailableLangs()
getAvailableLangs()Retrieves the list of available languages.
setFallbackLangForMissingTranslation()
setFallbackLangForMissingTranslation()Defines a fallback language to be used when a translation key is missing for the active language.
setAvailableLangs()
setAvailableLangs()Sets the list of available languages.
langChanges$
langChanges$An observable that emits whenever the active language changes.
load()
load()Loads the specified language and adds it to the service.
Was this helpful?

