Skip to content

Commit

Permalink
The localization module now warns when finding an out of date transla…
Browse files Browse the repository at this point in the history
…tion.

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.
  • Loading branch information
adam-waldenberg committed Oct 9, 2015
1 parent 4b92e7a commit 5259b76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gitinspector/gitinspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 11 additions & 0 deletions gitinspector/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import gettext
import locale
import os
import re
import sys
import time

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 5259b76

Please sign in to comment.