ManagerI18n

You can access this manager through the Homey instance as this.homey.i18n

Methods

__

__(key, tags): string

Translate a string, as defined in the app's /locales/<language>.json file. This method is also available at @{link Homey#__}

Parameters

Name Type Description
key
string
tags
object

An object of tags to replace. For example, in your json define Hello, __name__!. The property name would contain a string, e.g. Dave.

Returns

The translated string

string

Examples

/locales/en.json

{ "welcome": "Welcome, __name__!" }

/app.js

let welcomeMessage = this.homey.__('welcome', { name: 'Dave' });
console.log( welcomeMessage ); // "Welcome, Dave!"

getLanguage

getLanguage(): string

Get Homey's current language

Returns

The language as a 2-character string (e.g. en)

string

getUnits

getUnits(): string

Get Homey's current units

Returns

metric or imperial

string