def Xtest_setupI18n(self): """Gui translations are working.""" myUntranslatedString = 'Show/hide InaSAFE dock widget' myExpectedString = 'Tampilkan/hilangkan widget InaSAFE' myParent = QWidget() myCanvas = QgsMapCanvas(myParent) myIface = QgisInterface(myCanvas) myPlugin = Plugin(myIface) myPlugin.setup_i18n('id') myTranslation = myPlugin.tr(myUntranslatedString) myMessage = '\nTranslated: %s\nGot: %s\nExpected: %s' % \ (myUntranslatedString, myTranslation, myExpectedString) assert myTranslation == myExpectedString, myMessage
def Xtest_ImpactFunctionI18n(self): """Library translations are working.""" # Import this late so that i18n setup is already in place # Test indonesian too myCanvas = QgsMapCanvas(PARENT) myIface = QgisInterface(myCanvas) myPlugin = Plugin(myIface) myPlugin.setup_i18n('id') # indonesian myExpectedString = 'Letusan gunung berapi' myTranslation = safeTr('A volcano eruption') myMessage = '\nTranslated: %s\nGot: %s\nExpected: %s' % \ ('A volcano eruption', myTranslation, myExpectedString) assert myTranslation == myExpectedString, myMessage
def test_setupI18n(self): """Gui translations are working.""" myUntranslatedString = 'Show/hide InaSAFE dock widget' myExpectedString = 'Tampilkan/hilangkan widget InaSAFE' myParent = QWidget() myCanvas = QgsMapCanvas(myParent) myIface = QgisInterface(myCanvas) myPlugin = Plugin(myIface) myPlugin.setupI18n('id') myTranslation = myPlugin.tr(myUntranslatedString) myMessage = '\nTranslated: %s\nGot: %s\nExpected: %s' % ( myUntranslatedString, myTranslation, myExpectedString) assert myTranslation == myExpectedString, myMessage
def Xtest_ImpactFunctionI18n(self): """Library translations are working.""" # Import this late so that i18n setup is already in place # Test indonesian too myCanvas = QgsMapCanvas(PARENT) myIface = QgisInterface(myCanvas) myPlugin = Plugin(myIface) myPlugin.change_i18n('id') # indonesian myExpectedString = 'Letusan gunung berapi' myTranslation = safeTr('A volcano eruption') message = '\nTranslated: %s\nGot: %s\nExpected: %s' % \ ('A volcano eruption', myTranslation, myExpectedString) assert myTranslation == myExpectedString, message
def classFactory(iface): """Load Plugin class from file Plugin""" # setup the logging #import logging #logger = logging.getLogger('risiko') # TODO (TD): Change to read from a log file see # http://docs.python.org/howto/logging-cookbook.html#logging-cookbook # FIXME (TD): Logger is working at this level but not in the impact #functions!! #logger.setLevel(logging.DEBUG) #ch = logging.FileHandler('risiko.log') #fmt_str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' #formatter = logging.Formatter(fmt_str) #ch.setFormatter(formatter) #logger.addHandler(ch) # Try loading the FunctionProvider #from impact_functions.core import FunctionProvider # FIXME (TD): reload doesn't seem to reload the plugins anything #logger.debug("reload core 3") from safe_qgis.plugin import Plugin return Plugin(iface)
def test_ImpactFunctionI18n(self): """Library translations are working.""" # Import this late so that i18n setup is already in place from safe.common.utilities import ugettext as tr # Test indonesian too myParent = QWidget() myCanvas = QgsMapCanvas(myParent) myIface = QgisInterface(myCanvas) myPlugin = Plugin(myIface) myPlugin.setupI18n('id') # indonesian myExpectedString = 'Letusan gunung berapi' myTranslation = tr('A volcano eruption') myMessage = '\nTranslated: %s\nGot: %s\nExpected: %s' % ( 'A volcano eruption', myTranslation, myExpectedString) assert myTranslation == myExpectedString, myMessage
def Xtest_Afrikaans(self): """Test that Afrikaans translations are working""" # Note this has really bad side effects - lots of tests suddenly start # breaking when this test is enabled....disabled for now, but I have # left the test here for now as it illustrates one potential avenue # that can be pursued if dynamically changing the language to unit test # different locales ever becomes a requirement. # Be sure nose tests all run cleanly before reintroducing this! # This is part test and part demonstrator of how to reload inasafe # Now see if the same function is delivered for the function # Because of the way impact plugins are loaded in inasafe # (see http://effbot.org/zone/metaclass-plugins.htm) # lang in the context of the ugettext function in inasafe libs # must be imported late so that i18n is set up already from safe.common.utilities import ugettext as tr myUntranslatedString = 'Temporarily Closed' myExpectedString = 'Tydelik gesluit' # afrikaans myTranslation = tr(myUntranslatedString) myMessage = '\nTranslated: %s\nGot: %s\nExpected: %s' % ( myUntranslatedString, myTranslation, myExpectedString) assert myTranslation == myExpectedString, myMessage myParent = QWidget() myCanvas = QgsMapCanvas(myParent) myIface = QgisInterface(myCanvas) # reload all inasafe modules so that i18n get picked up afresh # this is the part that produces bad side effects for myMod in sys.modules.values(): try: if ('storage' in str(myMod) or 'impact' in str(myMod)): print 'Reloading:', str(myMod) reload(myMod) except NameError: pass myPlugin = Plugin(myIface) myPlugin.setupI18n('af') # afrikaans myLang = os.environ['LANG'] assert myLang == 'af' from safe_qgis.safe_interface import getSafeImpactFunctions #myFunctions = getSafeImpactFunctions() #print myFunctions myFunctions = getSafeImpactFunctions('Tydelik gesluit') assert len(myFunctions) > 0
def test_ImpactFunctionI18n(self): """Library translations are working.""" # Import this late so that i18n setup is already in place from safe.common.utilities import ugettext as _ myUntranslatedString = 'Temporarily Closed' # Test indonesian too myParent = QWidget() myCanvas = QgsMapCanvas(myParent) myIface = QgisInterface(myCanvas) myPlugin = Plugin(myIface) myPlugin.setupI18n('id') # indonesian myExpectedString = 'Ditutup sementara' myTranslation = _(myUntranslatedString) myMessage = '\nTranslated: %s\nGot: %s\nExpected: %s' % ( myUntranslatedString, myTranslation, myExpectedString) assert myTranslation == myExpectedString, myMessage
def classFactory(iface): """Load Plugin class from file Plugin""" # Try loading the FunctionProvider # from impact_functions.core import FunctionProvider # FIXME (TD): reload doesn't seem to reload the plugins #logger.debug("reload core 3") from safe_qgis.plugin import Plugin return Plugin(iface)
def classFactory(iface): """Load Plugin class from file Plugin.""" from safe_qgis.plugin import Plugin return Plugin(iface)