From d833abd23b9692310260b74e3160a385a14a39fa Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Fri, 12 Aug 2016 16:19:47 +0200 Subject: [PATCH 1/3] Added missing trailing dot. --- src/i18n/messages-ru.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/messages-ru.po b/src/i18n/messages-ru.po index f0cabd1f..1bf19295 100644 --- a/src/i18n/messages-ru.po +++ b/src/i18n/messages-ru.po @@ -301,7 +301,7 @@ msgid "" "and rooms." msgstr "" "Ваше фото, имя и сообщение о статусе идентифицируют вас в вызовах, чатах " -"и комнатах" +"и комнатах." msgid "Your ID" msgstr "Ваш ID" From dc4585080d4ba80c84fa23e3f60cba47263807fa Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Fri, 12 Aug 2016 16:20:50 +0200 Subject: [PATCH 2/3] Support multiline message ids. --- src/i18n/helpers/polint.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/i18n/helpers/polint.py b/src/i18n/helpers/polint.py index 739f0a62..614c28ed 100755 --- a/src/i18n/helpers/polint.py +++ b/src/i18n/helpers/polint.py @@ -62,8 +62,11 @@ def parsepo(fn): msgstr = None elif line.startswith("msgstr"): msgstr = line.strip()[8:-1] - elif line.startswith('"') and msgstr is not None and msgid is not None: - msgstr += line.strip()[1:-1] + elif line.startswith('"'): + if msgstr is None: + msgid += line.strip()[1:-1] + elif msgstr is not None: + msgstr += line.strip()[1:-1] elif line.startswith("#. Default: "): default = line.strip()[13:-1] elif line.startswith("#"): From bc25d998d722c5d55b6a98956e4d4c6adaa7caeb Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Fri, 12 Aug 2016 16:21:25 +0200 Subject: [PATCH 3/3] Add special "hook" mode to polint to fix language detection. The language is detected from the filename which doesn't work when called from the hook where a temporary file is processed. --- src/hooks/pre-commit.hook | 2 +- src/i18n/helpers/polint.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/hooks/pre-commit.hook b/src/hooks/pre-commit.hook index 04c2dac0..780bdeda 100755 --- a/src/hooks/pre-commit.hook +++ b/src/hooks/pre-commit.hook @@ -78,7 +78,7 @@ fi for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.po$"` ; do echo "Checking ${file}" nf=`git checkout-index --temp ${file} | cut -f 1` - ./src/i18n/helpers/polint.py "${nf}" + ./src/i18n/helpers/polint.py --hook "${nf}" "${file}" r=$? rm "${nf}" if [ $r != 0 ] ; then diff --git a/src/i18n/helpers/polint.py b/src/i18n/helpers/polint.py index 614c28ed..380275c4 100755 --- a/src/i18n/helpers/polint.py +++ b/src/i18n/helpers/polint.py @@ -187,13 +187,28 @@ def main(): _, POT_DATA, _ = parsepo(os.path.join(ROOT, 'messages.pot')) errors = 0 - filenames = sys.argv[1:] + try: + sys.argv.remove('--hook') + except ValueError: + is_hook = False + else: + is_hook = True + + if is_hook: + filename, orig_filename = sys.argv[1:] + filenames = [filename] + else: + orig_filename = None + filenames = sys.argv[1:] show_filenames = False if not filenames: filenames = glob.glob(os.path.join(ROOT, 'messages-*.po')) show_filenames = True for filename in filenames: - language = os.path.basename(filename)[9:-3] + if orig_filename: + language = os.path.basename(orig_filename)[9:-3] + else: + language = os.path.basename(filename)[9:-3] if show_filenames: print 'Checking %s (%s)' % (filename, language) try: