I'd like to write a wxPy开发者_运维知识库thon application that would run in different languages, updating itself automatically (with no need to close it and open it back) whenever I change the language. Is it possible to make a system that recognises and edits every widget that needs to be updated?
I don't think there is prebuilt facility or events in wxPython to trigger such change, but yes it is possible to write a system of your own e.g. you can have a central registry where each control which needs translation registers and when language changes you notify all those controls. It will be the responsibility of individual control to translate and update itself correctly.
Also see http://wiki.wxpython.org/RecipesI18n
I did it in that way created property file for each language and store translations into this file.
Translation config with UTF8 encoding
config = ConfigParser.SafeConfigParser()
config.readfp(codecs.open(fileName, "r", "utf8"))
translation looks like:
Time & Date=Время и дата
Time=Время
Local time=Местное время
精彩评论