diff options
author | n-peugnet <n.peugnet@free.fr> | 2022-03-25 14:34:44 +0100 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2022-03-25 14:50:57 +0100 |
commit | 5de7786306af5c66a69ff01fd4b6ceb929681a5f (patch) | |
tree | fcb839e6ac8200803778c203f2b784ba309e9c13 /Makefile | |
parent | 67f920f61571d52ed724dbffbfb41d2fe75d6872 (diff) | |
download | club1-docs-5de7786306af5c66a69ff01fd4b6ceb929681a5f.tar.gz club1-docs-5de7786306af5c66a69ff01fd4b6ceb929681a5f.zip |
better prepare gettext translations
- copy pot file in dir to add it to git repo
- make sphinx cmds that build docs require %.po files
- compile all messages in a single .pot
- allow fuzzy messages to be used
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 44 |
1 files changed, 28 insertions, 16 deletions
@@ -1,6 +1,5 @@ # Minimal makefile for Sphinx documentation # - # You can set these variables from the command line. override LOCALE := $(or $(LOCALE),fr) PUBHOST ?= club1.fr @@ -13,39 +12,52 @@ override NOTFR = endif SPHINXLANG = -D language=$(LOCALE) -SPHINXOPTS ?= +SPHINXOPTS += -a SPHINXBUILD ?= sphinx-build -SPHINXLCMDS = html latexpdf man -SPHINXCMDS = clean gettext +SPHINXLCMDS = html dirhtml singlehtml epub latex latexpdf latexpdfja text man texinfo info +SPHINXCMDS = pickle json htmlhelp changes xml pseudoxml linkcheck doctest coverage SOURCEDIR = . BUILDDIR = _build +MDFILES = index.md $(shell find . -type f -name '*.md') LOCALES = en -LOCALESDIRS = $(LOCALES:%=locales/%) +LOCALEFILES = $(LOCALES:%=locales/%/LC_MESSAGES/package.po) +DIRS = locales # Put it first so that "make" without argument is like "make help". help: $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $O -.PHONY: help locales publish Makefile $(SPHINXLCMDS) $(SPHINXCMDS) +.PHONY: help clean update-po gettext publish $(SPHINXLCMDS) $(SPHINXCMDS) + +update-po: $(LOCALEFILES) + +gettext: locales/package.pot + +$(LOCALEFILES): locales/%/LC_MESSAGES/package.po: locales/package.pot + sphinx-intl update -p $(<D) -l $* + @touch $@ -locales: $(LOCALESDIRS) +locales/package.pot: $(BUILDDIR)/gettext/package.pot | locales + cp $< $@ -$(LOCALESDIRS): gettext - sphinx-intl update -p $(BUILDDIR)/gettext -l $(@F) - touch $@ +$(DIRS): + mkdir -p $@ + +$(BUILDDIR)/gettext/package.pot: $(MDFILES) + $(SPHINXBUILD) -M gettext "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $O + @touch $@ publish: html rsync -av --del _build/html/ $(USER)@$(PUBHOST):$(PUBDIR) # Shinx commands that need locales. -$(SPHINXLCMDS): $(if $(NOTFR),locales/$(LOCALE)) +$(SPHINXLCMDS): $(if $(NOTFR),locales/$(LOCALE)/LC_MESSAGES/package.po) $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXLANG) $(SPHINXOPTS) $O # Other Sphinx commands for autocompletion $(SPHINXCMDS): - $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $0 - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $O + +clean: + rm -f locales/*/LC_MESSAGES/package.mo + rm -rf $(BUILDDIR)/* |