aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2019-12-04 08:27:39 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-12-04 08:27:39 +0100
commit3e49b44839237693ce1a8151325942704917f6c6 (patch)
tree75a1af8089d48d3bb14de2d9d98c503ee76433e2 /Makefile
parentde2b323847e0a91119625e4f506f51ec9d43872f (diff)
Update i18n cli tools (#2673)
* Update i18n cli tools Few things were bugging me when using the cli tool for i18n. So I've modified the tools to be easier to use. First, the tool automatically adds missing keys to all languages. This way, we always have all keys in all languages. Second, the tool detects all untranslated keys and adds automatically the todo comment after the value. Third, when adding a new key, the key is pushed to all languages at once. There is no need to duplicate it manually. Thus making the duplication process obsolete. Fourth, translation and ignore keys are manipulated at the same time. Thus we don't have obsolete ignored strings anymore. * Add i18n rules I find that having the common rules in the Makefile is easier to use, as long as you know they are here. As it is self documented, people will see the new rules when using make. * Use long parameters in Makefile I find that using long parameters in scripts makes it easier to understand what's going on. So I've switched all short parameters to long one. * Format all i18n files I've used the updated version of the cli tools to have some output that can be consistently formated. This commit is a huge formating commit. Nothing was added but some comments were removed in the process.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile69
1 files changed, 64 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 2d11116b7..ec559fed2 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ ifndef TAG
endif
PORT ?= 8080
+PHP := $(shell sh -c 'which php')
ifeq ($(findstring alpine,$(TAG)),alpine)
DOCKERFILE=Dockerfile-Alpine
@@ -14,20 +15,23 @@ else
DOCKERFILE=Dockerfile
endif
+############
+## Docker ##
+############
.PHONY: build
build: ## Build a Docker image
docker build \
--pull \
--tag freshrss/freshrss:$(TAG) \
- -f Docker/$(DOCKERFILE) .
+ --file Docker/$(DOCKERFILE) .
.PHONY: start
start: ## Start the development environment (use Docker)
docker run \
--rm \
- -v $(shell pwd):/var/www/FreshRSS:z \
- -p $(PORT):80 \
- -e FRESHRSS_ENV=development \
+ --volume $(shell pwd):/var/www/FreshRSS:z \
+ --publish $(PORT):80 \
+ --env FRESHRSS_ENV=development \
--name freshrss-dev \
freshrss/freshrss:$(TAG)
@@ -35,6 +39,61 @@ start: ## Start the development environment (use Docker)
stop: ## Stop FreshRSS container if any
docker stop freshrss-dev
+##########
+## I18N ##
+##########
+.PHONY: i18n-format
+i18n-format: ## Format I18N files
+ @$(PHP) ./cli/manipulate.translation.php -a format
+ @echo Files formatted.
+
+.PHONY: i18n-add-language
+i18n-add-language: ## Add a new supported language
+ifndef lang
+ @echo To add a new language, you need to provide one in the "lang" variable.
+ @exit 10
+endif
+ @$(PHP) ./cli/manipulate.translation.php -a add -l $(lang)
+ @echo Language added.
+
+.PHONY: i18n-add-key
+i18n-add-key: ## Add a translation key to all supported languages
+ifndef key
+ @echo To add a key, you need to provide one in the "key" variable.
+ @exit 10
+endif
+ifndef value
+ @echo To add a key, you need to provide its value in the "value" variable.
+ @exit 10
+endif
+ @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v $(value)
+ @echo Key added.
+
+.PHONY: i18n-remove-key
+i18n-remove-key: ## Remove a translation key from all supported languages
+ifndef key
+ @echo To remove a key, you need to provide one in the "key" variable.
+ @exit 10
+endif
+ @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
+ @echo Key removed.
+
+.PHONY: i18n-ignore-key
+i18n-ignore-key: ## Ignore a translation key for the selected language
+ifndef lang
+ @echo To ignore a key, you need to provide a language in the "lang" variable.
+ @exit 10
+endif
+ifndef key
+ @echo To ignore a key, you need to provide one in the "key" variable.
+ @exit 10
+endif
+ @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang)
+ @echo Key ignored.
+
+##########
+## HELP ##
+##########
.PHONY: help
help:
- @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
+ @grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'