def __init__(self):
     self.lang = {}
     for package in international.getInstalledPackages():
         locales = international.packageToLocales(package)
         if len(locales):
             language, country = international.splitLocale(locales[0])
             self.lang[locales[0]] = (
                 (international.getLanguageNative(language), language,
                  country, international.getLanguageEncoding(language)))
Exemple #2
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)