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