Extending SAPUI5 Apps - Handling localized texts



Okay, if you are reading this blog, you probably might know what extending apps in sapui5 means. If you don’t know, or want to exactly know what it means then you should read my previous blog on extending apps in sapui5, where I have clearly mentioned what it really means to extend an application in sapui5.




In this tutorial I will make you understand, how to handle localized text while extending apps. Whenever you copy an application, the texts stored in the SAPUI5 text repository of the original application are not copied and are, thus, not available in the copied SAPUI5 application. This also applies to applications using the extension concepts of SAPUI5.

So, now how to use localized text in the custom application? For that, instantiate a resource model with the URL to the corresponding text properties files of the original application. If needed, you can enhance this resource model with its own properties file. For applications located in the ABAP backend, the resource model of another application located in another SAPUI5 repository in the ABAP backend can be accessed by its relative path.

The following example is valid for an application that is stored in the SAPUI5 repository in the ABAP backend:

var oModel = new sap.ui.model.resource.ResourceModel({bundleUrl:"../<original bsp application name>/i18n/i18n.properties"});

If the code is not located at the root level of the application, adjust the path with additional "../" at the beginning.
You can enhance this with an additional custom text properties file, which resides in the copied application:

oModel.enhance({bundleUrl:"./other18n.properties"});

The custom text properties file can contain additional texts or texts which overwrite the default ones from the original application.

If an SAPUI5 application is extended or copied, the GUID in the SAPUI5 translation key in the copied text properties file must be exchanged with a new one. Each text properties file must contain a unique GUID. You can then upload the application with the new translation key in the text properties file to the ABAP backend by means of the team provider or the /UI5/UI5_REPOSITORY_LOAD upload report. 

So, I hope you understood how to handle localized text in extended sap ui5 application. In the next blog, I will mention the steps to configure the component.js file, for custom extensions to be made.

http://www.sapui5tutors.com/2016/10/extending-sapui5-apps-component-Configuration.html

Previous
Next Post »