'Subcommand for creating new message catalogs from a template.
:param argv: the command arguments'

def init(self, argv):

    parser = OptionParser(usage=(self.usage % ('init', '')), description=self.commands['init'])
    parser.add_option('--domain', '-D', dest='domain', help="domain    of    PO    file    (default    '%default')")
    parser.add_option('--input-file', '-i', dest='input_file', metavar='FILE', help='name    of    the    input    file')
    parser.add_option('--output-dir', '-d', dest='output_dir', metavar='DIR', help='path    to    output    directory')
    parser.add_option('--output-file', '-o', dest='output_file', metavar='FILE', help="name    of    the    output    file    (default    '<output_dir>/<locale>/LC_MESSAGES/<domain>.po')")
    parser.add_option('--locale', '-l', dest='locale', metavar='LOCALE', help='locale    for    the    new    localized    catalog')
    parser.set_defaults(domain='messages')
    (options, args) = parser.parse_args(argv)
    if (not options.locale):
        parser.error('you    must    provide    a    locale    for    the    new    catalog')
    try:
        locale = Locale.parse(options.locale)
    except UnknownLocaleError as e:
        parser.error(e)
    if (not options.input_file):
        parser.error('you    must    specify    the    input    file')
    if ((not options.output_file) and (not options.output_dir)):
        parser.error('you    must    specify    the    output    file    or    directory')
    if (not options.output_file):
        options.output_file = os.path.join(options.output_dir, options.locale, 'LC_MESSAGES', (options.domain + '.po'))
    if (not os.path.exists(os.path.dirname(options.output_file))):
        os.makedirs(os.path.dirname(options.output_file))
    infile = open(options.input_file, 'r')
    try:
        catalog = read_po(infile, locale=options.locale)
    finally:
        infile.close()
    catalog.locale = locale
    catalog.revision_date = datetime.now(LOCALTZ)
    self.log.info('creating    catalog    %r    based    on    %r', options.output_file, options.input_file)
    outfile = open(options.output_file, 'w')
    try:
        write_po(outfile, catalog)
    finally:
        outfile.close()
