diff --git a/Makefile b/Makefile
index 028af20..3f77bbb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,33 +1,64 @@
-backup-locales:
- cp app/locales/*.yml zanata/backup/
+# From https://raw.githubusercontent.com/Polyconseil/vue-gettext/master/Makefile
-restore-locales:
- cp zanata/backup/*.yml app/locales/
+# 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)
-prepare-locales:
- rm -f zanata/yml/*.yml zanata/po/*.po zanata/po/*.pot zanata/po/*.err
+# 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
-clean-locales: backup-locales prepare-locales
- zanata/scripts/yml2po.sh
- zanata/scripts/po2yml.sh
+# Where to find input files (it can be multiple paths).
+INPUT_FILES = ./src
-po:
- zanata/scripts/yml2po.sh
+# Where to write the files generated by this makefile.
+OUTPUT_DIR = ./src
-yml: backup-locales
- zanata/scripts/po2yml.sh
+# Available locales for the app.
+LOCALES = en_US fr_FR
-push-locales: po
- zanata-cli -q -B push --push-type both
+# Name of the generated .po files for each available locale.
+LOCALE_FILES ?= $(patsubst %,$(OUTPUT_DIR)/locale/%/LC_MESSAGES/app.po,$(LOCALES))
-pull-locales: prepare-locales
- cp -n zanata/zanata.xml zanata.xml
- sed -e 's@@join-peertube@' -i zanata.xml
- zanata-cli -q -B pull --pull-type both --min-doc-percent 75
- make yml
+GETTEXT_SOURCES ?= $(shell find $(INPUT_FILES) -name '*.jade' -o -name '*.html' -o -name '*.js' -o -name '*.vue' 2> /dev/null)
-preview:
- npm run preview
+# Makefile Targets
+.PHONY: clean makemessages translations all
-build:
- npm run prod
+all:
+ @echo choose a target from: clean makemessages translations
+
+clean:
+ rm -f $(TEMPLATE_POT) $(OUTPUT_DIR)/translations.json
+
+makemessages: $(TEMPLATE_POT)
+
+translations: ./$(OUTPUT_DIR)/translations.json
+
+# 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 --quiet --attribute v-translate --output $@ $(GETTEXT_SOURCES)
+# 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;
+
+$(OUTPUT_DIR)/translations.json: $(LOCALE_FILES)
+ mkdir -p $(OUTPUT_DIR)
+ gettext-compile --output $@ $(LOCALE_FILES)
diff --git a/index.html b/index.html
index 46037de..a383d99 100644
--- a/index.html
+++ b/index.html
@@ -5,10 +5,12 @@
-
-
+
+
+
+