cancel
Showing results for 
Search instead for 
Did you mean: 

Localization in MII using SAPUI5

0 Kudos

Hello All,

I am trying localization using SAPUI5 and for the same reason I am trying to call resource bundle from META-INF in js file using the following syntax

url: '/XMII/Catalog?ObjectName=CustomerExamples/META-INF/Bundles/<Project>_<language>.properties&Mode=LOAD'

But, I am getting below error while referring to the above syntax.

Error: resource URL '/XMII/Catalog?ObjectName=CustomerExamples/META-INF/Bundles/<Project>_<language>.properties&Mode=LOAD' has unknown type (should be one of .properties,.hdbtextbundle).

Please let me know if there is any fix to it or something that is missing in the above syntax.

Thanks.

Harsh

Accepted Solutions (0)

Answers (3)

Answers (3)

Private_Member_14935
Active Participant
0 Kudos

Hi Harsh,

As mentioned by Christian, MII Catalog services will give you the encoded content of properties files, which cannot be used by the localization service of SAP UI5. This means to use the MII message bundle properties file with SAP UI5 application you could copy the same in your web folder and then use it as shown below:

jQuery.sap.require("jquery.sap.resources");

var oBundle = jQuery.sap.resources({url : "CM/<Project>/messages.properties", locale: "en"});

oBundle.getText("XLBL_KEY"); //this will give the localized value

Hope this help!

Do let us know if you find some other way for resolving this.

Thanks and Best Regards,

Ria

0 Kudos

You can also hide a text field on your web page (make sure it has the extension .irpt) like this:

<input id=localized name=localized type=hidden value={##LocalizationKey} />


This will put the value of the localized entry directly onto your page and you can reference it directly in JS or you can change the type field to be visible; works well for field labels.  This is documented in the MII help here: http://help.sap.com/saphelp_mii151sp00/helpdata/en/4c/8c1960f2bd60c8e10000000a15822d/frameset.htm


Sam

0 Kudos

Hi Ria,

Thanks for your suggestion.

I had tried the method that you have suggested and localization was working when I copied the bundle resource in web folder and gave the path under URL.

I am checking on how we can get it done while referring to resource bundle from META-INF folder. Will keep you posted if I come across with some resolution to this.

Thanks,

Harsh

former_member185280
Active Contributor
0 Kudos

Harsh,


I don't think you can use the Catalog service directly to get the resource files. I think it returns an xml file with the properties file binary encoded within. Check in your browsers developer tools network or resources tab to see what MII is actually sending you.

Regards,
Christian

0 Kudos

Hi Christian,

Thanks for your response.

I have tried adding content-type = text/json to it and it will get me data in json format but i believe it has something to do with the syntax only as the error show that some parameter needs to be defined in the syntax itself so as to access the resource bundle in META-INF.

Please let me know if you find something after digging more into it.

Thanks.

Harsh

former_member185280
Active Contributor
0 Kudos

Harsh,
I spent a lot of time dealing with the Catalog services writing an application to integrate with the MII virtual file system via FTP. I could be wrong but in my experience the Catalog service will not return the file in a way that the ui5 localization infrastructure wants. It returns a file containing the properties file as an encoded string. If there is a way to use the Catalog service to get the localization files then Pradip or someone else will have to provide a more complete example.

Regards,
Christian

agentry_src
Active Contributor
0 Kudos

Hi Harsh,

Thank you for creating the Discussion.  Adding the link so the SAPUI5 experts will also see this, though I don't think moving it there makes sense at this time.  Your question is more focused on MII content than the SAPUI5 coding.

Regards, Mike (Moderator)

SAP Technology RIG

I would also suggest that you check the syntax of LOAD in hbtextbundle which is where the error message says the trouble is caused.  May not be all caps?

Message was edited by: Michael Appleby