예제 #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 __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)))
예제 #3
0
 def keySave(self):
     config.osd.language.value = self.currentLocale
     config.osd.language.save()
     config.misc.locale.value = self.currentLocale
     language, country = international.splitLocale(self.currentLocale)
     config.misc.language.value = language
     config.misc.country.value = country
     config.misc.locale.save()
     config.misc.language.save()
     config.misc.country.save()
     international.activateLocale(self.currentLocale, runCallbacks=True)
     self.close()
예제 #4
0
 def run(self, justlocal=False):
     locale = self["locales"].getCurrent()[self.LIST_LOCALE]
     if locale != config.osd.language.value:
         config.osd.language.value = locale
         config.osd.language.save()
     if locale != config.misc.locale.value:
         config.misc.locale.value = locale
         language, country = international.splitLocale(locale)
         config.misc.language.value = language
         config.misc.country.value = country
         config.misc.locale.save()
         config.misc.language.save()
         config.misc.country.save()
     if justlocal:
         return
     international.activateLocale(locale, runCallbacks=True)