1- Create a new ADF Mobile Application
By default two projects created (ApplicationController – ViewController)
2- We will do all our work on the ViewController Project as it’s the one responsible for the user interface(UI), so right Click on ViewController project -> project Properties
Under Resource bundle -> basic Configuration we will find two choices
- One Bundle Per Project (Default)
It means that for the whole project there will only be one bundle holding all our keys and values.
- One Bundle per File
Means a bundle file will be created for each amx page(view).
For simplicity I will choose the first option
Note: you will also find that the only Resource Bundle Type available for ADF Mobile project is Xliff.
3- Create a new feature
ViewController -> Application Sources -> META-INF ->adfmf-feature.xml
4- Under content tab create a new ADF Mobile AMX Page
5- An AMX Page will be created , add “Output Text” component by dragging it from “Component Palete” to the page structure
6- Select the “Output Text” and under “Property Inspector” click the right arrow beside “Value” property and click “Select Text Resource”
7- The “Select Text Resource” window will appear contains
- Resource Bundle Name: in our case “ViewControllerBundle” as we choose to create one bundle for the whole project.
- Display Value: the value that we want to view in our “Output Text”
- Key: represent the key that holds the display value in the ResourceBundle (created automatically and can be modified )
- Matching Text Resource: If we created keys before it will appear in this part and can be selected to be used again anywhere in the project so no need to create new key if the value already exists in a previously created one.
Enter a value in Display value “Welcome To Egypt” a key will be created automatically “WELCOME_TO_EGYPT” then click the button “Save and Select”
As soon as we click “Save and Select” we will notice two things created
- “ViewControllerBundle.xlf’ file is created under ViewController project default package.
- A “load Bundle” component added to our AMX Page that refers to the created ResourceBundle.
- Also notice the value of the “Output Text” component
8- Now if we opened the created “ViewControllerBundle” we will notice that the default language for this bundle is “en” and we will find the Key and it’s display value we created
9- Our second language will be Arabic so we will create a new bundle file with the same name of “ViewControllerBundle.xlf” but we will add “_ar” at the end of it just before “.xlf” , so our file name will be “ViewControllerBundle_ar.xlf”
- Right click on ViewController project default package and select new.
- Under General-> XML choose XML Localization File (XLIFF)
- Add file name “ViewControllerBundle_ar.xlf” and make sure it’s in the same directory as the main “ViewControllerBundle.xlf” and click “OK”
10- You will notice the file name “ViewControllerBundle_ar.xlf” created open it then copy the content of file “ViewControllerBundle.xlf” into it but do below modifications
- Change file encoding to “UTF-8” to accept Arabic language
- Change the file source-language to “ar”
- Change the source (display value) of the created key to “مرحباُ في مصر”
So it would look like below
11- Right click on ViewController Project-> Project Properties-> Resource Bundle -> Bundle Search and add “ViewControllerBundle_ar.xlf”
12- Create a deployment profile and change character encoding to “UTF-8” to allow Arabic language
This is how the application looks in English
This is how it looks in Arabic
NOTE: ADF Mobile will automatically get current language setting from phone, you cannot override it with code, or at least that’s what I know till now.
For more information about ADF Mobile Localization & Internationalization visit ADF Mobile Developers Guide