mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-07 01:40:41 +02:00
+ Adding a template for all messages : fixes #15
This commit is contained in:
parent
4b57c1107d
commit
d2545b2f0c
|
@ -295,7 +295,7 @@ class TransBot(Bot):
|
|||
lang_emoji= "🏳️🌈"
|
||||
answer = "%s %s" % (translated,lang_emoji)
|
||||
logging.debug(">> %s" % answer)
|
||||
self.chatter.send(answer)
|
||||
self.chatter.send( i18n.t('all_messages',message=answer) )
|
||||
# Returns as soon as one translation was done
|
||||
return
|
||||
else:
|
||||
|
@ -309,7 +309,7 @@ class TransBot(Bot):
|
|||
|
||||
def onExit( self ):
|
||||
|
||||
sent = self.chatter.send( i18n.t('Goodbye') )
|
||||
sent = self.chatter.send( i18n.t('all_messages',message=i18n.t('Goodbye')) )
|
||||
|
||||
|
||||
def run( self ):
|
||||
|
@ -320,7 +320,7 @@ class TransBot(Bot):
|
|||
2. Waits for messages to translate
|
||||
"""
|
||||
|
||||
self.chatter.send( i18n.t('Hello') )
|
||||
self.chatter.send( i18n.t('all_messages',message=i18n.t('Hello')) )
|
||||
self.registerExitHandler()
|
||||
self.chatter.start(self)
|
||||
|
||||
|
@ -416,8 +416,17 @@ if __name__ == '__main__':
|
|||
i18n.set('locale',config.locale.split('_')[0])
|
||||
logging.debug("i18n locale : %s"%i18n.get('locale'))
|
||||
i18n.set('filename_format', 'i18n.{locale}.{format}') # Removing the namespace from keys is simpler for us
|
||||
i18n.set('error_on_missing_translation',True)
|
||||
i18n.load_path.append(config.config_dir)
|
||||
|
||||
# These MUST be instanciated AFTER i18n has been configured !
|
||||
try:
|
||||
i18n.t('all_messages',message="")
|
||||
except:
|
||||
i18n.add_translation('all_messages',r'%{message}')
|
||||
if not config.shutdown:
|
||||
config.shutdown = i18n.t('all_messages',message=i18n.t('Shutdown'))
|
||||
|
||||
if not config.ibmcloud_url:
|
||||
raise ValueError("Missing required parameter : --ibmcloud-url")
|
||||
if not config.ibmcloud_apikey:
|
||||
|
@ -464,10 +473,6 @@ if __name__ == '__main__':
|
|||
except:
|
||||
raise ValueError("Could not open %s : please remove --languages to generate it automatically or create the file indicated with --languages-file"%config.languages_file)
|
||||
|
||||
if not config.shutdown:
|
||||
# This MUST be instanciated AFTER i18n has been configured !
|
||||
config.shutdown = i18n.t('Shutdown')
|
||||
|
||||
# Creates the chat engine depending on the 'backend' parameter
|
||||
if config.backend == "signal":
|
||||
if not config.signal_cli:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
en:
|
||||
Hello: 🤟 nicobot ready 🤟
|
||||
# If present, this is a template to use for all messages
|
||||
all_messages: 🤖 %{message}
|
||||
Hello: nicobot ready 🤟
|
||||
Goodbye: See you later 👋
|
||||
Shutdown: bye nicobot
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
fr:
|
||||
Hello: "🤟 nicobot paré 🤟"
|
||||
# If present, this is a template to use for all messages
|
||||
all_messages: 🤖 %{message}
|
||||
Hello: nicobot paré 🤟
|
||||
Goodbye: A+ 👋
|
||||
Shutdown: couché nicobot
|
||||
|
|
Loading…
Reference in a new issue