#! /usr/bin/env python
# WAF build script for midori
# This file is licensed under the terms of the expat license, see the file EXPAT.

import Params
import pproc as subprocess
import os

if bld.env ()['INTLTOOL_UPDATE']:
    os.chdir ('./po')
    try:
        try:
            size_old = os.stat ('midori.pot').st_size
        except:
            size_old = 0
        subprocess.call (['intltool-update', '--pot'])
        size_new = os.stat ('midori.pot').st_size
        if size_new <> size_old:
            Params.pprint ('YELLOW', "Updated po template.")
            try:
                intltool_update = subprocess.Popen (['intltool-update', '-r'],
                                                    stderr=subprocess.PIPE)
                intltool_update.wait ()
                Params.pprint ('YELLOW', "Updated translations.")
            except:
                Params.pprint ('RED', "Failed to update translations.")
    except:
        Params.pprint ('RED', "Failed to generate po template.")
    os.chdir ('..')

obj = bld.create_obj ('intltool_po')
obj.appname = 'midori'