From 8d300cc8a85e2f9e8fc710f524b6817c27fc30bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 21 May 2016 18:57:48 +0200 Subject: [PATCH] i18n: Disable line numbers in location context Can be toggled on with --with-line-nb. --- tools/translations/extract.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/translations/extract.py b/tools/translations/extract.py index 395f2c528a2..0ae856344ae 100755 --- a/tools/translations/extract.py +++ b/tools/translations/extract.py @@ -2,13 +2,25 @@ import fnmatch import os -import re import shutil import subprocess +import sys + + +line_nb = False + +for arg in sys.argv[1:]: + if (arg == "--with-line-nb"): + print("Enabling line numbers in the context locations.") + line_nb = True + else: + os.sys.exit("Non supported argument '" + arg + "'. Aborting.") + if (not os.path.exists("tools")): os.sys.exit("ERROR: This script should be started from the root of the git repo.") + matches = [] for root, dirnames, filenames in os.walk('.'): for filename in fnmatch.filter(filenames, '*.cpp'): @@ -47,7 +59,9 @@ for fname in matches: msg += l[pos] pos += 1 - location = os.path.relpath(fname).replace('\\','/') + ":" + str(lc) + location = os.path.relpath(fname).replace('\\','/') + if (line_nb): + location += ":" + str(lc) if (not msg in unique_str): main_po += "\n#: " + location + "\n"