https://bugzilla.wikimedia.org/show_bug.cgi?id=55109
--- Comment #5 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- Logged In: YES user_id=880694 Originator: NO
Current status:
I have changed the text colorization system so that it is now possible to internationalize colorized strings.
There is now a branch called i18n which has gettext support. It works fine, and the selflink.py script can be run in German. There is a new config variable to set the UI lang, it will default to mylang and fall back to English if the chosen language is unsupported.
One disadvantage is that source code readability suffers. Before:
choice = wikipedia.inputChoice(u'\nWhat shall be done with this selflink?', ['unlink', 'make bold', 'skip', 'edit', 'more context'], ['U', 'b', 's', 'e', 'm'], 'u')
After:
choice = wikipedia.inputChoice(_(u'\nWhat shall be done with this selflink?'), [_('unlink'), _('make bold'), _('skip'), _('edit'), _('more context')], [_('u [unlink hotkey]'), _('b [make bold hotkey]'), _('s [skip hotkey]'), _('e [edit hotkey]'), _('m [more context hotkey]')], _('u [unlink hotkey]'))
valhallasw and I have discussed how to modify inputChoice() to make it less cluttered, but we didn't find a convincing solution. For example, inputChoice could be changed so that it works like this:
choice = wikipedia.inputChoice(_(u'What shall be done with this selflink?'), _(u'[u]nlink, make [b]old, [s]kip, [e]dit, [m]ore context'), 0)
so that it automatically parses the [brackets] to find out the hotkeys, and returns an integer for the option that was chosen. But integers make the code very hard to read and maintain when there are long if-elif constructions (... elif choice == 12 ...).
So, we currently don't know how to do it better. I think having full i18n is worth cluttering up the code a little bit.