- SOURCES = ikiwiki
- ikiwiki_ORIGIN = http://source.jones.dk/ikiwiki_MODULE.git
- ikiwiki_MODULES = basewiki smiley templates
- ikiwiki_BRANCH = master-LOCALE
- ikiwiki_LOCALES = da
- #dummy_MODULES = content_dummy
- # Everything after this is generic
- underlays_l10n = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(patsubst %,%_l10n/$(locale),$($(source)_MODULES))))
- underlays = $(foreach source, $(SOURCES), $($(source)_MODULES)) $(underlays_l10n)
- # FIXME: Handle translation of templates (needs po4a parser for HTML::Template markup)
- #potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$($(source)_MODULES)))
- potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$(filter-out templates,$($(source)_MODULES))))
- pofiles = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(patsubst %.pot,%.$(locale).po,$(potfiles))))
- l10nfiles = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(foreach underlay,$(patsubst po/%.$(locale).po,%,$(pofiles)), $(patsubst %,$(l10ndir)/%,$(l10nfiles_in_underlay)))))
- source_of_underlay = $(firstword $(foreach source, $(SOURCES), $(if $(filter $(underlay),$($(source)_MODULES)),$(source))))
- origin = $(subst MODULE,$(underlay),$($(source_of_underlay)_ORIGIN))
- master = $(subst -LOCALE,$(locale:%=-$(locale)),$($(source_of_underlay)_BRANCH))
- masterdir = $(underlay)
- l10ndir = $(underlay)_l10n/$(locale)
- # FIXME: The po4a plugin for HTML::Template needs to be written...
- fileformat = $(if $(filter templates,$(underlay)),htmltemplate,text)
- filetype = $(if $(filter templates,$(underlay)),tmpl,mdwn)
- l10nfiles_in_underlay = $(shell cd "$(masterdir)" && find * -type f -name '*.$(filetype)')
- all: $(underlays) $(dummy_MODULES)
- $(underlays): locale=$(if $(filter l10n/,$(lastword $(subst _, ,$(dir $@)))),$(notdir $@))
- $(underlays): underlay=$(@:%_l10n/$(locale)=%)
- $(underlays):
- mkdir -p $@
- @if [ -d "$@/.git" ]; then \
- cd $@ && \
- git pull; \
- else \
- cd $@ && \
- git init && \
- git remote add -f -t $(master) -m $(master) origin $(origin) && \
- git merge origin && \
- git config remote.origin.push +refs/heads/master:refs/heads/$(master); \
- fi
- pot: $(potfiles)
- po: pot $(pofiles)
- translations: po $(l10nfiles)
- $(potfiles): underlay=$(patsubst po/%.pot,%,$@)
- $(potfiles):
- cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
- $(pofiles): underlay=$(basename $(patsubst po/%.po,%,$@))
- $(pofiles): locale=$(patsubst .%,%,$(suffix $(patsubst po/%.po,%,$@)))
- ifeq ($(translation_mode),init)
- $(pofiles):
- # cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) $(patsubst %,-l $(CURDIR)/$(l10ndir)/%,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
- ( cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) $(patsubst %,-l $(CURDIR)/$(l10ndir)/%,$(l10nfiles_in_underlay)) ) \
- | grep -v '#, fuzzy' \
- > $@
- else
- $(pofiles):
- cd "$(masterdir)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
- endif
- #$(error $(l10nfiles):)
- $(l10nfiles): underlay=$(patsubst %_l10n,%,$(firstword $(subst /, ,$@)))
- $(l10nfiles): locale=$(patsubst %_l10n,%,$(word 2,$(subst /, ,$@)))
- $(l10nfiles):
- mkdir -p $(l10ndir)
- ifeq ($(translation_mode),init)
- cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 -k 0 -f $(fileformat) -m $(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -p $(CURDIR)/po/$(underlay).$(locale).po -l $(CURDIR)/$@
- else
- cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 -k 100 -f $(fileformat) -m $(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -p $(CURDIR)/po/$(underlay).$(locale).po -l $(CURDIR)/$@
- endif
- $(dummy_MODULES):
- mkdir -p $@
- install:
- $(error FIXME: you need to adjust ikiwiki.setup first!)
- # ikiwiki --setup ikiwiki.setup --rebuild
- # WARNING: this may wipe unrelated files too!
- ultraclean:
- rm -rf $(underlays)
- rm -rf $(dir $(underlays_l10n))
- rm -rf $(dummy_MODULES)
- .PHONY: pot po translations $(underlays)
|