def Xtest_setup_i18n(self): """Gui translations are working.""" unstranslated = 'Show/hide InaSAFE dock widget' expected = 'Tampilkan/hilangkan widget InaSAFE' parent = QWidget() canvas = QgsMapCanvas(parent) iface = QgisInterface(canvas) plugin = Plugin(iface) plugin.change_i18n('id') translation = plugin.tr(unstranslated) message = '\nTranslated: %s\nGot: %s\nExpected: %s' % \ (unstranslated, translation, expected) assert translation == expected, message
def Xtest_impact_function_i18n(self): """Library translations are working.""" # Import this late so that i18n setup is already in place # Test indonesian too canvas = QgsMapCanvas(PARENT) iface = QgisInterface(canvas) plugin = Plugin(iface) plugin.change_i18n('id') # indonesian expected = 'Letusan gunung berapi' translation = tr('A volcano eruption') message = '\nTranslated: %s\nGot: %s\nExpected: %s' % ( 'A volcano eruption', translation, expected) assert translation == expected, message
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 # import PyQt4.QtCore.QObject.tr as tr untranslated = 'Temporarily Closed' expected = 'Tydelik gesluit' # afrikaans translated = tr(untranslated) message = '\nTranslated: %s\nGot: %s\nExpected: %s' % \ (untranslated, translated, expected) assert translated == expected, message parent = QWidget() canvas = QgsMapCanvas(parent) iface = QgisInterface(canvas) # reload all inasafe modules so that i18n get picked up afresh # this is the part that produces bad side effects for mod in sys.modules.values(): try: if 'storage' in str(mod) or 'impact' in str(mod): print 'Reloading:', str(mod) reload(mod) except NameError: pass plugin = Plugin(iface) plugin.change_i18n('af') # afrikaans language = os.environ['LANG'] assert language == 'af' # functions = get_safe_impact_function() # print functions functions = ImpactFunctionManager().get('Tydelik gesluit') assert len(functions) > 0
def classFactory(iface): """Load Plugin class from file Plugin.""" # Try to import submodule to check if there are present. try: from parameters.generic_parameter import GenericParameter except ImportError: # Don't use safe.utilities.i18n.tr as we need to be outside of `safe`. # Some safe functions will import safe_extras.parameters QMessageBox.warning( None, QCoreApplication.translate('@default', 'InaSAFE submodule not found'), QCoreApplication.translate( '@default', 'InaSAFE could not find the submodule "parameters". ' 'You should do "git submodule update" or if you need a new ' 'clone, do "git clone --recursive [email protected]:inasafe/' 'inasafe.git". Finally, restart QGIS.')) from safe.plugin import Plugin return Plugin(iface)
def classFactory(iface): """Load Plugin class from file Plugin.""" from safe.plugin import Plugin return Plugin(iface)