Bangle.js Internationalisation

If you have an app (eg by following the Bangle.js First App tutorial), you might want to have a go at making it so that users in other countries can use it easily.

For this, we provide a locale module. By default an en_GB locale module is built into Bangle.js's firmware, but you can install the Language app from the App Loader to use a different language.

How do you use it?

Simply require("locale") in your code and use the provided object.

For instance, if you want to write a date in a locale-friendly way, just use:

var myDate = new Date();
var dateString = require('locale').date(myDate);

What's provided

It's easiest to show examples (for the de_DE locale):

Note: Some strings (eg currencySym) may not render correctly in the console. They may need to be rendered with a 6x8 or other ISO10646-1 font.

// The name of the Locale

// Symbol used for currency

// Day of the week from Date (long)
>require('locale').dow(new Date())

// Day of the week from Date  (short)
>require('locale').dow(new Date(), 1)

// Month of the year from Date (long)
>require('locale').month(new Date())

// Month of the year from Date (short)
>require('locale').month(new Date(), 1)

// Number to formatted String

// Currency to formatted String

// Distance/Length (in meters) to formatted String

// Automatic unit selection for larger distances

// Speed (in kph) formatted String

// Temperature (in Centigrade) to String

// Translate test or a phrase

// Date to date string (long)
>require('locale').date(new Date())
="Donnerstag, 02. April 2020"

// Date to date string (short)
>require('locale').date(new Date(),1)

// Date to time string (long)
>require('locale').time(new Date())

// Date to time string (long)
>require('locale').time(new Date(),1)

// Date to meridian (text describing morning/evening)
>require('locale').medidian(new Date())
="" // or "pm" for en_GB


require('locale').translate will attempt to translate the English text that is supplied to it. Currently it only handles very specific words:

  • Yes
  • No
  • Ok
  • On
  • Off

However it is expected that it will become slightly better in the future, translating a wider variety of words even when used with other characters.

E.showMenu / E.showMessage / E.showPrompt / E.showAlert all use the translate function internally - as such any menu that is displayed should already have basic translation included as long as you use one of the supported translated words.

Adding your own locale

All you need to do is form the BangleApps loader as you would have done for adding an app to the Bangle.js App Loader.

Now, edit the apps/locale/locales.js file - you can easily add your own date/time formats and translations.

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.