From 5259b76b944720073318f9da277f5bfe58a5227e Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Fri, 9 Oct 2015 03:02:06 +0200 Subject: [PATCH] The localization module now warns when finding an out of date translation. While allowing us to include translations that are not quite up to date with the current development branch in releases, it also serves to inform the user that they are using a translation that is broken or incomplete. --- gitinspector/gitinspector.py | 2 ++ gitinspector/localization.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/gitinspector/gitinspector.py b/gitinspector/gitinspector.py index 199fa92..2263b31 100755 --- a/gitinspector/gitinspector.py +++ b/gitinspector/gitinspector.py @@ -59,6 +59,8 @@ def __init__(self): self.useweeks = False def output(self): + localization.check_compatibility(version.__version__) + if not self.localize_output: localization.disable() diff --git a/gitinspector/localization.py b/gitinspector/localization.py index 7bec0a3..6dc8969 100644 --- a/gitinspector/localization.py +++ b/gitinspector/localization.py @@ -28,6 +28,7 @@ import gettext import locale import os +import re import sys import time @@ -74,6 +75,16 @@ def init(): __installed__ = True __translation__.install(True) +def check_compatibility(version): + if isinstance(__translation__, gettext.GNUTranslations): + header_pattern = re.compile ("^([^:\n]+): *(.*?) *$", re.MULTILINE) + header_entries = dict(header_pattern.findall(_(""))) + + if (header_entries["Project-Id-Version"] != "gitinspector {0}".format(version)): + print("WARNING: The translation for your system locale is not up to date with the current gitinspector " + "version. The current maintainer of this locale is {0}.".format(header_entries["Last-Translator"]), + file=sys.stderr) + def get_date(): if __enabled__ and isinstance(__translation__, gettext.GNUTranslations): date = time.strftime("%x")