bernard357 / shellbot

Fast, simple and lightweight micro bot-framework for Python.
Apache License 2.0
10 stars 3 forks source link

Internationalization @ Localization #35

Closed guillain closed 7 years ago

guillain commented 7 years ago

Hi, Capability to set langage file to overload the EN default langage can be very interesting ;) Thanks!

guillain commented 7 years ago

Nice to see the coming improvement ;) Thanks!

bernard357 commented 7 years ago

Guillain, I was thinking today about some shortcut here. Maybe we could add customized strings in a configuration file, instead of depending of fully-fledged internationalization? At least this would allow you to respond quickly to the pressing demand of your client. Let me know your thoughts

bernard357 commented 7 years ago

Ok, here you go with 042a6feb639b7e25ef90d9fd540f746bfb05244c as a potential solution for this issue. Now you can define customized strings in settings given to shellbot, either from python code (with a dictionary) or from YAML. The top-level keyword to use is customized. The value should be a dictionary where original strings are keys, and customized strings are values.

For example to translate some strings in French:

customized:
  "help": "aide"
  "next": "suivant"

Thanks for your next feedback

bernard357 commented 7 years ago

As per tests done today with Guillain: while the configuration of customized strings is loaded in memory, it is not taken into account by the engine. This has to be fixed and tested.

bernard357 commented 7 years ago

with daf64fbab4085d1591bf9a1aecd06b4fc615d132 all built-in commands can be translated via configuration; use localized keyword like this:

            'localized': 
                'help': 'aide'
                'help <command>': 'aide <commande>'
                'Show commands and usage': 'Liste les commandes et leur usage'
                'Available commands:': 'Commandes disponibles :'
                "Sorry, I do not know how to handle '{}'": "Désolé, je ne sais pas traiter '{}'"
                'usage: {}': 'utilisation : {}'
                u'Thank you for the information shared!': "Merci pour le partage d'informations !"

What do you think?

guillain commented 7 years ago

Yep, Last update works perfectly, thanks master ;)

bernard357 commented 7 years ago

great news, thanks for the (positive) feed-back! let move to other issues on the backlog :-)