ManagerI18n
homey.manager.i18n
Manages internationalization in the app.
You can access this manager through the Homey instance as self.homey.i18n.
Ancestors
- Manager
- SimpleClass
- homey.util.event_emitter.EventEmitter
- typing.Generic
- abc.ABC
Methods
get_strings
def get_strings(self) ‑> dict[str, Translations]Get the locale manifest for the language the Homey uses.
translate
def translate(self, key: str, **tags: str) ‑> str | NoneTranslate a string, as defined in the app's /locales/<language>.json file.
Example:
/locales/en.json
{ "welcome": "Welcome, __name__!" }
/app.py
welcome_message = self.homey.i18n.translate("welcome", name="Dave")
self.log(welcome_message)
Args
| Name | Type | Description |
|---|---|---|
key |
str | The key in the <language.json> file, with dots separating nesting. For example "errors.missing". |
tags |
str | A keyword mapping of tags in the string to replace. For example, for Hello, __name__! you could pass name="Dave". |
Returns
The translated string, or None if the key was not found.
get_language
def get_language(self) ‑> strGet the language the Homey uses.
Returns
A 2-character language code.
get_units
def get_units(self) ‑> Literal['metric', 'imperial']Get the units the Homey uses.