|
1 |
#!/usr/share/ucs-test/runner python |
1 |
#!/usr/share/ucs-test/runner python |
2 |
## desc: | |
2 |
## desc: | |
3 |
## univention-ucs-translation-merge fuzzy entries |
3 |
## univention-ucs-translation-merge fuzzy entries |
4 |
## Does univention -ucs translation-merge create fuzzy entries correctly when |
4 |
## Does univention-ucs-translation-merge create fuzzy entries correctly when |
5 |
## merging into an existing translation? |
5 |
## merging into an existing translation? |
6 |
## bugs: [41223] |
6 |
## bugs: [41223] |
7 |
## tags: [translation-template] |
7 |
## tags: [translation-template] |
Lines 50-57
def _change_entry_in_source_file(source_pkg_path, po_entry):
|
Link Here
|
---|
|
50 |
with open(source_file_path, 'w') as changed_source, open(original_source_file, 'r') as fd: |
50 |
with open(source_file_path, 'w') as changed_source, open(original_source_file, 'r') as fd: |
51 |
for i, line in enumerate(fd): |
51 |
for i, line in enumerate(fd): |
52 |
if i == int(line_number) - 1: |
52 |
if i == int(line_number) - 1: |
53 |
logging.info('Changing %s in line %s', source_file, line_number) |
53 |
logging.info('Attempting to change %s in line %s', source_file, line_number) |
54 |
line = line.replace(po_entry.msgid, 'C!{}'.format(po_entry.msgid)) |
54 |
lhs, msgid_from_source = line.split('_(') |
|
|
55 |
msgid_from_source = msgid_from_source.replace(po_entry.msgid[0:1], 'C!') |
56 |
line = lhs + msgid_from_source |
55 |
changed_source.write(line) |
57 |
changed_source.write(line) |
56 |
os.unlink(original_source_file) |
58 |
os.unlink(original_source_file) |
57 |
|
59 |
|
Lines 127-133
if __name__ == '__main__':
|
Link Here
|
---|
|
127 |
for po_path, changed_entry in changes: |
129 |
for po_path, changed_entry in changes: |
128 |
if not _entry_is_fuzzy(changed_entry, po_path): |
130 |
if not _entry_is_fuzzy(changed_entry, po_path): |
129 |
# Sometimes msgmerges fuzzy matching does not match the change and |
131 |
# Sometimes msgmerges fuzzy matching does not match the change and |
130 |
# appends the entry as commented (obsolete) to the end of the file |
132 |
# appends the entry as a comment to the end of the file |
131 |
if _entry_is_obsolete(changed_entry, po_path): |
133 |
if _entry_is_obsolete(changed_entry, po_path): |
132 |
logging.debug('Change not matched by fuzzy matching in PO file: %s', po_path) |
134 |
logging.debug('Change not matched by fuzzy matching in PO file: %s', po_path) |
133 |
else: |
135 |
else: |