Pebble library to support locale features in apps/faces and select the correct text to display.
-
Run
pebble package install pebble-localize. -
Include the library in any C files that will use it:
#include <pebble-localize/pebble-localize.h>
-
Add
locale_english.bin,locale_french.binandlocale_whatever.binto your app resources. -
Modify your main function to use
localize_init()andlocalize_deinit():
int main(void) {
// Init localize library
localize_init(RESOURCE_ID_OF_YOUR_CHOOSEN_LANGUAGE);
/* Other app setup code */
// DeInit localize library
localize_deinit();
}- For all strings that you wish to localize, add
_()around them.
_("Breakfast Time");-
Run
python gen_dict.py src/ locale_english.json. This will generatelocale_english.jsonandlocale_english.bin. -
Move
locale_english.binto your project'sresourcesdirectory. -
Make a copy of
locale_english.jsonfor other languages, such aslocale_german.json. -
Modify
locale_german.jsonto replace the English strings with German strings. -
Run
python dict2bin.py locale_german.json. This will generatelocale_german.bin. -
Move
locale_german.binto your project'sresourcesdirectory. -
Add the new
.binresource files to your project'sappinfo.jsonfile as shown in the App Resources guide. For example, for the four language files in this project are added as shown below:
"media": [
{
"type": "raw",
"name": "LOCALE_ENGLISH",
"file": "locale_english.bin"
},
{
"type": "raw",
"name": "LOCALE_FRENCH",
"file": "locale_french.bin"
},
{
"type": "raw",
"name": "LOCALE_SPANISH",
"file": "locale_spanish.bin"
},
{
"type": "raw",
"name": "LOCALE_GERMAN",
"file": "locale_german.bin"
}
]- Compile your application and install!
If you wish to add more translations in the future, repeat Generating Translation Resources to obtain new translation binary resources. You will also need to do this in the event that you modify any of your strings.