summaryrefslogtreecommitdiff
path: root/Makefile.common
blob: 680020618ce51b0266ef4d182af27d47c5d4dc02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
all: clean clean_ids update-language
	@publican build --embedtoc --publish --langs=all --formats=html,html-single,pdf
	@for lang in $$(ls -d *-*/); do \
		publican install_book --site_config=../site.cfg --lang=$$lang; \
	done

clean:
	@publican clean

clean_ids:
	@cp -a ../Common_Content/en-US/*.xml en-US/.
	@publican clean_ids
	@sed -i -r \
		-e 's/\t/    /g' \
		-e 's/((\s{4})+)\s*/\1/g' \
		-e 's/\s*$$//g' \
		`find en-US/ -type f -name "*.xml"`

tx-init:
	@if [ ! -f .tx/config ]; then \
		tx init; \
		tx set -t PO; \
	fi

update-language: tx-init
	@publican update_pot
	for file in `find pot/ -type f \
		! -name "Author_Group.pot" -a \
		! -name "Book_Info.pot" -a \
		! -name "Community_$(PACKAGE).pot" -a \
		! -name "Enterprise_$(PACKAGE).pot" -a \
		! -name "$(PACKAGE).pot"`; do \
		if [ -f "../Common_Content/en-US/$$(echo $$file | sed -e 's/.pot/.xml/g' -e 's/^pot\///g')" ]; then \
			echo "FOUND FILE IN UPPER COMMON CONTENT ../Common_Content/en-US/$$(echo $$file | sed -e 's/.pot/.xml/g' -e 's/^pot\///g')"; \
			tx set \
				--auto-local \
				-r "kolab.$$(echo $$file | sed -e 's/.pot//g' -e 's/^pot\///g')" \
				"<lang>/$$(echo $$file | sed -e 's/^pot\///g' -e 's/.pot/.po/g')" \
				--source-lang en_US \
				--source-file $$file \
				--execute; \
			continue; \
		else \
			echo "DID NOT FIND FILE IN UPPER COMMON CONTENT ../Common_Content/en-US/$$(echo $$file | sed -e 's/.pot/.xml/g' -e 's/^pot\///g')"; \
		fi; \
		slug=$$(echo $$file | sed -e 's/^pot\///g' -e 's/.pot//g'); \
		pkg="$(PACKAGE)"; \
		while [ $$(echo $$slug | wc -c) -gt $$(( 50 - $$(echo $$pkg | wc -c) )) ]; do \
			previous_length=$$(echo $$slug | wc -c); \
			slug=$$(echo $$slug | cut -d'-' -f2-); \
			if [ $$(echo $$slug | wc -c) -ge $$previous_length ]; then \
				unset pkg; \
			fi; \
		done; \
		if [ ! -z "$$pkg" -a $$(echo $$pkg | wc -c) -ne 1 ]; then \
			pkgprefix="$$pkg-"; \
		else \
			pkgprefix=""; \
		fi; \
		if [ $$(echo $$pkgprefix$$slug | wc -c) -gt 50 ]; then \
			exit 1; \
		fi; \
		tx set \
			--auto-local \
			-r "kolab.$$pkgprefix$$slug" \
			"<lang>/$$(echo $$file | sed -e 's/^pot\///g' -e 's/.pot/.po/g')" \
			--source-lang en_US \
			--source-file $$file \
			--execute; \
	done
	@tx push -s
	@publican update_po --langs=all
	@for lang in $$(ls -d *-*); do \
		tx pull -l $$lang -f; \
	done

add-language: tx-init
	@publican update_pot
	@publican update_po --langs=$(LANGUAGE)
	@for lang in $$(ls -d *-* | grep -v "en-US"); do \
		lang_short=$$(echo $$lang | cut -d'-' -f1); \
		lang_underscore=$$(echo $$lang | sed -e 's/-/_/g'); \
		if [ -z "$$lang_map" ]; then \
			lang_map="$$lang_short: $$lang"; \
		else \
			lang_map="$$lang_map, $$lang_short: $$lang"; \
		fi; \
	done; sed -i -e '/^lang_map/d' -e "2 i\lang_map = $$lang_map" .tx/config