Back to index

plone3  3.1.7
setdomain.py
Go to the documentation of this file.
00001 """
00002    Usage: setdomain.py <product> <domain>
00003 """
00004 
00005 import os, sys
00006 import getopt
00007 from utils import getPoFiles, getLongProductName
00008 
00009 from i18ndude import catalog
00010 
00011 
00012 def main():
00013     if len(sys.argv) < 3:
00014         print 'You have to specify the product and the new text for domain.'
00015         sys.exit(1)
00016 
00017     product = getLongProductName(sys.argv[1])
00018     domain = sys.argv[2]
00019 
00020     os.chdir('..')
00021     os.chdir('i18n')
00022 
00023     poFiles = getPoFiles(product, all=True)
00024     if poFiles == []:
00025         print 'No po-files were found for the given product.'
00026         sys.exit(2)
00027 
00028     for poFile in poFiles:
00029         try:
00030             po_ctl = catalog.MessageCatalog(filename=poFile)
00031         except IOError, e:
00032             print >> sys.stderr, 'I/O Error: %s' % e
00033         po_ctl.mime_header['Domain'] = domain
00034         file = open(poFile, 'w')
00035         writer = catalog.POWriter(file, po_ctl)
00036         writer.write(sort=False)
00037 
00038 if __name__ == '__main__':
00039     main()