You are currently viewing the Homey Apps SDK v2 documentation. New apps should use Homey Apps SDK v3 ››

Homey.ManagerI18n

const { ManagerI18n } = require('homey');

Table of Contents

Methods

__(key, tags) → {string}

Translate a string, as defined in the app's /locales/<language>.json file. This method is also available at 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:
Type:
string

The translated string

Examples

/locales/en.json

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

/app.js

const Homey = require('homey');

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

getLanguage() → {string}

Get Homey's current language

Returns:
Type:
string

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

getUnits() → {string}

Get Homey's current units

Returns:
Type:
string

metric or imperial