API: I18nService
Examples coming soon.
- Access through injection:
- Access through hook
- translate()
- translateToString()
- setLang()
- getLang()
- getLangs() ___
Access through injection:
import { inject, withInject, I18nService } from '@daimler/ftk-core';
// ...
class Example extends React.Component<WithStyles<{}>, {}> {
@inject()
public i18n!: I18nService;
// ...
}
export default withInject(Example);
Access through hook
import { useI18n } from '@daimler/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