예제 #1
0
파일: push.py 프로젝트: RailComm/LiVSs
 def __t2r(self):
     logging.debug("Pushing Translator into resources...")
     trans = TranslationFile( self.__input, self.__defaultLangCode() )
     trans.load()
     logging.debug("\tPulling out sys utils")
     menuFile = trans.getSysMenuFile('')
     dlogFile = trans.getSysDialogFile('')
     strsFile = trans.getSysStrTblFile('')
     projFiles = {}
     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:
             if resource._name in projFiles:
                 logging.debug("\t\tReloading proj lvl files for %s..."%resource._name)
                 projMenus, projDlogs, projConts = projFiles[ resource._name ]
             else:
                 logging.debug("\t\tPulling out proj lvl files for %s..."%resource._name)
                 projMenus = menuFile.genProjLevelFile(resource._name, '')
                 projDlogs = dlogFile.genProjLevelFile(resource._name, '')
                 projConts = strsFile.genProjLevelFile(resource._name, '')
                 projFiles[ resource._name ] = (projMenus, projDlogs, projConts)
         except KeyError:
             logging.warning("Project %s does not exist in %s. (path=%s,name=%s)"%(resource._name,self.__input,cpath,name))
             continue
         
         logging.debug("\t\tUpdating %s @> %s"%(name,cpath))
         buff = resource.updateMenus( projMenus, save=False )
         buff = resource.updateDialogs( projDlogs, save=False, buffer=buff )
         resource.updateStringTables( projConts, buffer=buff )
예제 #2
0
from lslib.base.file.utility.TranslationFile import TranslationFile
from lslib.base.file.syslvl.SysMenuFileCSV   import ConvertMenuXML2CSV


TRANS_PATH = "" #TODO: SET TO PATH OF XLS TRANSLATOR FILE
NEW_TRANS_PATH = "" #TODO: SET TO NEW PATH FOR FILTERED TRANSLATOR FILE

PRIMARY_LANGCODE = '1033'
PROJ_NAMES_TO_REMOVE = \
[
    #TODO: ADD NAMES OF PROJECTS HERE
]

if __name__ == "__main__":
    trans = TranslationFile(TRANS_PATH,PRIMARY_LANGCODE)
    newTrans = TranslationFile(NEW_TRANS_PATH,PRIMARY_LANGCODE)
    print("Loading translator...")
    trans.load()
    
    print("Extracting dialogs to filter...")
    newDlogs = trans.getSysDialogFile('')
    print("Extracting string tables to filter...")
    newStrTbl = trans.getSysStrTblFile('')
    print("Extracting menus to filter...")
    newMenus = trans.getSysMenuFile('')
    
    print("Filtering...")
    for proj in PROJ_NAMES_TO_REMOVE:
        print("\t-Removing: %s"%proj)
        newDlogs._projs.pop(proj, '')
예제 #3
0
파일: push.py 프로젝트: RailComm/LiVSs
 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!")