forked from chyrp/chyrp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetuptx.py
More file actions
executable file
·32 lines (26 loc) · 880 Bytes
/
setuptx.py
File metadata and controls
executable file
·32 lines (26 loc) · 880 Bytes
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
29
30
31
32
#!/usr/bin/env python
import os
import fnmatch
def locate(root, pattern):
'''Locate all files matching supplied filename pattern in and below
supplied root directory.'''
for path, dirs, files in os.walk(root):
for filename in fnmatch.filter(files, pattern):
if os.path.getsize(os.path.join(path, filename)) > 0:
yield os.path.join(path, filename)
def gatherpotfiles():
lst = locate (".", "*.pot")
for item in lst:
base = item[0:item.rfind("/")];
print (base)
chunks = item.split("/")
if chunks[1]=="global":
resource = chunks[1]
else:
resource = chunks[1]+"_"+chunks[2]
print ("")
print (resource)
cmd = "tx set --auto-local -r 'chyrp."+resource+"' '"+base+"/<lang>.po' --source-lang en_US --source-file "+item+" --execute"
# print (cmd)
os.system (cmd)
gatherpotfiles()