def getLocalizationData(self, locales):
        self._console.debug("Generating localization data...")
        self._console.indent()

        data = {}
        root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")

        newlocales = locales
        for locale in locales:
            if len(locale) > 2 and locale[2] == "_":
              topLevelLocale = locale[0:2]
              if not topLevelLocale in locales:
                self._console.warn("Base locale %s not specified, trying to add it." % topLevelLocale)
                newlocales[:0] = [topLevelLocale]

        for entry in newlocales:
            if entry == "C":
                locale = "en"
            else:
                locale = entry
            locFile = os.path.join(root, "%s.xml" % locale)
            cacheId = "locale-%s-%s" % (root, locale)

            locDat = self._cache.read(cacheId, locFile)
            if locDat == None:
                self._console.debug("Processing locale: %s" % locale)
                locDat = cldr.parseCldrFile(locFile)
                self._cache.write(cacheId, locDat)

            data[entry] = locDat

        self._console.outdent()
        return data
Beispiel #2
0
    def getLocalizationData(self, locales):
        self._console.debug("Generating localization data...")
        self._console.indent()

        data = {}
        root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")
        for entry in locales:
            if entry == "C":
                locale = "en"
            else:
                locale = entry

            locFile = os.path.join(root, "%s.xml" % locale)
            cacheId = "locale-%s" % locale

            locDat = self._cache.read(cacheId, locFile)
            if locDat == None:
                self._console.debug("Processing locale: %s" % locale)
                locDat = cldr.parseCldrFile(locFile)
                self._cache.write(cacheId, locDat)

            data[entry] = locDat

        self._console.outdent()
        return data
Beispiel #3
0
    def getLocalizationData(
        self,
        classList,
        targetLocales,
    ):
        self._console.debug("Generating localization data...")
        data = {}

        # check need for cldr data in this classlist
        need_cldr = False
        for classId in classList:
            if self._classesObj[classId].getHints('cldr'):
                need_cldr = True
                break

        # early return
        if not need_cldr:
            return data

        # else collect cldr data
        self._console.indent()
        root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")

        newlocales = targetLocales
        for locale in targetLocales:
            if len(locale) > 2 and locale[2] == "_":
                topLevelLocale = locale[0:2]
                if not topLevelLocale in targetLocales:
                    self._console.warn(
                        "Base locale %s not specified, trying to add it." %
                        topLevelLocale)
                    newlocales[:0] = [topLevelLocale]

        for entry in newlocales:
            if entry == "C":
                locale = "en"
            else:
                locale = entry
            locFile = os.path.join(root, "%s.xml" % locale)
            cacheId = "locale-%s-%s" % (root, locale)

            locDat, _ = self._cache.read(cacheId, locFile)
            if locDat == None:
                self._console.debug("Processing locale: %s" % locale)
                locDat = cldr.parseCldrFile(locFile)
                self._cache.write(cacheId, locDat)

            data[entry] = locDat

        self._console.outdent()
        return data
Beispiel #4
0
    def getLocalizationData(self, locales):
        self._console.debug("Generating localization data...")
        self._console.indent()

        data = {}
        root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")
        for entry in locales:
            if entry == "C":
                locale = "en"
            else:
                locale = entry
            self._console.debug("Processing locale: %s" % locale)
            data[entry] = cldr.parseCldrFile(os.path.join(root, "%s.xml" % locale))

        self._console.outdent()
        return data
Beispiel #5
0
    def getLocalizationData(self, classList, targetLocales, ):
        self._console.debug("Generating localization data...")
        data = {}

        # check need for cldr data in this classlist
        need_cldr = False
        for clazz in classList:
            if clazz.getHints('cldr'):
                need_cldr = True
                break

        # early return
        if not need_cldr:
            return data


        # else collect cldr data
        self._console.indent()
        root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")

        newlocales = targetLocales
        for locale in targetLocales:
            if len(locale) > 2 and locale[2] == "_":
              topLevelLocale = locale[0:2]
              if not topLevelLocale in targetLocales:
                self._console.warn("Base locale %s not specified, trying to add it." % topLevelLocale)
                newlocales[:0] = [topLevelLocale]

        for entry in newlocales:
            if entry == "C":
                locale = "en"
            else:
                locale = entry
            locFile = os.path.join(root, "%s.xml" % locale)
            cacheId = "locale-%s-%s" % (root, locale)

            locDat, _ = self._cache.read(cacheId, locFile)
            if locDat == None:
                self._console.debug("Processing locale: %s" % locale)
                locDat = cldr.parseCldrFile(locFile)
                self._cache.write(cacheId, locDat)

            data[entry] = locDat

        self._console.outdent()
        return data