-
Notifications
You must be signed in to change notification settings - Fork 7
/
locale.mk
59 lines (44 loc) · 1.78 KB
/
locale.mk
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
TRANSLATION_TARGET ?=
pot := $(wildcard po/*.pot)
po := $(wildcard po/*/*.po)
mo := $(po:.po=.mo)
TRANSLATION_CHARSET ?= .UTF-8
__translation_check = (echo TRANSLATION_TARGET is not set; exit 1)
_translation_check = test ${TRANSLATION_TARGET} || $(call __translation_check)
_translation_locale = ${TRANSLATION_TARGET}${TRANSLATION_CHARSET}
translation-init: ${pot}
@$(call _translation_check)
@mkdir -p po/${TRANSLATION_TARGET}
@msginit --no-translator -i ${pot} -l $(_translation_locale) -o po/${TRANSLATION_TARGET}/${PACKAGE}.po
translation-edit: ${pot}
@$(call _translation_check)
@${EDITOR} po/${TRANSLATION_TARGET}/${PACKAGE}.po
translation-update: ${po} ${src}/*.c
@$(info updating translations)
@xgettext -k_ -o ${pot} -i ${src}
@mv ${pot}.tmp ${pot}
@for a in ${po}; do msgmerge -Uq $$a ${pot}; done
translation-generate: ${mo}
translation-install: translation-generate
@$(info installing translations)
for a in ${mo}; do echo $$a; mkdir -p ${PREFIX}/share/locale/$$(basename $$(dirname $$a))/LC_MESSAGES/; cp $$a ${PREFIX}/share/locale/$$(basename $$(dirname $$a))/LC_MESSAGES/${PACKAGE}.mo; done
translation-uninstall:
@$(info uninstalling translations)
@for a in ${mo}; do rm ${PREFIX}/share/locale/$$(basename $$(dirname $$a))/LC_MESSAGES/${PACKAGE}.mo; done
translation-clean:
@$(info cleaning translations)
@for a in ${mo}; do rm -f $$a; done
translation-commit:
@$(call _translation_check)
@$(info commiting translations)
@rm -f po/${TRANSLATION_TARGET}/gwion.po~
@git add po/${TRANSLATION_TARGET}
@git commit -m":briefcase: Updating ${TRANSLATION_TARGET} [skip ci]"
define _translation-name
$(shell basename `dirname $1`)
endef
.SUFFIXES: .po .mo
.po.mo:
@which msgfmt || return 0
$(info generate $(call _translation-name, $<) translations)
@msgfmt $< -o $(<:.po=.mo)