Skip to Content
Author's profile photo Daniel Van Leeuwen

Getting Started with Kapsel – Part 15 — Localization (SP09+)



The text displayed by an application should appear in the language the device is set to.  One way to do this is to place the user visible strings an application displays in a file separate from the rest of the files that make up the application.  When the application needs to support a new language, a new language file can be added that includes the translated versions of the text.  When the application loads, the application will determine the language the device or emulator is set to and will load the language file that most closely matches current language.

Kapsel provides an i18n plugin that can be used to determine the language of the device and based on the language will attempt to load the appropriate language bundle.  In SP09 the Kapsel plugins have been localized for many different languages.  The list of available languages can be seen below.

 Directory of C:\SAP\MobileSDK3\KapselSDK\plugins\appupdate\www

06/18/2015  08:15 PM            12,821 appupdate.js
06/18/2015  08:15 PM               312
06/18/2015  08:15 PM               339
06/18/2015  08:15 PM               135 messages_en.json
06/18/2015  08:15 PM               312
06/18/2015  08:15 PM               351
06/18/2015  08:15 PM               351
06/18/2015  08:15 PM               395
06/18/2015  08:15 PM               345
06/18/2015  08:15 PM               602
06/18/2015  08:15 PM               371

If a Kapsel app is to support an additional language, the strings for that language need to be provided.  The following topic will demonstrate how to use the Kapsel i18n plugin and the SAPUI5 resources module to provide different strings depending on the language selected for the device.
Note that as of SP08, the Kapsel i18n plugin switched from using .json files to .properties files.
For additional details on this topic in general see Internationalization and localization.

Using the Kapsel i18n Plugin
Language Files Used by Kapsel Plugins

Using the Kapsel i18n Plugin

  • Add the i18n plugin to the LogonDemo project created in the Logonsection.
    cordova plugin add kapsel-plugin-i18n --searchpath %KAPSEL_HOME%/plugins
    cordova plugin add kapsel-plugin-i18n --searchpath $KAPSEL_HOME/plugins
  • Create a i18n folder and add a new language files.

        These files must be saved as UTF-8.  One way to verify that these are properly encoded is to open the file in Notepad on Windows and choose File > Save As. 

  • Modify index.html to use the resource bundles.  In the init method add
        var i18n = cordova.require("kapsel-plugin-i18n.i18n");
        console.log("Locale is " + navigator.language);
        i18n.load({path: "i18n", name: "messages"}, bundleCallback);

    Add the following method.

    function bundleCallback(languageBundle) {
        bundle = languageBundle;
        document.getElementById("register").innerText = bundle.get("RegisterKey");
        document.getElementById("read").innerText = bundle.get("ReadKey");
        document.getElementById("unregister").innerText = bundle.get("UnregisterKey");
        document.getElementById("lock").innerText = bundle.get("LockKey");
        document.getElementById("unlock").innerText = bundle.get("UnlockKey");
  •     In an Android device or emulator, change the language to French via Settings > Language & input > Language > Francais (Canada).
        In an iOS device or simulator, change the language to French via Settings > General > Language and Region > Device Language > French.
        Deploy and run the app.  Notice that the Logon screens are localized as French is one of the languages that the Kapsel SDK has been localized for.



Another option is to use as described in Use of Localized Texts in Applications.  The Logon plugin uses this for its resources.  The logon plugin’s resource files are located in the following folder.


Note that these files have had non ascii characters converted to Unicode characters.  It is possible to convert between formats using the following commands which make reading and editing these files easier.

native2ascii -reverse -encoding UTF-8
native2ascii -encoding UTF-8 

Copy the file to and make a few changes such as the following (adding on _FR_CA).


Prepare, build and deploy the app with the following command.

cordova run android
cordova run ios


Language Files Used by Kapsel Plugins

The following are the list of localizable strings used by the Kapsel plugins in SP09.


Back to Getting Started With Kapsel

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.