Text Manager (v5.2+)

Manage your app wordings with multilingual support !

The Android Apps Panel SDK provides a module letting you update the wordings in your app without having to resubmit it into the stores. It is based on key value data provided by the back office. It supports multiple languages and dynamic content with variables management.

Mechanism

📘

Since the 5.2 version, the text manager is initialized by the SDK itself and do not require any call from the app. Nevertheless, this module need to be active from project configuration in order to sync texts with API request so make sure GET conf return active TRUE for this module.

When your application is launched, the SDK is setup and do severals steps for Text Manager :
1 - The module is initialized and copy all embeded assets string files to internal storage if not yet done.
2 - The module identify the locale (can be customized) and load the corresponding string file.
3 - If no string file correspond, it load the default embeded string file (can be changed).
4 - When SDK get the online configuration from GET /conf it check the availability of all modules.
If the component text manager is active, the module will request GET /text to sync wordings.
5 - The API response containing wordings is saved by replacing existing locale file or by creating a new one.
6 - When your app need to display a wording, the value is retrieve by it key from the loaded string file.

Default file

Take in consideration that the app can be launched for the first time in offline mode or with limited connection. In this case there is no way to get any string from the server. This is why you must import a default strings file to your app in order to show default wordings.

From the Apps Panel back office, you can export all wordings as a json file by clicking on the top right icon. To import it in your app, paste the file in this folder : assets/strings and rename it like below :
apnl_strings_fr_fr.json !

You are able to choose the default embeded file to used as fallback, when you start app the first time without any connexion (default value fr_FR) :

APTextManager.setDefaultFilename("en_uk")

Get wording

To obtain a wording you need to provide the back office associated key as below :

APTextManager.getString(key)

📘

Information

If you try to obtain a wording which does not match to any key, the key is returned instead.

Get smart wording

It's possible to insert one or several variables into wording by adding them as parameters :

fun getString(key: String, variables: HashMap<String, String>): String
  
fun getString(key: String, variable: String): String

The variables positions are defined in the wording value with ## tags like below :

{
  "hello_user" : "Hello ##FIRSTNAME## ##FAMILYNAME## !",
  "bye_user":"Good bye ##USERNAME## ! See you soon..."
}

Multilingual

You can specify the language you want by providing your locale as below :

APTextManager.setCustomLocale("FR", "fr")

Or remove your custom :

APTextManager.removeCustomLocale()

When you set or remove a custom locale, the module is automatically reinitialized to take into account the change. If the module is active, a request is done to get the wordings corresponding to your new locale.