From 5922fe24289c4ae998960607face97f5a10af1e5 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 30 May 2008 21:29:49 +0200 Subject: Separate po4a and git rules from rules.mk. --- make/git.mk | 11 +++++++++++ make/po4a.mk | 31 +++++++++++++++++++++++++++++++ make/rules.mk | 24 +++++++++++------------- 3 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 make/git.mk create mode 100644 make/po4a.mk diff --git a/make/git.mk b/make/git.mk new file mode 100644 index 0000000..930e77a --- /dev/null +++ b/make/git.mk @@ -0,0 +1,11 @@ +update: + git pull + +init: + git init + git remote add -f -t "$(master)" -m "$(master)" origin "$(origin)" + git merge origin + git branch -m "$(master)" + git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)" + +.PHONY: update init diff --git a/make/po4a.mk b/make/po4a.mk new file mode 100644 index 0000000..df5d051 --- /dev/null +++ b/make/po4a.mk @@ -0,0 +1,31 @@ +# override with e.g. htmltemplate when handling non-Markdown files +fileformat = text + +# Percentage of l10n completed to be acceptable +threshold = 100 + +# l10nfiles: relative paths to localizable files + +# Invoke from inside basedir of master files +# potfile: path to POT file +mkpot: + po4a-gettextize -M UTF-8 -L UTF-8 -f "$(fileformat)" -o markdown $(patsubst %,-m %,$(l10nfiles)) -p "$(potfile)" + +# Invoke from root dir of translated files +# masterdir: path to dir containing untranslated files +# pofile: path to PO file +mkpo: + po4a-gettextize -M UTF-8 -L UTF-8 -f "$(fileformat)" -o markdown $(patsubst %,-m %,$(l10nfiles)) $(patsubst %,-l $(masterdir)/%,$(l10nfiles)) -p "$(pofile)" + +# Invoke from inside basedir of master files +# pofile: path to PO file +updatepo: + po4a-updatepo -M UTF-8 -f "$(fileformat)" -o markdown $(patsubst %,-m %,$(l10nfiles)) -p "$(pofile)" + +# Invoke from root dir of translated files +# masterdir: path to dir containing untranslated files +# pofile: path to PO file +$(l10nfiles): + po4a-translate -M UTF-8 -L UTF-8 -k "$(threshold)" -f "$(fileformat)" -o markdown $(patsubst %,-m $(masterdir)/%,$@) -p "$(pofile)" -l "$@" + +.PHONY: mkpot mkpo diff --git a/make/rules.mk b/make/rules.mk index 753aa3a..91aff14 100644 --- a/make/rules.mk +++ b/make/rules.mk @@ -17,15 +17,11 @@ $(1): master = $$(subst -LOCALE,$(2:%=-$(2)),$$($(4)_BRANCH)) $(1): mkdir -p $$@ @if [ -d "$$@/.git" ]; then \ - cd $$@ && \ - git pull; \ + echo $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" update; \ + $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" update; \ else \ - cd $$@ && \ - git init && \ - git remote add -f -t $$(master) -m $$(master) origin $$(origin) && \ - git merge origin && \ - git branch -m $$(master) && \ - git config remote.origin.push +refs/heads/$$(master):refs/heads/$$(master); \ + echo $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" master="$$(master)" origin="$$(origin)" init; \ + $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" master="$$(master)" origin="$$(origin)" init; \ fi @@ -42,6 +38,8 @@ $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(eval $(call $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(foreach locale,$($(source)_LOCALES),$(eval $(call MODULE_template,$(l10ndir),$(locale),$(module),$(source)))))) +# Override po4a with local Markdown-supportive text module +export PERL5LIB = $(CURDIR)/perl # 1:moduledir 2:locale 3:mastermodule 4:source define POT_template @@ -52,7 +50,7 @@ $(3)_L10NFILES = $$(patsubst $(1)/%,%,$$(shell find $(1) -type f -name '*.$$(fil MASTER_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)) $(podir)/$(3).pot: $(1) - cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) -o markdown $$(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@ + $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" potfile="$(CURDIR)/$$@" mkpot; \ .PHONY: $(1) endef @@ -71,7 +69,7 @@ $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES)) $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES)) $(podir)/$(3).$(2).po: $(3) $(5) - cd "$(3)" && PERL5LIB="$(CURDIR)/perl" po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) -o markdown $$(patsubst %,-m %,$$($(3)_L10NFILES)) $$(patsubst %,-l $$(CURDIR)/$(1)/%,$($(3)_L10NFILES)) -p $(CURDIR)/$$@ + $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(3)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(1)" pofile="$(CURDIR)/$$@" mkpo # TODO: Implement the below for automated tests, after unfuzzing the above like this: # grep -v '^#, fuzzy$' | sed 's/^#, fuzzy,/#,/' @@ -79,7 +77,7 @@ $(podir)/$(3).$(2).po: $(3) $(5) # FIXME: needs to depend also on its masterfile #$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po # mkdir -p $(1) -# cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-translate -M UTF-8 -L UTF-8 -k 0 -f $(fileformat) -o markdown $$(patsubst $(1)/%,-m $(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@ +# $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(3)" pofile="$(CURDIR)/$(podir)/$(3).$(locale).po" threshold=0 "$(CURDIR)/$$@" endef $(foreach source,$(SOURCES),$(foreach module,$(po-init-modules),$(foreach locale,$(po-init-locales),$(eval $(call INITPO_template,$(l10ndir),$(locale),$(module),$(source),$(if $(po-init-fromlocale),$(module)_l10n/$(po-init-fromlocale),$(module))))))) @@ -93,11 +91,11 @@ ALL_POFILES += $(podir)/$(3).$(2).po LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)) $(podir)/$(3).$(2).po: $(3) - cd "$(3)" && PERL5LIB="$(CURDIR)/perl" po4a-updatepo -M UTF-8 -f $(fileformat) -o markdown $$(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@ + $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(3)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" pofile="$(CURDIR)/$$@" updatepo $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po mkdir -p $(1) - cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-translate -M UTF-8 -L UTF-8 -k 100 -f $(fileformat) -o markdown $$(patsubst $(1)/%,-m $$(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@ + $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(3)" pofile="$(CURDIR)/$(podir)/$(3).$(locale).po" "$(CURDIR)/$$@" endef # Only update if not initializing - can't do both at once ifeq ($(po-init-modules),) -- cgit v1.2.3