def update_all_translations(): """Update the translations in every active widget""" global translated_widgets guitranslations.set_translations() objecttranslations.set_translations() for (filename, widget) in translated_widgets.iteritems(): widget = widget() # resolve weakref if not widget: continue all_widgets = guitranslations.text_translations.get(filename, {}) for (element_name, attribute), translation in all_widgets.iteritems(): element = widget.findChild(name=element_name) replace_attribute(element, attribute, translation) widget.adaptLayout()
def update_all_translations(): """Update the translations in every active widget""" from horizons.gui.gui import build_help_strings global translated_widgets guitranslations.set_translations() objecttranslations.set_translations() for (filename, widget) in translated_widgets.iteritems(): widget = widget() # resolve weakref if not widget: continue for (element_name, attribute), translation in guitranslations.text_translations.get(filename,{}).iteritems(): element = widget.findChild(name=element_name) replace_attribute(element, attribute, translation) if filename == 'help.xml': build_help_strings(widget) widget.adaptLayout()
def update_all_translations(): """Update the translations in every active widget""" import horizons.main global translated_widgets guitranslations.set_translations() objecttranslations.set_translations() for (filename, widget) in translated_widgets.iteritems(): widget = widget() # resolve weakref if not widget: continue all_widgets = guitranslations.text_translations.get(filename, {}) for (element_name, attribute), translation in all_widgets.iteritems(): element = widget.findChild(name=element_name) replace_attribute(element, attribute, translation) if filename == 'help.xml': horizons.main._modules.gui.build_help_strings() widget.adaptLayout()
import platform import gettext import os import logging import locale import weakref from horizons.constants import LANGUAGENAMES from horizons.i18n import objecttranslations, guitranslations from horizons.i18n.utils import get_fontdef_for_locale, find_available_languages log = logging.getLogger("i18n") # init translations guitranslations.set_translations() objecttranslations.set_translations() # save translated widgets translated_widgets = {} def translate_widget(untranslated, filename): """ Load widget translations from guitranslations.py file. Its entries look like {element_name: (attribute, translation)}. The translation is not applied to inactive widgets. Check update_all_translations for the application. """ global translated_widgets if filename in guitranslations.text_translations: for entry in guitranslations.text_translations[filename].iteritems(): widget = untranslated.findChild(name=entry[0][0])