String Resources

Libre Apps usually interacts with devices. And user usually interacts with Libre Apps through devices.

However, there are occasions that Libre Apps may interact with user through smartphone.

For example, Libre Apps can send messages to users’ smartphones. We need to give Apps capabilities to localize the message text.

Managing String Resources

In Liberty-IoT Studio, open App Signature Editor, for every App function, there is a list of string resources (key/value) pairs.

The string resources can be managed by clicking “String Resource” button with the App function selected in “Functions” panel.

String Resource Button

Translation

String resources can be translated into different languages.

String Resources Editor

With string resource editor developers can edit list of string resources associated with function.

String Resource Editor

Valid Resource Name

The resource name must match the regex below.

^([a-zA-Z_][\w]*)$
  • It must start with an ASCII letter or “ _ “
  • The following characters must be letter, number of “ _ “

String Formating

If an App needs to send a message to users, instead of sending the literal string, it shall send the “string resource name”.

On user smartphone, our Libre Home app will get the best translation of the string resource and get actual string from translation with the resource name.

The format follows IEEE printf specification, the same format are supported on C/C++, Android and iOS.

%[argument_index$][flags][width][.precision]conversion

For more information about formatting, please visit:

Restrictions

Currently, the formatter variables are from JSON array. So only the following data types are supported:

  • Boolean
  • Floating point
  • String

For more information, please read chapter “Messaging & Notification”.