joinpeertube/Makefile

65 lines
2.5 KiB
Makefile
Raw Permalink Normal View History

2019-09-11 13:17:18 +00:00
# From https://raw.githubusercontent.com/Polyconseil/vue-gettext/master/Makefile
2018-03-21 07:04:22 +00:00
2019-09-11 13:17:18 +00:00
# On OSX the PATH variable isn't exported unless "SHELL" is also set, see: http://stackoverflow.com/a/25506676
SHELL = /bin/bash
NODE_BINDIR = ./node_modules/.bin
export PATH := $(NODE_BINDIR):$(PATH)
LOGNAME ?= $(shell logname)
2018-03-21 07:04:22 +00:00
2019-09-11 13:17:18 +00:00
# adding the name of the user's login name to the template file, so that
# on a multi-user system several users can run this without interference
TEMPLATE_POT ?= /tmp/template-$(LOGNAME).pot
2018-03-21 07:04:22 +00:00
2019-09-11 13:17:18 +00:00
# Where to find input files (it can be multiple paths).
INPUT_FILES = ./src
2018-03-21 07:04:22 +00:00
2019-09-11 13:17:18 +00:00
# Where to write the files generated by this makefile.
OUTPUT_DIR = ./src
2018-03-30 13:27:39 +00:00
2019-09-11 13:17:18 +00:00
# Available locales for the app.
2019-12-10 07:40:53 +00:00
LOCALES = en_US fr_FR de es ru sv it pl
2018-03-21 07:04:22 +00:00
2019-09-11 13:17:18 +00:00
# Name of the generated .po files for each available locale.
LOCALE_FILES ?= $(patsubst %,$(OUTPUT_DIR)/locale/%/LC_MESSAGES/app.po,$(LOCALES))
2018-03-21 07:04:22 +00:00
2019-09-11 13:17:18 +00:00
GETTEXT_SOURCES ?= $(shell find $(INPUT_FILES) -name '*.jade' -o -name '*.html' -o -name '*.js' -o -name '*.vue' 2> /dev/null)
2018-09-21 21:00:42 +00:00
2019-09-11 13:17:18 +00:00
# Makefile Targets
.PHONY: clean makemessages translations all
2018-09-21 21:00:42 +00:00
2019-09-11 13:17:18 +00:00
all:
@echo choose a target from: clean makemessages translations
clean:
2019-10-25 17:57:46 +00:00
rm -rf $(TEMPLATE_POT)
2019-09-11 13:17:18 +00:00
makemessages: $(TEMPLATE_POT)
2019-10-25 17:57:46 +00:00
translations: $(LOCALE_FILES)
mkdir -p $(OUTPUT_DIR)/translations
@for lang in $(LOCALES); do \
gettext-compile --output $(OUTPUT_DIR)/translations/$$lang.json $(OUTPUT_DIR)/locale/$$lang/LC_MESSAGES/app.po; \
done;
2019-09-11 13:17:18 +00:00
# Create a main .pot template, then generate .po files for each available language.
# Thanx to Systematic: https://github.com/Polyconseil/systematic/blob/866d5a/mk/main.mk#L167-L183
$(TEMPLATE_POT): $(GETTEXT_SOURCES)
# `dir` is a Makefile built-in expansion function which extracts the directory-part of `$@`.
# `$@` is a Makefile automatic variable: the file name of the target of the rule.
# => `mkdir -p /tmp/`
mkdir -p $(dir $@)
# Extract gettext strings from templates files and create a POT dictionary template.
gettext-extract --removeHTMLWhitespaces --quiet --attribute v-translate --output $@ $(GETTEXT_SOURCES)
2019-09-11 13:17:18 +00:00
# Generate .po files for each available language.
@for lang in $(LOCALES); do \
export PO_FILE=$(OUTPUT_DIR)/locale/$$lang/LC_MESSAGES/app.po; \
mkdir -p $$(dirname $$PO_FILE); \
if [ -f $$PO_FILE ]; then \
echo "msgmerge --update $$PO_FILE $@"; \
msgmerge --lang=$$lang --update $$PO_FILE $@ || break ;\
else \
msginit --no-translator --locale=$$lang --input=$@ --output-file=$$PO_FILE || break ; \
msgattrib --no-wrap --no-obsolete -o $$PO_FILE $$PO_FILE || break; \
fi; \
done;