on 06-05-2023 3:59 PM
Hello SAP Community,
I'm really hoping someone here can help us out with an issue we're having. We have a CAP application with a Fiori Elements List Report/Object Page frontend interface. The question I have is about the @Common.Label or @title annotation.
Most commonly, the value here points to the i18n model; for example:
country @title: '{i18n>country}'
This updates the text shown for the "country" label everywhere it is seen:
Our application requires this label to be dynamic, however. We have tried a few different approaches, but the most straightforward option appears to be using JSONModel to set the value we need.
The implementation then looks like the following.
In my labels.cds file:
country @title '{json>/country}'
In my controller extension for the List Report:
onInit: function () {
const json = new sap.ui.model.json.JSONModel({country: 'Country',});
this.base.getAppComponent().setModel(json, 'json');
},
This seems to work ONLY for the filter bar. The table column header and p13n menu entries for this property only display the path as a string; for example, '{json>/country}'. Please note I have also tried this with a JSONModel that is instantiated in the manifest.json and given static values from a json file with the same results.
I'm wondering if this has something to do with model instantiation, or is it a limitation of the @title annotation (does it only support paths to resource models)? Is there a different approach you recommend in order to make this happen with Fiori Elements? For such a small feature we would like to avoid ui5 freestyle or adding a bunch of custom fragments to the page.
I hope I've explained this well, but please let me know if any clarification is needed. We've been really scratching our heads on this one, so your help is very much appreciated. Thanks so much in advance!
Hi daniellelyle,
Check out the below video will solve your problem:
https://youtu.be/KjqenYC6itY
Thank You,
Suggu Sandeep.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi sandeepsuggu - thanks for your response, I appreciate you reaching out. I'm not sure I'm understanding, what I need is not to change the language but to have a label that is editable by the user. I don't believe it is possible to do this using the i18n model, which is why I am trying to use a JSONModel instead.
Hi daniellelyle,
We got a requirement while building of an SAPUI5 Application that
Translation of language should happen based on user selection from different Countries,
So i18n is the only solution we found, in that i18n file each and every language translation words also need to be attached...
As worked on 3 languages we added each language manually....
Thank You,
Suggu Sandeep.
User | Count |
---|---|
77 | |
9 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.