forked from QTodoTxt/QTodoTxt2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pylupdate.py
executable file
·70 lines (55 loc) · 1.77 KB
/
pylupdate.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! python3
# -*- coding: utf-8 -*-
import os
import sys
# change to value of your locale
locale = "ru_RU"
def filterFiles(str):
if str.endswith(".py"):
return True
return False
def getsubs(dir):
# get all
dirs = []
files = []
src = []
for dirname, dirnames, filenames in os.walk(dir):
dirs.append(dirname)
for subdirname in dirnames:
dirs.append(os.path.join(dirname, subdirname))
for filename in filenames:
files.append(os.path.join(dirname, filename))
for file in files:
if filterFiles(file) and (file not in src):
src.append(file)
return src
def updateTranslation():
print("__update__")
files = getsubs(os.getcwd())
myString = ' '.join(files)
text = "pylupdate5 {0!s} -ts i18n/{1!s}.ts".format(myString, locale)
os.system(text)
def clearTranslation():
print("__no_obsolete__")
files = getsubs(os.getcwd())
myString = ' '.join(files)
text = "pylupdate5 {0!s} -ts -noobsolete i18n/{1!s}.ts".format(myString, locale)
os.system(text)
def fixationTranslation():
print("__fixation__")
text = "lrelease i18n/{0!s}.ts".format(locale)
os.system(text)
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] == "upd":
updateTranslation()
if sys.argv[1] == "fix":
fixationTranslation()
if sys.argv[1] == "clr":
clearTranslation()
else:
print("Usage: \n params: upd | fix")
print("upd - Update the specified language translations in the variable 'locale'")
print("fix - Compilation of translations specified language")
print("clr - Drop all obsolete strings'")
print("!!! don't forget update var locale in script !!!")