shaonianzhentan / node-red-contrib-ha-mqtt

在HomeAssistant中生成MQTT实体
https://github.com/shaonianzhentan/node-red-contrib-ha-mqtt
MIT License
37 stars 19 forks source link

Transition to i18n and add English translation #6

Closed benfiglin closed 2 years ago

benfiglin commented 2 years ago

This PR adds multi-language support per this document: https://nodered.org/docs/creating-nodes/i18n

As requested in #3, also adds English as the default language, while keeping the Chinese language available and auto-selected for installations with Node Red set up to Chinese.

Most of the translation strings are located in the locales/[_lang_]/common.json file, while some are within each individual node folder (only for those nodes that have specific definitions that are not common among the other nodes).

I tried to keep anything i18n specific out of the HomeAssistant.js file, since I wanted to keep this class/file language-neutral and to only be responsible for constructing and sending MQTT messages to HA, and not for sending language-specific messages back to the Node Red editor.

Please review and let me know if I should fix anything.

@emkookmer, I'm mentioning you here since you were interested in this too.