Pregunta

Is there a specific API call (maybe undocumented, none is listed here http://docs.waf.googlecode.com/git/apidocs_16/tools/intltool.html ) which allows me to create and/or update a translation template?

Or do I need use native system tools?

¿Fue útil?

Solución

I could not find one either, so I introduced an option in my main wsript file.

opt.add_option('--update-po',                action='store_true', default=False, dest='update_po', help='Update localization files')
// ...
def shutdown(self):
    if Options.options.update_po:
        os.chdir('./po')
        try:
            try:
                size_old = os.stat (APPNAME + '.pot').st_size
            except:
                size_old = 0
            subprocess.call (['intltool-update', '-p', '-g', APPNAME])
            size_new = os.stat (APPNAME + '.pot').st_size
            if size_new <> size_old:
                Logs.info("Updated po template.")
                try:
                    command = 'intltool-update -r -g %s' % APPNAME
                    self.exec_command (command)
                    Logs.info("Updated translations.")
                except:
                    Logs.error("Failed to update translations.")
        except:
            traceback.print_exc(file=open("errlog.txt","a"))
            Logs.error("Failed to generate po template.")
            Logs.errors("Make sure intltool is installed.")
        os.chdir ('..')

Unfortunately I haven't had the time to transform this into a tool yet. Is on my list. But you can find a full fledge sample here: https://bazaar.launchpad.net/~diodon-team/diodon/trunk/view/head:/wscript

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top