Blob Blame Raw
###############################################################################
#
#  The Apache HTTP server test page Makefile
#  Copyright (C) 2019  Alain Reguera Delgado
#
#  This program is free software: you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the Free
#  Software Foundation, either version 3 of the License, or (at your option)
#  any later version.
#
#  This program is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
#  more details.
#
#  You should have received a copy of the GNU General Public License along with
#  this program.  If not, see <https://www.gnu.org/licenses/>.
#
###############################################################################

#==============================================================================
# Configuration
#==============================================================================
lang = en_US
prefix = .
srcdir = .
datarootdir = $(prefix)/$(lang)
localedir = PO

#==============================================================================
# Requirements
#==============================================================================
all: $(datarootdir)/index.html

#======================================================================
# Translations
#======================================================================
$(localedir)/$(lang).pot: $(srcdir)/index.tpl.html
	xml2po -o /tmp/$(lang).pot $(srcdir)/index.tpl.html
	if [[ ! -f $(localedir)/$(lang).pot ]];then \
		msginit -i /tmp/$(lang).pot -o $(localedir)/$(lang).pot -l $(lang) --no-translator --width=80; \
	else \
		msgmerge -U $(localedir)/$(lang).pot /tmp/$(lang).pot; \
	fi
	rm /tmp/$(lang).pot
$(localedir)/$(lang).po: $(localedir)/$(lang).pot
	if [[ ! -f $(localedir)/$(lang).po ]];then \
		msginit -i $(localedir)/$(lang).pot -o $(localedir)/$(lang).po -l $(lang) --no-translator --width=80; \
	else \
		msgmerge -U $(localedir)/$(lang).po $(localedir)/$(lang).pot; \
	fi

#======================================================================
# Pages
#======================================================================
$(datarootdir):
	mkdir -p $(datarootdir)
$(datarootdir)/index.html: $(datarootdir) $(localedir)/$(lang).po $(srcdir)/index.tpl.html
	xmllint -noout $(srcdir)/index.tpl.html
	xml2po -p $(localedir)/$(lang).po -o $(datarootdir)/index.html $(srcdir)/index.tpl.html