summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-06-20 06:38:16 -0400
committerRob Crittenden <rcritten@redhat.com>2012-07-24 16:54:21 -0400
commit23e188f2260f60e05cc7c33b029440db2253a170 (patch)
tree9ca3f6babeccbba8c19b1346c6ed6a54f13fbaad /tests
parentcc42d19e35ee54b9fcf82e70b7897a6d386d08b9 (diff)
downloadfreeipa-23e188f2260f60e05cc7c33b029440db2253a170.tar.gz
freeipa-23e188f2260f60e05cc7c33b029440db2253a170.tar.xz
freeipa-23e188f2260f60e05cc7c33b029440db2253a170.zip
Arrange stripping .po files
The .po files we use for translations have two shortcomings when used in Git: - They include file locations, which change each time the source is updated. This results in large, unreadable diffs that don't merge well. - They include source strings for untranslated messages, wasting space unnecessarily. Update the Makefile so that the extraneous information is stripped when the files are updated or pulled form Transifex, and empty translation files are removed entirely. Also, translations are normalized to a common style. This should help diffs and merges. The validator requires file location comments to identify the programming language, and to produce good error reports. To make this work, merge the comments in before validation. First patch for: https://fedorahosted.org/freeipa/ticket/2435
Diffstat (limited to 'tests')
-rwxr-xr-xtests/i18n.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/i18n.py b/tests/i18n.py
index 703dc8bbb..9c8479bb0 100755
--- a/tests/i18n.py
+++ b/tests/i18n.py
@@ -367,7 +367,7 @@ def validate_positional_substitutions(s, prog_langs, s_name='string'):
return errors
-def validate_file(file_path, validation_mode):
+def validate_file(file_path, validation_mode, reference_pot=None):
'''
Given a pot or po file scan all it's entries looking for problems
with variable substitutions. See the following functions for
@@ -378,6 +378,9 @@ def validate_file(file_path, validation_mode):
* validate_positional_substitutions()
Returns the number of entries with errors.
+
+ For po files, ``reference_pot`` gives a pot file to merge with (to recover
+ comments and file locations)
'''
def emit_messages():
@@ -419,6 +422,9 @@ def validate_file(file_path, validation_mode):
emit_messages()
return Result(n_entries=n_entries, n_msgids=n_msgids, n_msgstrs=n_msgstrs, n_warnings=n_warnings, n_errors=n_errors)
+ if validation_mode == 'po' and reference_pot:
+ # Merge the .pot file for comments and file locations
+ po.merge(reference_pot)
if validation_mode == 'po':
plural_forms = po.metadata.get('Plural-Forms')
@@ -754,12 +760,14 @@ def main():
if not files:
files = [options.pot_file]
validation_mode = 'pot'
+ reference_pot = None
elif options.mode == 'validate_po':
files = args
if not files:
print >> sys.stderr, 'ERROR: no po files specified'
return 1
validation_mode = 'po'
+ reference_pot = polib.pofile(options.pot_file)
else:
print >> sys.stderr, 'ERROR: unknown validation mode "%s"' % (options.mode)
return 1
@@ -771,7 +779,7 @@ def main():
total_errors = 0
for f in files:
- result = validate_file(f, validation_mode)
+ result = validate_file(f, validation_mode, reference_pot)
total_entries += result.n_entries
total_msgids += result.n_msgids
total_msgstrs += result.n_msgstrs