Exemplo n.º 1
0
def generatePoFiles(names, locales, numFlows, contentLength):
    """Generates a mock pot file for each name with associated mock po files for each locale"""
    
    ensure_dir(outputDir)
    
    for name in names:
        flows = makeRandomTextFlows(locales, name, numFlows, contentLength)
        
        #write the source file
        f = polib.POFile()
        header = makePoHeader(name)
        f.header = header
        meta = makePoMetadata()
        f.metadata.update(meta)
        addTextFlows(toFile=f, textFlows=flows)
        savePoFile(f, outputDir, name, None)
        
        #write the targets
        for locale in locales:
            f = polib.POFile()
            f.encoding='utf-8' #TODO is this needed?
            f.header = header
            f.metadata.update(meta)
            
            addTextFlows(toFile=f, textFlows=flows, locale=locale)
            savePoFile(f, outputDir, name, locale)
Exemplo n.º 2
0
def generatePartialTransPropertiesFiles(names, locales, numFlows, contentLength):
    """Generate properties files with different translation coverage between locales"""
    
    ensure_dir(outputDir)
    
    for name in names:
        flows = makeRandomTextFlows(locales, name+'_id', numFlows, contentLength)
        
        f = createPropsFile(outputDir, name)
        writePropHeader(toFile=f, comment='Generated comment for {0} with locale {1}'.format(name, None))
        writeTextFlows(toFile=f, textFlows=flows)
        f.write('\n')
        f.close()

        for locale in locales:
            f = createPropsFile(outputDir, name, locale)
            writePropHeader(toFile=f, comment='Generated comment for {0} with locale {1}'.format(name, locale))
            writeTextFlows(toFile=f, textFlows=flows, locale=locale, useEach=partials[locale])
            f.write('\n')
            f.close()
Exemplo n.º 3
0
def generatePropertiesFiles(names, locales, numFlows, contentLength):
    """Generates a basic set of properties files with the given names, one
    set for each locale given"""
    
    ensure_dir(outputDir)
    
    for name in names:
        flows = makeRandomTextFlows(locales, name+'_id', numFlows, contentLength)
        
        f = createPropsFile(outputDir, name)
        writePropHeader(toFile=f, comment='Generated comment for {0} with locale {1}'.format(name, None))
        writeTextFlows(toFile=f, separators=validPropsSeparators,
                       textFlows=flows)
        f.write('\n')
        f.close()

        for locale in locales:
            f = createPropsFile(outputDir, name, locale)
            writePropHeader(toFile=f, comment='Generated comment for {0} with locale {1}'.format(name, locale))
            writeTextFlows(toFile=f, separators=validPropsSeparators,
                           textFlows=flows, locale=locale)
            f.write('\n')
            f.close()