示例#1
0
    def add_locale_to_build(cfg):
        # Bug 730776: Ignore locales for addon-kit, that are only for unit tests
        if not is_running_tests and cfg.name == "addon-sdk":
            return

        path = resolve_dir(cfg, cfg['locale'])
        files = os.listdir(path)
        for filename in files:
            fullpath = os.path.join(path, filename)
            if os.path.isfile(fullpath) and filename.endswith('.properties'):
                language = filename[:-len('.properties')]

                from property_parser import parse_file, MalformedLocaleFileError
                try:
                    content = parse_file(fullpath)
                except MalformedLocaleFileError, msg:
                    print msg[0]
                    sys.exit(1)

                # Merge current locales into global locale hashtable.
                # Locale files only contains one big JSON object
                # that act as an hastable of:
                # "keys to translate" => "translated keys"
                if language in build.locale:
                    merge = (build.locale[language].items() +
                             content.items())
                    build.locale[language] = Bunch(merge)
                else:
                    build.locale[language] = content
示例#2
0
    def add_locale_to_build(cfg):
        path = resolve_dir(cfg, cfg['locale'])
        files = os.listdir(path)
        for filename in files:
            fullpath = os.path.join(path, filename)
            if os.path.isfile(fullpath) and filename.endswith('.properties'):
                language = filename[:-len('.properties')]

                from property_parser import parse_file
                content = parse_file(fullpath)

                # Merge current locales into global locale hashtable.
                # Locale files only contains one big JSON object
                # that act as an hastable of:
                # "keys to translate" => "translated keys"
                if language in build.locale:
                    merge = (build.locale[language].items() + content.items())
                    build.locale[language] = Bunch(merge)
                else:
                    build.locale[language] = content
示例#3
0
    def add_locale_to_build(cfg):
        path = resolve_dir(cfg, cfg['locale'])
        files = os.listdir(path)
        for filename in files:
            fullpath = os.path.join(path, filename)
            if os.path.isfile(fullpath) and filename.endswith('.properties'):
                language = filename[:-len('.properties')]

                from property_parser import parse_file
                content = parse_file(fullpath)

                # Merge current locales into global locale hashtable.
                # Locale files only contains one big JSON object
                # that act as an hastable of:
                # "keys to translate" => "translated keys"
                if language in build.locale:
                    merge = (build.locale[language].items() +
                             content.items())
                    build.locale[language] = Bunch(merge)
                else:
                    build.locale[language] = content