I have a application written in wxPython which I want to make multilingual. Our options are
- using gettext http://docs.python.org/library/gettext.html
- seprating out all UI text to a messages.py file, and using it to translate text
I am very much inclined towards 2nd and I see no benefit in going gettext way, using 2nd way i can have all my messages at one place not in code, so If i need to change a message, code need not be changed, in case of gettext i may have confusing msg-constants as I will be just wrapping the orginal msg instead of converting it to a constant in messages.py
basically instead of
wx.MessageBox(_("Hi stackoverflow!"))
I think
wx.MessageBox(messages.GREET_SO)
is better, so is there any advantage in gettext way and disadvantage 2nd way? and is there a 3rd way?
edit: also gettext languages files seems to be too tied to code, and what happens if i want two messages same in english but different in french e.g. suppose french has more subtle translation for different scnerarios for english one is ok
experience: I have already gone 2nd way, and i must say every application should try to extract UI text from code, it gives a chance to refactor, see where UI is creeping into model and where UI text can be improved, gettext in comparison is mechanic, doesn't gives any input for coder, and i think would be more difficult to maintain.
and while creating a name for text e.g. PRINT_PROGRESS_MSG, gives a chance to see that at many places, same msg is being used slightly differently and can be merged into a single name, which later on will help when i need to change msg only once.
Conclusion: I am still not sure of any advantage to use gettext and am using my own messages file. but I have selected the answer which at least explained few points why gettext can be beneficial. The final solution IMO is which takes the best from both ways i.e my own message identifier wrapped by gettext e.g
wx.MessageBox(_("GREET_SO"))