예제 #1
0
 def updateLocaleList(self, inUseLoc=None):
     if inUseLoc is None:
         inUseLoc = self.currentLocale
     self.localeList = []
     for package in international.getAvailablePackages():
         installStatus = self.PACK_INSTALLED if package in international.getInstalledPackages(
         ) else self.PACK_AVAILABLE
         locales = international.packageToLocales(package)
         for locale in locales:
             data = international.splitLocale(locale)
             if len(locales) > 1 and "%s-%s" % (data[0], data[1].lower(
             )) in international.getAvailablePackages():
                 continue
             png = LoadPixmap(
                 resolveFilename(SCOPE_GUISKIN,
                                 "countries/%s.png" % data[1].lower()))
             if png is None:
                 png = LoadPixmap(
                     resolveFilename(SCOPE_GUISKIN,
                                     "countries/missing.png"))
             name = "%s (%s)" % (LANGUAGE_DATA[data[0]][LANG_NAME], data[1])
             icon = self["icons"].pixmaps[
                 self.
                 PACK_INSTALLED] if installStatus == self.PACK_INSTALLED else self[
                     "icons"].pixmaps[self.PACK_AVAILABLE]
             if locale == inUseLoc:
                 status = self.PACK_IN_USE
                 icon = self["icons"].pixmaps[self.PACK_IN_USE]
             else:
                 status = installStatus
             self.localeList.append(
                 (png, LANGUAGE_DATA[data[0]][LANG_NATIVE], name, locale,
                  package, icon, status))
             if config.locales.packageLocales.value == "P":
                 break
     if inUseLoc not in [x[self.LIST_LOCALE] for x in self.localeList]:
         data = international.splitLocale(inUseLoc)
         png = LoadPixmap(
             resolveFilename(SCOPE_GUISKIN,
                             "countries/%s.png" % data[1].lower()))
         if png is None:
             png = LoadPixmap(
                 resolveFilename(SCOPE_GUISKIN, "countries/missing.png"))
         name = "%s (%s)" % (LANGUAGE_DATA[data[0]][LANG_NAME], data[1])
         package = international.getPackage(inUseLoc)
         self.localeList.append(
             (png, LANGUAGE_DATA[data[0]][LANG_NATIVE], name, inUseLoc,
              package, self["icons"].pixmaps[self.PACK_IN_USE],
              self.PACK_IN_USE))
     sortBy = int(config.locales.localesSortBy.value)
     order = int(sortBy / 10) if sortBy > 9 else sortBy
     reverse = True if sortBy > 9 else False
     self.localeList = sorted(self.localeList,
                              key=lambda x: x[order],
                              reverse=reverse)
     self["locales"].updateList(self.localeList)
예제 #2
0
 def updateText(self):
     self.setTitle(_("Locale/Language Selection"))
     self["key_red"].text = _("Cancel")
     self["key_green"].text = _("Save")
     self["key_menu"].text = _("MENU")
     self["key_info"].text = _("INFO")
     self["key_help"].text = _("HELP")
     current = self["locales"].getCurrent()
     locale = current[self.LIST_LOCALE]
     package = current[self.LIST_PACKAGE]
     status = current[self.LIST_STATUS]
     if international.splitPackage(package)[1] is None:
         detail = "%s - %s" % (international.getLanguageTranslated(locale),
                               package)
         if status == self.PACK_AVAILABLE:
             self["description"].text = _(
                 "Press OK to install and use this language.  [%s]"
             ) % detail
         elif status == self.PACK_INSTALLED:
             self["description"].text = _(
                 "Press OK to use this language.  [%s]") % detail
         else:
             self["description"].text = _(
                 "This is the currently selected language.  [%s]") % detail
         deleteButton = _("Delete Lang")
         installButton = _("Install Lang")
     else:
         detail = "%s (%s) %s" % (international.getLanguageTranslated(
             locale), international.getCountryTranslated(locale), locale)
         if status == self.PACK_AVAILABLE:
             self["description"].text = _(
                 "Press OK to install and use this locale.  [%s]") % detail
         elif status == self.PACK_INSTALLED:
             self["description"].text = _(
                 "Press OK to use this locale.  [%s]") % detail
         else:
             self["description"].text = _(
                 "This is the currently selected locale.  [%s]") % detail
         deleteButton = _("Delete Loc")
         installButton = _("Install Loc")
     if package != international.getPackage(self.currentLocale):
         self["manageActions"].setEnabled(True)
         self[
             "key_yellow"].text = deleteButton if status == self.PACK_INSTALLED else installButton
     elif international.getPurgablePackages(self.currentLocale):
         self["manageActions"].setEnabled(True)
         self["key_yellow"].text = _("Purge")
     else:
         self["manageActions"].setEnabled(False)
         self["key_yellow"].text = ""