Hubot: hubot-i18n
A hubot script to support i18n.
Basic usage
Use environment variable HUBOT_LANG=language-tag
to specify hubot language.
# Init i18n = roboti18n 'unique name' # You can load i18n config serverl times i18nload "language-tag": message: "${ robot_name } support i18n now" # simple way respond: /.*i18n\s+awesome.*/i # complex way respond: match: /.*i18n\s+awesome.*/i # You can modify `msg` before pass in Listener : msg.match = null'R2-D2' msg # Use it robotrespond i18nt'respond'i18nc 'respond' msgsend i18nt'message'robot_name: msgmatch1 #=> R2-D2 support i18n now
Patch mode
You can internationalize other plugin with patch mode by using environment variable HUBOT_I18N_PATCH=true
.
Example for hubot-help.
# In your scripts/ file = # The module name must be `patch` i18n = roboti18n 'patch' i18nload 'zh-CN': # key is RegExp.source 'help\\s*(.*)?$': match: /?\s*?\s*?命令$/i : match = msgmatch msg.match = match0match2 msg