Cadaxo UI5 Snippet 2

Cadaxo UI5 Snippets #2 – i18n with parameters in XML View

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.

Define i18n File

/webapp/i18n/i18n.properties

Using in XML View

To display defined text with parameters you can use following snippet

Set parameters in Controller

Define JSON Model in manifest.json file

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

Let me know how you work with i18n parameters in Frontend or leave a comment if you found this blog post useful!

Constants

Cadaxo UI5 Snippets #1 – How to define constants

During the work on some Freestyle UI5 Apps I always look for a way how to save constants in Frontend. I would like to share following practice with you, which I use currently.

Define JSON File with Constants

I am going to create a new File in my project root folder. In this file all constant and values will be stored as a JSON Object.

/webapp/model/constants.json

   

Define JSON Model in manifest.json file

I my project manifest.json, I am going to define a new JSON Model with created JSON file in URI

Using Constants in View

From now on it is possible to use the constant model in View:

Using Constants in Controller

And of course also in Controllers. For example like this:

Let me know how you save constants in Frontend or leave a comment if you found this blog post useful!