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. See these two example translation files for English and Dutch:
These files define translations with the ID's: title
, greeting
, settings.title
, settings.intro
, and pair.press_button
. If a translated string with a certain ID is not present in the locale file for the users locale Homey will fall-back to English.
Your app's README.txt
can also be translated by creating additional README.<languagecode>.txt
files. For exampleREADME.nl.txt
would contain the Dutch translation of the readme.
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.
You can also input a single string, when translation isn't necessary:
Always have at least an en
translation! This is what Homey will fall-back on when the user language can't be found.
Temperature conversion
Your Homey app should always use Celsius internally, Homey will automatically converts capability values from Celsius to Fahrenheit. For custom capabilities make sure the "unit"
is set to "°C"
to let Homey know that this value should be converted.
Supported Languages
The following languages are currently supported for any Homey app.
en
: Englishnl
: Dutchde
: Germanfr
: Frenchit
: Italiansv
: Swedishno
: Norwegianes
: Spanishda
: Danishru
: Russianpl
: Polishko
: South Korean
Translating a string from your app
In your App, Drivers or Devices you can call this.homey.__()
with the identifier of the translated string to get the translation. In the following example we define a translation with the ID title
and use the translation in app.js
.
You can also use variables in your translations. In the translated string variables are surrounded by two underscores (__
). To get the translated string with variables you should pass an object to this.homey.__()
as the second argument with the values that you want to use for those variables.
Translating a string in Custom views
Within your custom views, you can also use translations. For example:
It is also possible to get translated strings with JavaScript:
To lean more about custom views you can read to the custom views guide.
Translating with OpenAI
To translate your app automatically, Homey CLI has a built-in integration that asks OpenAI to translate all .json
and README.txt
files. First, create an OpenAI API Key at https://platform.openai.com/api-keys and connect a payment method.
Then, execute in a command line:
We found that translating an entire app usually costs less than $1.
Last updated