diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2016-05-21 18:35:21 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2016-05-21 18:59:27 +0200 |
commit | 1c8a447cb652ee332b2add03c9ad1cc571965a36 (patch) | |
tree | 48d153f7c91bb658c43b58ec2ad905245bad4315 | |
parent | bcd4d8a8a0d7f5075312d8e286deef663505d19c (diff) |
i18n: Add location of duplicate strings to the context
-rwxr-xr-x | tools/translations/extract.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/translations/extract.py b/tools/translations/extract.py index 735100d076..395f2c528a 100755 --- a/tools/translations/extract.py +++ b/tools/translations/extract.py @@ -22,6 +22,7 @@ for root, dirnames, filenames in os.walk('.'): unique_str = [] +unique_loc = {} main_po = "" print("Updating the tools.pot template...") @@ -46,11 +47,19 @@ for fname in matches: msg += l[pos] pos += 1 + location = os.path.relpath(fname).replace('\\','/') + ":" + str(lc) + if (not msg in unique_str): - main_po += "\n#: " + os.path.relpath(fname).replace('\\','/') + ":" + str(lc) + "\n" + main_po += "\n#: " + location + "\n" main_po += 'msgid "' + msg + '"\n' main_po += 'msgstr ""\n' unique_str.append(msg) + unique_loc[msg] = [location] + elif (not location in unique_loc[msg]): + # Add additional location to previous occurence too + msg_pos = main_po.find('\nmsgid "' + msg) + main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:] + unique_loc[msg].append(location) l = f.readline() lc += 1 |