Skip to content

Latest commit

 

History

History
84 lines (65 loc) · 1.68 KB

I18nService.md

File metadata and controls

84 lines (65 loc) · 1.68 KB

API: I18nService

Examples coming soon.


Access through injection:

import { inject, withInject, I18nService } from '@mercedes-benz/ftk-core';
// ...
class Example extends React.Component<WithStyles<{}>, {}> {
  @inject()
  public i18n!: I18nService;
  // ...
}

export default withInject(Example);

Access through hook

import { useI18n } from '@mercedes-benz/ftk-core';
// ...
const i18n = useI18n();
// ...


translate()

translate(translationId: string, params?: any): any;

The translate Method provides the value of the tranlation map for the set translationId (key) and current language as react component. If the value contains placeholders, these are replaced by the content of the params parameter.


translateToString()

translateToString(translationId: string, params?: any): string;

The translateToString Method does the same as translate but provides the translation as simple string value.


setLang()

setLang(lang: string): void;

The setLang Method sets the current language to the lang parameter value.


getLang()

getLang(): string;

The getLang Method provides the language key of the current set language.


getLangs()

getLangs(): string[];

The getLangs Method provides all available language keys.



I18n within Swidgets

Each Swidget should provide it's own language files