def testWxMessageFactory(self): if not self._wx_available: return self.assertEquals(w("Cancel"), u"Annuler") self.assertEquals(w("&Quit"), u"&Quitter") self.i18nMan.setLocaleSet("es_UY") self.assertEquals(w("Cancel"), u"Cancelar") self.assertEquals(w("&Quit"), u"&Salir") self.i18nMan.setLocaleSet("en") self.assertEquals(w("Cancel"), u"Cancel") self.assertEquals(w("&Quit"), u"&Quit") # The 'test' locale is a debug keyword # which sets the locale set to ['fr_CA', 'fr'] # and enables the testing mode flag. # In testing mode all values returned by # the WxMessageFactory method insert # a (WX): at the start of the string. self.i18nMan.setLocaleSet("test") self.assertEquals(w("Cancel"), u"(WX): Annuler") self.assertEquals(w("&Quit"), u"(WX): &Quitter") # Restore the default locale set self.i18nMan.setLocaleSet(self.LOCALE_SET)
import sys, os from i18n import wxMessageFactory as w """ Command line utility to confirm that wx localization files are loaded And options locale can be specified on the command line: If no locale is passed the System default locale is used: Load the French wx translations: =================================== ./release/RunPython i18n/tests/wxLocalizationTest.py fr Load the System default wx translations: =================================== ./release/RunPython i18n/tests/wxLocalizationTest.py """ i18nMan = i18n._I18nManager if len(sys.argv) > 1: i18nMan.initialize(sys.argv[1]) else: i18nMan.initialize(None) print "Using Locale: ", i18n.getLocaleSet()[0] print "Cancel: ", w("Cancel").encode("utf8") print "Quit: ", w("&Quit").encode("utf8")
def translate(): print "Using Locale: ", i18n.getLocaleSet()[0] print "Cancel: ", w("Cancel").encode("utf8") print "Quit: ", w("&Quit").encode("utf8")
from application import Utility import i18n import sys, os from i18n import wxMessageFactory as w """ Command line utility to confirm that wx localization files are loaded And options locale can be specified on the command line: If no locale is passed the System default locale is used: Load the French wx translations: =================================== ./release/RunPython i18n/tests/wxLocalizationTest.py fr Load the System default wx translations: =================================== ./release/RunPython i18n/tests/wxLocalizationTest.py """ i18nMan = i18n._I18nManager if len(sys.argv) > 1: i18nMan.initialize(sys.argv[1]) else: i18nMan.initialize(None) print "Using Locale: ", i18n.getLocaleSet()[0] print "Cancel: ", w("Cancel").encode("utf8") print "Quit: ", w("&Quit").encode("utf8")