@@ -36,7 +36,7 @@ def __init__(self, api, about, owner, hide_commands, before_help,
3636 after_help , link_preview_in_help ,
3737 validate_callback_signatures , process_backlog , lang , itself ,
3838 commands_re , commands , chains , scheduler , main_component_id ,
39- bot_id , shared_memory , update_processors ):
39+ bot_id , shared_memory , update_processors , override_i18n ):
4040 # This attribute should be added with the default setattr, because is
4141 # needed by the custom setattr
4242 object .__setattr__ (self , "_frozen" , False )
@@ -61,6 +61,7 @@ def __init__(self, api, about, owner, hide_commands, before_help,
6161 self ._update_processors = update_processors
6262 self ._commands = {name : command .for_bot (self )
6363 for name , command in commands .items ()}
64+ self .override_i18n = override_i18n
6465
6566 # Setup the logger
6667 self .logger = logbook .Logger ('botogram bot' )
@@ -82,7 +83,7 @@ def __reduce__(self):
8283 self .validate_callback_signatures , self .process_backlog , self .lang ,
8384 self .itself , self ._commands_re , self ._commands , self ._chains ,
8485 self ._scheduler , self ._main_component_id , self ._bot_id ,
85- self ._shared_memory , self ._update_processors ,
86+ self ._shared_memory , self ._update_processors , self . override_i18n
8687 )
8788 return restore , args
8889
@@ -240,7 +241,12 @@ def register_update_processor(self, kind, processor):
240241
241242 def _ (self , message , ** args ):
242243 """Translate a string"""
243- return self ._lang_inst .gettext (message ) % args
244+ # Check if the message has been overridden
245+ if message in self .override_i18n :
246+ return self .override_i18n [message ] % args
247+ # Otherwise try to return the original message
248+ else :
249+ return self ._lang_inst .gettext (message ) % args
244250
245251 # And some internal methods used by botogram
246252
0 commit comments