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.
This commit is contained in:
Adam Waldenberg 2015-10-09 03:02:06 +02:00
parent 4b92e7a3cc
commit 5259b76b94
2 changed files with 13 additions and 0 deletions

View file

@ -59,6 +59,8 @@ class Runner:
self.useweeks = False
def output(self):
localization.check_compatibility(version.__version__)
if not self.localize_output:
localization.disable()

View file

@ -28,6 +28,7 @@ except:
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")