Changeset - 36a36ebdf4bb
[Not reviewed]
tip stable
0 1 0
Mads Kiilerich - 3 years ago 2022-12-12 22:24:50
mads@kiilerich.com
Grafted from: 0c9c91ac3873
i18n: prevent msgmerge fuzzy matching - it is too random
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
scripts/i18n_utils.py
Show inline comments
 
@@ -159,25 +159,25 @@ def _normalize_po(raw_content):
 
        msgstr_i = [i for i, line in enumerate(chunk_lines) if line.startswith('msgstr')]
 
        if (
 
            chunk_lines[0].startswith('msgid') and
 
            msgstr_i and
 
            all(line.endswith(' ""') for line in chunk_lines[msgstr_i[0]:])
 
        ):  # skip translation chunks that doesn't have any actual translations
 
            continue
 
        chunks.append('\n'.join(chunk_lines) + '\n')
 
    return '\n'.join(chunks)
 

	
 
def _normalize_po_file(po_file, merge_pot_file=None, strip=False):
 
    if merge_pot_file:
 
        runcmd(['msgmerge', '--width=76', '--backup=none', '--previous',
 
        runcmd(['msgmerge', '--width=76', '--backup=none', '--previous', '--no-fuzzy-matching',
 
                '--update', po_file, '-q', merge_pot_file])
 
    if strip:
 
        po_tmp = po_file + '.tmp'
 
        with open(po_file, 'r') as src, open(po_tmp, 'w') as dest:
 
            raw_content = src.read()
 
            normalized_content = _normalize_po(raw_content)
 
            dest.write(normalized_content)
 
        os.rename(po_tmp, po_file)
 

	
 
def _normalized_diff(file1, file2, merge_pot_file=None, strip=False):
 
    # Create temporary copies of both files
 
    temp1 = tempfile.NamedTemporaryFile(prefix=os.path.basename(file1))
0 comments (0 inline, 0 general)