SAP-Formulare ohne Frust: Mein Workflow mit dox42
Wer im SAP-Umfeld entwickelt, weiß: Formulare sind oft ein Klotz am Bein. Man verbringt Stunden mit Adobe Forms…
Internationalization in UI5 – using i18n properties files – is the way to translate text into other languages. In this blog post I will share you the way, how to use i18n text with parameters in XML Views.
/webapp/i18n/i18n.properties
textWithParameters=Hello my first name is {0}. And my last name {1}.To display defined text with parameters you can use following snippet
<View xmlns:core="sap.ui.core">
<Page id="page" title="Cadaxo UI5 Snippets #1">
<content>
<Text core:require="{ formatMessage: 'sap/base/strings/formatMessage' }"
text="{parts: ['i18n>textWithParameters', 'myModel>/firstName', 'myModel>/lastName'],
formatter: 'formatMessage'
} />
</content>
</Page>
</View>...
onInit: function () {
const oView = this.getView();
const oModel = oView.getModel("myModel");
oModel.setProperty("firstName", "Dusan" );
oModel.setProperty("lastName", "Sacha" );
}
...
Do not forget to define ‚myModel‘ as it is not possible to input the parameter as a hard-coded strings. Either in the View or in manifest.json file
"models": {
"i18n": {
...
},
"myModel": {
"type": "sap.ui.model.json.JSONModel"
}
}Let me know how you work with i18n parameters in Frontend or leave a comment if you found this blog post useful!