Examples coming soon.
- Access through injection:
- Access through hook
- translate()
- translateToString()
- setLang()
- getLang()
- getLangs()
import { inject, withInject, I18nService } from '@mercedes-benz/ftk-core';
// ...
class Example extends React.Component<WithStyles<{}>, {}> {
@inject()
public i18n!: I18nService;
// ...
}
export default withInject(Example);
import { useI18n } from '@mercedes-benz/ftk-core';
// ...
const i18n = useI18n();
// ...
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(translationId: string, params?: any): string;
The translateToString Method does the same as translate but provides the translation as simple string value.
setLang(lang: string): void;
The setLang Method sets the current language to the lang parameter value.
getLang(): string;
The getLang Method provides the language key of the current set language.
getLangs(): string[];
The getLangs Method provides all available language keys.
Each Swidget should provide it's own language files