-
Notifications
You must be signed in to change notification settings - Fork 0
/
en2fa_lib.py
29 lines (25 loc) · 1.01 KB
/
en2fa_lib.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
import polib
files = ["admin","api","common","default","editor","emails","grid","installer","manager","reader","reviewer","submission","sushi","user",]
print('copy untransalted msgstr from en to fa')
for file in files:
fa_pofile = polib.pofile(f'lib/pkp/locale/fa/{file}.po')
en_pofile = polib.pofile(f'lib/pkp/locale/en/{file}.po')
for entry in fa_pofile:
if entry.msgstr == "":
en_found = en_pofile.find(entry.msgid)
# print(entry.msgid, en_found.msgstr if en_found else None)
if en_found:
entry.msgstr = en_found.msgstr
fa_pofile.save()
print(f'file {file} done')
print()
print('copy unkhown msgstr in fa from en')
for file in files:
fa_pofile = polib.pofile(f'lib/pkp/locale/fa/{file}.po')
en_pofile = polib.pofile(f'lib/pkp/locale/en/{file}.po')
for entry in en_pofile:
fa_found = fa_pofile.find(entry.msgid)
if fa_found is None:
fa_pofile.append(entry)
fa_pofile.save()
print(f'file {file} done')