forked from primaeval/plugin.video.iptv.recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguage.py
145 lines (138 loc) · 4.9 KB
/
language.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#! /usr/bin/python
__strings = {}
if __name__ == "__main__":
import polib
po = polib.pofile('resources/language/English/strings.po')
try:
import re
import subprocess
r = subprocess.check_output(["grep", "-hnr", "_([\'\"]", "."])
strings = re.compile("_\([\"'](.*?)[\"']\)", re.IGNORECASE).findall(r)
translated = [m.msgid.lower().replace("'", "\\'") for m in po]
missing = set([s for s in strings if s.lower() not in translated])
if missing:
ids_range = range(30000, 31000)
ids_reserved = [int(m.msgctxt[1:]) for m in po]
ids_available = [x for x in ids_range if x not in ids_reserved]
print "warning: missing translation for", missing
for text in missing:
id = ids_available.pop(0)
entry = polib.POEntry(
msgid=text,
msgstr=u'',
msgctxt="#{0}".format(id)
)
po.append(entry)
po.save('resources/language/English/strings.po')
except:
pass
content = []
with open(__file__, "r") as me:
content = me.readlines()
content = content[:content.index("#GENERATED\n")+1]
with open(__file__, 'w') as f:
f.writelines(content)
for m in po:
line = "__strings['{0}'] = {1}\n".format(m.msgid.lower().replace("'", "\\'"), m.msgctxt.replace('#', '').strip())
f.write(line)
else:
import xbmc, xbmcaddon
__language__ = xbmcaddon.Addon().getLocalizedString
def get_string(t):
id = __strings.get(t.lower())
if id:
return __language__(id)
xbmc.log("missing translation for " + t.lower())
return t
#setattr(__builtin__, '_', get_string)
#GENERATED
__strings['delete all recordings?'] = 30000
__strings['play channel'] = 30001
__strings['delete job'] = 30002
__strings['finished'] = 30003
__strings['record once'] = 30004
__strings['play channel external'] = 30005
__strings['external player'] = 30006
__strings['title search (% is wildcard)?'] = 30007
__strings['delete all jobs'] = 30008
__strings['search plot'] = 30009
__strings['add favourite channel'] = 30010
__strings['delete all rules'] = 30011
__strings['recording rules'] = 30012
__strings['favourite channels'] = 30013
__strings['delete all recordings'] = 30014
__strings['full epg'] = 30015
__strings['search title'] = 30016
__strings['xmltv'] = 30017
__strings['delete search'] = 30018
__strings['cancel record?'] = 30019
__strings['delete recording?'] = 30020
__strings['new'] = 30021
__strings['remove favourite channel'] = 30022
__strings['recording jobs'] = 30023
__strings['plot search (% is wildcard)?'] = 30024
__strings['add title search rule'] = 30025
__strings['add plot search rule'] = 30026
__strings['delete all rules?'] = 30027
__strings['recordings folder'] = 30028
__strings['ffmpeg exe not found!'] = 30029
__strings['tomorrow'] = 30030
__strings['today'] = 30031
__strings['delete rule'] = 30032
__strings['channel groups'] = 30033
__strings['loading data...'] = 30034
__strings['cancel record'] = 30035
__strings['service'] = 30036
__strings['delete recording'] = 30037
__strings['yesterday'] = 30038
__strings['delete all jobs?'] = 30039
__strings['recordings'] = 30040
__strings['record always'] = 30041
__strings['record daily'] = 30042
__strings['creating database'] = 30043
__strings['copying xmltv file'] = 30044
__strings['unzipping xmltv file'] = 30045
__strings['finding channels'] = 30046
__strings['finding programmes'] = 30047
__strings['finding streams'] = 30048
__strings['nuke'] = 30049
__strings['finished loading data'] = 30050
__strings['watch daily'] = 30051
__strings['delete everything and start again?'] = 30052
__strings['watch once'] = 30053
__strings['reload data'] = 30054
__strings['search categories'] = 30055
__strings['watch always'] = 30056
__strings['monday'] = 30057
__strings['tuesday'] = 30058
__strings['wednesday'] = 30059
__strings['thursday'] = 30060
__strings['friday'] = 30061
__strings['saturday'] = 30062
__strings['sunday'] = 30063
__strings['remind daily'] = 30064
__strings['rules'] = 30065
__strings['jobs'] = 30066
__strings['remind once'] = 30067
__strings['remind always'] = 30068
__strings['cancel watch'] = 30069
__strings['cancel remind'] = 30070
__strings['% is wildcard'] = 30071
__strings['search'] = 30072
__strings['tv shows'] = 30073
__strings['movies'] = 30074
__strings['do not load group'] = 30075
__strings['delete ffmpeg'] = 30076
__strings['add daily time rule'] = 30077
__strings['add weekly time rule'] = 30078
__strings['record and play'] = 30079
__strings['watch weekly'] = 30080
__strings['other'] = 30081
__strings['select groups to load'] = 30082
__strings['record weekly'] = 30083
__strings['maintenance'] = 30084
__strings['load group'] = 30085
__strings['browse'] = 30086
__strings['add one time rule'] = 30087
__strings['categories'] = 30088
__strings['remind weekly'] = 30089