Exemplo n.º 1
0
    def _select_locale(self, locale):
        """
        Try to select the given locale in the language and locale
        treeviews. This method tries to find the best match for the given
        locale.

        :return: a pair of selected iterators (language and locale)
        :rtype: a pair of GtkTreeIter or None objects

        """

        # get lang and select it
        parts = localization.parse_langcode(locale)
        if "language" not in parts:
            # invalid locale, cannot select
            return (None, None)

        lang_itr = set_treeview_selection(self._langView,
                                          parts["language"],
                                          col=2)

        # find matches and use the one with the highest rank
        locales = localization.get_language_locales(locale)
        locale_itr = set_treeview_selection(self._localeView,
                                            locales[0],
                                            col=1)

        return (lang_itr, locale_itr)
Exemplo n.º 2
0
    def get_locales(self, language_id):
        """Get locales available for the specified language.

        For example: ["de_DE.UTF-8", "de_AT.UTF-8", ... ]

        :return: a list of locale ids
        """
        return get_language_locales(language_id)
Exemplo n.º 3
0
    def __init__(self, app, data, storage, payload, instclass):
        NormalTUISpoke.__init__(self, app, data, storage, payload, instclass)

        self._langs = [localization.get_english_name(lang)
                        for lang in localization.get_available_translations()]
        self._langs_and_locales = dict((localization.get_english_name(lang), lang)
                                for lang in localization.get_available_translations())
        self._locales = dict((lang, localization.get_language_locales(lang))
                                for lang in self._langs_and_locales.values())
        self._selected = self.data.lang.lang
Exemplo n.º 4
0
    def __init__(self, app, data, storage, payload, instclass):
        NormalTUISpoke.__init__(self, app, data, storage, payload, instclass)

        self._langs = [localization.get_english_name(lang)
                        for lang in localization.get_available_translations()]
        self._langs_and_locales = dict((localization.get_english_name(lang), lang)
                                for lang in localization.get_available_translations())
        self._locales = dict((lang, localization.get_language_locales(lang))
                                for lang in self._langs_and_locales.values())
        self._selected = self.data.lang.lang
Exemplo n.º 5
0
    def _refresh_locale_store(self, lang):
        """Refresh the localeStore with locales for the given language."""

        self._localeStore.clear()
        locales = localization.get_language_locales(lang)
        for locale in locales:
            self._add_locale(self._localeStore,
                             localization.get_native_name(locale), locale)

        # select the first locale (with the highest rank)
        set_treeview_selection(self._localeView, locales[0], col=1)
Exemplo n.º 6
0
 def _mark_selected_language_bold(self,
                                  column,
                                  renderer,
                                  model,
                                  itr,
                                  user_data=None):
     lang_locales = set(localization.get_language_locales(model[itr][2]))
     if not lang_locales.isdisjoint(self._selected_locales):
         renderer.set_property("weight", Pango.Weight.BOLD.real)
     else:
         renderer.set_property("weight", Pango.Weight.NORMAL.real)
Exemplo n.º 7
0
    def _refresh_locale_store(self, lang):
        """Refresh the localeStore with locales for the given language."""

        self._localeStore.clear()
        locales = localization.get_language_locales(lang)
        for locale in locales:
            self._add_locale(self._localeStore,
                             localization.get_native_name(locale),
                             locale)

        # select the first locale (with the highest rank)
        set_treeview_selection(self._localeView, locales[0], col=1)
Exemplo n.º 8
0
    def __init__(self, data, storage, payload, instclass):
        NormalTUISpoke.__init__(self, data, storage, payload, instclass)
        self.title = N_("Language settings")
        self.initialize_start()
        self._container = None

        self._langs = [localization.get_english_name(lang)
                       for lang in localization.get_available_translations()]
        self._langs_and_locales = dict((localization.get_english_name(lang), lang)
                                       for lang in localization.get_available_translations())
        self._locales = dict((lang, localization.get_language_locales(lang))
                             for lang in self._langs_and_locales.values())
        self._selected = self.data.lang.lang
        self.initialize_done()
Exemplo n.º 9
0
    def __init__(self, data, storage, payload, instclass):
        NormalTUISpoke.__init__(self, data, storage, payload, instclass)
        self.title = N_("Language settings")
        self.initialize_start()
        self._container = None

        self._langs = [
            localization.get_english_name(lang)
            for lang in localization.get_available_translations()
        ]
        self._langs_and_locales = dict(
            (localization.get_english_name(lang), lang)
            for lang in localization.get_available_translations())
        self._locales = dict((lang, localization.get_language_locales(lang))
                             for lang in self._langs_and_locales.values())
        self._selected = self.data.lang.lang
        self.initialize_done()
Exemplo n.º 10
0
    def __init__(self, data, storage, payload):
        NormalTUISpoke.__init__(self, data, storage, payload)
        self.title = N_("Language settings")
        self.initialize_start()
        self._container = None

        self._langs = [
            localization.get_english_name(lang)
            for lang in localization.get_available_translations()
        ]
        self._langs_and_locales = dict(
            (localization.get_english_name(lang), lang)
            for lang in localization.get_available_translations())
        self._locales = dict((lang, localization.get_language_locales(lang))
                             for lang in self._langs_and_locales.values())

        self._l12_module = LOCALIZATION.get_observer()
        self._l12_module.connect()

        self._selected = self._l12_module.proxy.Language
        self.initialize_done()
Exemplo n.º 11
0
    def _select_locale(self, locale):
        """
        Try to select the given locale in the language and locale
        treeviews. This method tries to find the best match for the given
        locale.

        :return: a pair of selected iterators (language and locale)
        :rtype: a pair of GtkTreeIter or None objects

        """

        # get lang and select it
        parts = localization.parse_langcode(locale)
        if "language" not in parts:
            # invalid locale, cannot select
            return (None, None)

        lang_itr = set_treeview_selection(self._langView, parts["language"], col=2)

        # find matches and use the one with the highest rank
        locales = localization.get_language_locales(locale)
        locale_itr = set_treeview_selection(self._localeView, locales[0], col=1)

        return (lang_itr, locale_itr)
Exemplo n.º 12
0
 def _is_lang_selected(self, lang):
     lang_locales = set(localization.get_language_locales(lang))
     return not lang_locales.isdisjoint(self._selected_locales)
Exemplo n.º 13
0
 def _is_lang_selected(self, lang):
     lang_locales = set(localization.get_language_locales(lang))
     return not lang_locales.isdisjoint(self._selected_locales)
Exemplo n.º 14
0
 def _mark_selected_language_bold(self, column, renderer, model, itr, user_data=None):
     lang_locales = set(localization.get_language_locales(model[itr][2]))
     if not lang_locales.isdisjoint(self._selected_locales):
         renderer.set_property("weight", Pango.Weight.BOLD.real)
     else:
         renderer.set_property("weight", Pango.Weight.NORMAL.real)