File: updatepo

package info (click to toggle)
steadyflow 0.2.0-1.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,384 kB
  • ctags: 57
  • sloc: perl: 1,186; xml: 46; python: 44; makefile: 5
file content (28 lines) | stat: -rwxr-xr-x 1,080 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python

import os;
import re;
import subprocess;

outfile = 'po/steadyflow.pot'
pattern = re.compile('^([a-zA-Z_]+)\.po$')

files = subprocess.Popen(['find', 'Steadyflow', 'Steadyflow.Core', 'Steadyflow.UI', '-name', '*.vala'],
	stdout = subprocess.PIPE).communicate()[0].splitlines()

common_args = ['-o', outfile, '--copyright-holder=Maia Kozheva <sikon@ubuntu.com>', '--package-name=steadyflow',
	'--package-version=0.1', '--msgid-bugs-address=sikon@ubuntu.com']

print 'Updating translation template'
subprocess.call(['xgettext', '--from-code=utf-8', '--language=C#', '--keyword=_',
    '--keyword=ngettext:1,2', '--add-comments=///'] + common_args + files)
subprocess.call(['xgettext', '-j', '--language=Glade', '-D', 'data/ui'] + common_args + os.listdir('data/ui'))

for langfile in sorted(os.listdir('po')):
	matches = pattern.match(langfile)
	
	if matches:
		lang = matches.group(1)
		print 'Updating translation file for language "%s"' % lang
		langfile = 'po/%s' % langfile
		subprocess.call(['msgcat', '--use-first', '-o', langfile, langfile, outfile])