# 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): % : $(masterdir)/%
	po4a-translate -M UTF-8 -L UTF-8 -k "$(threshold)" -f "$(fileformat)" -o markdown $(patsubst %,-m $(masterdir)/%,$@) -p "$(pofile)" -l "$@"

.PHONY: mkpot mkpo $(l10nfiles)