def __s2r(self): logging.debug("Pushing strings into resources...") if isSystemLevelStringTable(self.__input): logging.debug("\tString table file is System Level.") file = SysStrTblFile( self.__input ) file.load() for cpath,name in self.__output: resource = scanRCFile(cpath) if not self.__validLangcode(resource._langcode): logging.debug("\t\tIgnoring '%s' because its not the right langcode. @> %s"%(name,cpath)) continue try: projFile = file.genProjLevelFile( resource._name, '' ) except KeyError: logging.warning("Project %s does not exist in %s"%(resource._name, self.__input)) continue resource.updateStringTables(projFile) else: logging.debug("\tString Table File is Project or Language Level.") projFile = RCStrTblFile( self.__input ) projFile.load() langs = projFile._table.getPossibleLangs() for cpath,name in self.__output: resource = scanRCFile(cpath) if not self.__validLangcode(resource._langcode): logging.debug("\t\tIgnoring '%s' because its not the right langcode. @> %s"%(name,cpath)) continue if resource._langcode in langs: logging.debug("\t\tUpdating %s @> %s"%(name,cpath)) resource.updateStringTables(projFile) else: raise MissingLangCodeError()
def __trans2sys(self): logging.debug("Pushing Translator into System Level Utilities...") trans = TranslationFile( self.__input, self.__defaultLangCode() ) trans.load() if self.__makenew: logging.debug("\tPulling out new sys utils") trans.getSysMenuFile( opath.join(self.__outputPath, "System_Strings.master.menus"), True, self.__langcodes ) trans.getSysDialogFile( opath.join(self.__outputPath, "System_Strings.master.dialogs"), True, self.__langcodes ) trans.getSysStrTblFile( opath.join(self.__outputPath, "System_Strings.master.strtbls"), True, self.__langcodes ) logging.debug("\tSaved new system files from translator!") return logging.debug("\tPulling new sys utils to merge") menuFile = trans.getSysMenuFile('') dlogFile = trans.getSysDialogFile('') strsFile = trans.getSysStrTblFile('') strtbl, menus, dlogs = False, False, False for cpath,_ in self.__output: if opath.splitext(cpath)[1] == "strtbls" and \ PusherOutputs.isStringTable( self.__outputType ): if strtbl: #only allow one? logging.warning("\tFound another system string table file. Skipping: %s"%cpath) continue tmp = SysStrTblFile(cpath) tmp.load() logging.debug("\tUpdating @> %s"%cpath) tmp.updateFromTranslation(strsFile, autosave=True) strtbl = True elif opath.splitext(cpath)[1] == "menus" and \ PusherOutputs.isMenu( self.__outputType ): if menus: #only allow one? logging.warning("\tFound another system menu file. Skipping: %s"%cpath) continue tmp = SysMenuFile(cpath) tmp.load() logging.debug("\tUpdating @> %s"%cpath) tmp.updateFromTranslation(menuFile, autosave=True) menus = True elif opath.splitext(cpath)[1] == "dialogs" and \ PusherOutputs.isDialog( self.__outputType ): if dlogs: #only allow one? logging.warning("\tFound another system dialog file. Skipping: %s"%cpath) continue tmp = SysDialogFile(cpath) tmp.load() logging.debug("\tUpdating @> %s"%cpath) tmp.updateFromTranslation(dlogFile, autosave=True) dlogs = True # after we're done, lets inform them if there was something missing. if not strtbl: logging.debug("\tCould not find system string table file!") if not dlogs: logging.debug("\tCould not find system dialog file!") if not menus: logging.debug("\tCould not find system menu file!")
def __genTranslator( self, langcodes, useExisting=False, keepInMem=False, save=True, ret=False, order=False, prunepath=None, markconflicts=False ): """Generate the translator file for the entire system.""" if self.__changeoutputs: newpath = opath.join(self.__outdir, Joiner.TRANS_FILENAME) else: newpath = opath.join(self.__sysdir, Joiner.TRANS_FILENAME) if not useExisting: menuFile, dialogFile, stringFile = self.__genSysLevelUtil(useExisting=False, useExistingLangLevel=False, keepInMem=keepInMem, save=False) else: #we must load by hand. basename = opath.join( self.__sysdir, Joiner.MASTER_FILENAME ) menuFile = SysMenuFile(basename+".menus") dialogFile = SysDialogFile(basename+".dialogs") stringFile = SysStrTblFile(basename+".strtbls") menuFile.load() ; dialogFile.load() ; stringFile.load() trans = MakeTranslationFile(newpath, menuFile, dialogFile, stringFile, True, save, langcodes, order, False, prunepath, markconflicts) if ret: return trans