def import_modified_ios_resource(self): repository.load() fileOperator = FileOperator() # 更新词条 for f in os.listdir(self.appConfig.ios_resources_root_directory): language = self.__get_ios_file_language(f) if len(language) <= 0: continue path = os.path.join(self.appConfig.ios_resources_root_directory, f, "Localizable.strings") dist = fileOperator.read_ios_keywords(path) for k, v in dist.items(): repository.try_ro_modify_keyword(k, v, language) # 重写 repo json repository.rewrite_repo_json()
def import_ios_resources(self): fileOperator = FileOperator() # 解析所有的多语言 for f in os.listdir(self.appConfig.ios_resources_root_directory): language = self.__get_ios_file_language(f) if len(language) <= 0: continue # 语言名称 self.support_languages.append(language) # 解析多语言的词条 for f in os.listdir(self.appConfig.ios_resources_root_directory): language = self.__get_ios_file_language(f) if len(language) <= 0: continue path = os.path.join(self.appConfig.ios_resources_root_directory, f, "Localizable.strings") dist = fileOperator.read_ios_keywords(path) logging.debug("Read iOS keywords : " + str(dist)) for k, v in dist.items(): if k not in self.keywords: self.keywords.append(k) if k not in self.translates: self.translates[k] = {} for support_language in self.support_languages: if support_language != language: self.translates[k][support_language] = "" else: self.translates[k][support_language] = v # 新增多语言的情况:要为应用初始化的时候选中的多语言设置词条 for sl in self.appConfig.support_languages: if sl not in self.support_languages: for k, v in self.translates.items(): self.translates[k][sl] = "" # 输出用于调试的日志 self.appConfig.add_support_languages(self.support_languages) logging.debug("Parsed From iOS Resources : " + str(self.support_languages)) logging.debug("Parsed Keywords : " + str(self.keywords)) logging.debug(self.translates)