Back to index

plone3  3.1.7
create.py
Go to the documentation of this file.
00001 """
00002    Usage: create.py <target-product> <source-product>
00003 
00004    Creates copies of all existing po files of the source product under the name of the target product.
00005    This is useful to preserves headers of the files and to give a starting point for work.
00006 
00007    You have to run merge after that, to remove the wrong msgid's and include the one's from the actual product
00008 
00009    Using admix.py can then copy over existing translations.
00010 """
00011 
00012 import os, sys, shutil
00013 from utils import getPoFiles, getLanguage
00014 
00015 
00016 def main():
00017     if len(sys.argv) < 3:
00018         print 'You have to specify the target and source product.'
00019         sys.exit(1)
00020 
00021     target = sys.argv[1]
00022     source = sys.argv[2]
00023 
00024     os.chdir('..')
00025 
00026     sourcePoFiles = getPoFiles(source)
00027 
00028     if sourcePoFiles == []:
00029         print 'No po-files were found for the source product.'
00030         sys.exit(3)
00031 
00032     for sourcefile in sourcePoFiles:
00033         sourceLanguage = getLanguage(source,sourcefile)
00034         if sourceLanguage:
00035             targetfile = target + '-' + sourceLanguage + '.po'
00036             targetpath = os.path.join(os.curdir, targetfile)
00037             if not os.path.exists(targetpath):
00038                 shutil.copy(sourcefile, targetfile)
00039 
00040 if __name__ == '__main__':
00041     main()