OSDN Git Service

update translations
[kde/Katie.git] / scripts / updatetranslations.py
1 #!/usr/bin/python
2
3 import os, glob, subprocess, shlex
4
5 components = ('core', 'dbus', 'declarative', 'gui', 'network', 'plugins',
6     'script', 'scripttools', 'sql', 'svg', 'test', 'uitools', 'xml')
7 cfiles = []
8 tfiles = []
9
10 def list_files(sdir):
11     lfiles = []
12     for root, subdirs, files in os.walk(sdir):
13         for sfile in files:
14             if sfile.endswith(('.cpp', '.h', '.js', '.qs', '.qml', '.ui')):
15                 lfiles.append('%s/%s' % (root, sfile))
16     return lfiles
17
18 for c in components:
19     cfiles.extend(list_files('src/%s' % c))
20
21 for t in glob.glob('src/tools/*'):
22     tfiles.extend(list_files(t))
23
24 for t in glob.glob('translations/qt*.ts'):
25     if 'tools' in t:
26         files = ' '.join(tfiles)
27     else:
28         files = ' '.join(cfiles)
29     command = 'fastdev/bin/lupdate -locations relative -no-ui-lines -no-obsolete %s -ts %s' % (files, t)
30     command = shlex.split(command)
31     pipe = subprocess.Popen(command, stderr=subprocess.PIPE)
32     pipe.wait()
33     if pipe.returncode != 0:
34         raise(Exception(pipe.communicate()[1].strip()))