70 lines
2.6 KiB
Python
Executable File
70 lines
2.6 KiB
Python
Executable File
#!/usr/bin/python
|
|
# -*- encoding: utf-8 -*-
|
|
import fnmatch
|
|
import polib
|
|
import re
|
|
import os
|
|
import string
|
|
|
|
start_directory = '../..'
|
|
language_filename = '*.pot'
|
|
|
|
search_replace_regex = [(u'^Partner$', u'Kunde'),
|
|
(u'^Partners$', u'Kunden'),
|
|
(u'^Partner:$', u'Kunde:'),
|
|
(u'^Partners:$', u'Kunden:'),
|
|
(u'^Whole Company$', u'Ganzes Unternehmen'),
|
|
(u'^General announces for all employees.$', u'Allgemeine Nachrichten für alle Mitarbeiter'),
|
|
#(u'^Exception Rules$', u'Ausnahmeregeln'),
|
|
(u'^Payment Method$', u'Zahlungsart'),
|
|
#(u'^Automatic Workflow$', u'Automatischer Workflow'),
|
|
#(u'^Exception Name$', u'Name der Ausnahme'),
|
|
(u'^Description$', u'Beschreibung'),
|
|
(u'^Apply on$', u'Anwenden auf'),
|
|
(u'^Payment Term$', u'Zahlungsziel'),
|
|
(u'^Company$', u'Firma'),
|
|
#(u'^Journal for payment$', u'Journal für Zahlungseingänge'),
|
|
(u'^Default Values$', u'Standardwerte'),
|
|
(u'^Main Exception$', u'Fehlermeldung'),
|
|
# (u'^$', u''),
|
|
]
|
|
|
|
search_module = False # ['sale', 'stock']
|
|
|
|
valid_entries = []
|
|
|
|
for root, dirs, files in os.walk(start_directory):
|
|
for filename in fnmatch.filter(files, language_filename):
|
|
print filename
|
|
src = os.path.join(root, filename)
|
|
try:
|
|
po = polib.pofile(src)
|
|
except IOError as e:
|
|
print "ERROR", e
|
|
continue
|
|
for e in po:
|
|
if not e.obsolete:
|
|
valid_entries.append(e)
|
|
|
|
|
|
po2 = polib.POFile()
|
|
|
|
cnt = 0
|
|
for se in search_replace_regex:
|
|
for entry in valid_entries:
|
|
module = re.search(u'(module:)(.*)', entry.comment)
|
|
if module:
|
|
module = module.group(2).strip()
|
|
if search_module is False or module in search_module:
|
|
if re.search(se[0], entry.msgstr):
|
|
entry.msgstr = string.replace(entry.msgstr, se[0], se[1])
|
|
po2.append(entry)
|
|
cnt += 1
|
|
print entry.msgid, "<->", entry.msgstr, cnt
|
|
elif re.search(se[0], entry.msgid):
|
|
entry.msgstr = se[1]
|
|
po2.append(entry)
|
|
cnt += 1
|
|
print entry.msgid, "<->", entry.msgstr, cnt
|
|
|
|
po2.save('../../setup/auto_translated2.po') |