Skip to content

Commit 5259b76

Browse files
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.
1 parent 4b92e7a commit 5259b76

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

gitinspector/gitinspector.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def __init__(self):
5959
self.useweeks = False
6060

6161
def output(self):
62+
localization.check_compatibility(version.__version__)
63+
6264
if not self.localize_output:
6365
localization.disable()
6466

gitinspector/localization.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import gettext
2929
import locale
3030
import os
31+
import re
3132
import sys
3233
import time
3334

@@ -74,6 +75,16 @@ def init():
7475
__installed__ = True
7576
__translation__.install(True)
7677

78+
def check_compatibility(version):
79+
if isinstance(__translation__, gettext.GNUTranslations):
80+
header_pattern = re.compile ("^([^:\n]+): *(.*?) *$", re.MULTILINE)
81+
header_entries = dict(header_pattern.findall(_("")))
82+
83+
if (header_entries["Project-Id-Version"] != "gitinspector {0}".format(version)):
84+
print("WARNING: The translation for your system locale is not up to date with the current gitinspector "
85+
"version. The current maintainer of this locale is {0}.".format(header_entries["Last-Translator"]),
86+
file=sys.stderr)
87+
7788
def get_date():
7889
if __enabled__ and isinstance(__translation__, gettext.GNUTranslations):
7990
date = time.strftime("%x")

0 commit comments

Comments
 (0)