summaryrefslogtreecommitdiff
path: root/Makefile.common
blob: f9777c3fb87997d7ec9747f698444d67281f98e2 (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
90
91
92
93
94
95
96
97
98
99
all: clean clean_ids update-language
	@if [ "$(SKIP_UPDATE_LANG)" != "1" ]; then \
		publican build --embedtoc --publish --langs=all --formats=html,html-single,pdf; \
	else \
		publican build --embedtoc --publish --langs=en-US --formats=html,html-single,pdf; \
	fi
	@publican install_book --site_config=../site.cfg --lang=en-US
	@if [ "$(SKIP_UPDATE_LANG)" != "1" ]; then \
		for lang in $$(ls -d *-* | grep -v en-US); do \
			publican install_book --site_config=../site.cfg --lang=$$lang; \
		done \
	fi

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
	@if [ "$(SKIP_UPDATE_LANG)" != "1" ]; then \
		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" -o -name "About_Kolab_Groupware.pot" \)`; do \
			if [ -f "../Common_Content/en-US/$$(echo $$file | sed -e 's/.pot/.xml/g' -e 's/^pot\///g')" ]; then \
				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; \
			fi; \
			slug=$$(echo $$file | sed -e 's/^pot\///g' -e 's/.pot//g' -e 's/.//g'); \
			pkg="$(PACKAGE)"; \
			while [ $$(echo $$slug | wc -c) -gt $$(( 50 - $$(echo $$pkg | wc -c) )) ]; do \
				echo "SLUG: $$slug (length: $$(echo $$slug | wc -c)"; \
				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; \
			echo "Continuing with SLUG $$pkgprefix$$slug"; \
			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; \
	fi

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
	@git add $(LANGUAGE)
	@git commit $(LANGUAGE) -m "Add language $(LANGUAGE)"