Internationalization

Homey Apps support internationalization so that users can use your app in their native language.

Homey Apps can store translated strings as JSON files in the /locales/ folder with the language code as filename. For example the English translations of the app strings should be stored in /locales/en.json.

/locales/en.json
{
"title": "Hello World",
"hello": "Hello, __name__",
"settings": {
"title": "My Title",
"intro": "This is an example page."
},
"pair": {
"press_button": "Press the `pair` button on your device."
}
}

The translation object

In addition to the translation files you can define the translations directly inside the App Manifest. This is done by defining an object with the language code as keys and the translations as the values.

"title": {
"en": "Hello, World!",
"nl": "Hallo, wereld!"
}

You can also input a single string, when translation isn't necessary:

"title": "°C"

Always have at least an en translation! This is what Homey will fall-back on when the user language can't be found.

Supported language codes

The following languages are currently supported:

  • en: English

  • nl: Dutch

  • de: German

  • fr: French

  • it: Italian

  • sv: Swedish

  • no: Norwegian

  • es: Spanish

  • da: Danish

Translating a string from your app

In your App, Drivers or Devices you can call this.homey.__() with the correct key to get the translation.

/locales/en.json
{
"title": "Hello, World!"
}
/app.js
console.log(this.homey.__("title")); // "Hello, World!"

Or with a variable:

/locales/en.json
{
"hello": "Hello, __name__!"
}
/app.js
console.log(this.homey.__("hello", { name: "Dave" })); // "Hello, Dave!"

Translating a string in Custom views

Within your custom views, you can also use translations. For example:

/locales/en.json
{
"settings": {
"title": "My Title",
"intro": "This is an example page."
}
}
/settings/index.html
<span data-i18n="settings.title">
<!-- "My Title" will be placed here -->
</span>
<p data-i18n="settings.intro">
<!-- "This is an example page." will be placed here -->
</p>

It is also possible to get translated strings with JavaScript:

/settings/index.html
<script type="application/javascript">
function onHomeyReady(Homey) {
alert(Homey.__("settings.title")); // will alert "Settings page title"
}
</script>

To lean more about custom views you can read to the custom views guide.