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
This commit is contained in:
Petr Viktorin
2012-06-20 06:38:16 -04:00
committed by Rob Crittenden
parent cc42d19e35
commit 23e188f226
4 changed files with 49 additions and 6 deletions

View File

@@ -14,6 +14,7 @@ MSGFMT = @MSGFMT@
MSGINIT = @MSGINIT@
MSGMERGE = @MSGMERGE@
MSGCMP = @MSGCMP@
MSGATTRIB = @MSGATTRIB@
TX = @TX@
IPA_TEST_I18N = ../../tests/i18n.py
@@ -67,7 +68,7 @@ C_POTFILES = $(C_FILES) $(H_FILES)
.SUFFIXES:
.SUFFIXES: .po .mo
.PHONY: all create-po update-po update-pot install mostlyclean clean distclean test mo-files debug
.PHONY: all create-po update-po update-pot install mostlyclean clean distclean test mo-files debug strip-po merge-po $(po_files)
all:
@@ -86,6 +87,19 @@ $(po_files): $(DOMAIN).pot
echo Merging $(DOMAIN).pot into $@; \
$(MSGMERGE) --no-fuzzy-matching -o $@ $@ $(DOMAIN).pot
strip-po:
@for po_file in $(po_files); do \
echo Stripping $$po_file; \
$(MSGATTRIB) --translated --no-fuzzy --no-location $$po_file > $$po_file.tmp; \
mv $$po_file.tmp $$po_file; \
done
@export FILES_TO_REMOVE=`find . -name '*.po' -empty`; \
if [ "$$FILES_TO_REMOVE" != "" ]; then \
echo Removing empty translation files; \
rm -v $$FILES_TO_REMOVE; \
echo; echo Please remove the deleted files from LINGUAS!; echo; \
fi
create-po: $(DOMAIN).pot
@for po_file in $(po_files); do \
if [ ! -e $$po_file ]; then \
@@ -98,10 +112,14 @@ create-po: $(DOMAIN).pot
pull-po:
cd ../..; $(TX) pull -f
$(MAKE) strip-po
update-po: update-pot
merge-po: update-pot
$(MAKE) $(po_files)
update-po: merge-po
$(MAKE) strip-po
update-pot:
@rm -f $(DOMAIN).pot.update
@pushd ../.. ; \