Get Language

How can I get the current language set for the Homey? I would prefer an object returning a code i.e. en,sv,nl so I can format i.e. Dates properly to the user.

Thanks, i have been searching but could not see it!

1 Like

Okey using import{Manager, Device} from ‘homey’ does not expose under l18n any getLanguage(). what Im I doing wrong? I should mention that I’m in code for the device (device.ts)

At the top of the aforementioned page:
“You can access this manager through the Homey instance as this.homey.i18n

So within your device class you can use this.homey.i18n.getLanguage()

I had to move my helper function inside the class to get that one to work.

Is it possible to fetch the language in the index.html for widgets?
It looks like this isn’t working het but i want to set the locale of momentjs here in index.html (script)

I also needed language and timezone. I passed it with the widget data from the app to the widget.

How?

Ah, sorry.
I use realtime events to pass data to the widget. Iy you are using the API, you can do the same.

2 Likes

I think you van just use Homey._language