Project

General

Profile

Download (1.82 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / locale / Makefile @ d9498f54

1
#
2
# Makefile for PO merging and MO generation. More info in the README.
3
#
4
# make all-mo (default) - generate MO files
5
# make check - check translations using translate-tool
6
# make tx-update - download and merge translations from Transifex
7
# make clean - clean everything
8
#
9
DOMAIN = hammer-cli-csv
10
VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load("../hammer_cli_csv.gemspec");puts spec.version')
11
POTFILE = $(DOMAIN).pot
12
MOFILE = $(DOMAIN).mo
13
POFILES = $(shell find . -name '*.po')
14
MOFILES = $(patsubst %.po,%.mo,$(POFILES))
15
POXFILES = $(patsubst %.po,%.pox,$(POFILES))
16

    
17
%.mo: %.po
18
	mkdir -p $(shell dirname $@)/LC_MESSAGES
19
	msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
20

    
21
# Generate MO files from PO files
22
all-mo: $(MOFILES)
23

    
24
# Check for malformed strings
25
%.pox: %.po
26
	msgfmt -c $<
27
	pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
28
		-t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
29
	cat $@
30
	! grep -q msgid $@
31

    
32
check: $(POXFILES)
33
	msgfmt -c ${POTFILE}
34

    
35
# Merge PO files
36
update-po:
37
	for f in $(shell find ./ -name "*.po") ; do \
38
		msgmerge -N --backup=none -U $$f ${POTFILE} ; \
39
	done
40

    
41
# Unify duplicate translations
42
uniq-po:
43
	for f in $(shell find ./ -name "*.po") ; do \
44
		msguniq $$f -o $$f ; \
45
	done
46

    
47
tx-pull:
48
	tx pull -f
49
	for f in $(POFILES) ; do \
50
		sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
51
	done
52
	-git commit -a -m "i18n - extracting new, pulling from tx"
53

    
54
extract-strings:
55
	bundle exec rake gettext:find
56

    
57
reset-po:
58
	# merging po files is unnecessary when using transifex.com
59
	git checkout -- ../locale/*/*po
60

    
61
tx-update: tx-pull extract-strings reset-po $(MOFILES)
62
	# amend mo files
63
	git add ../locale/*/LC_MESSAGES
64
	git commit -a --amend -m "i18n - extracting new, pulling from tx"
65
	-echo Changes commited!