From 8a59dc3402bb3d200f74e7d1ea06d77124ccc492 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 3 Sep 2025 00:50:24 -0400 Subject: [PATCH] add target to generate the translation progress (#7905) * add target to generate the translation progress * replace short options by long options This adds a little bit of explanation for someone looking at the code without knowing how the underlying script is working. * sort test targets * sort i18n targets --- Makefile | 106 ++++++++++++++++++++++++++------------------------ composer.json | 2 +- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index ffa3ad3e7..2c7bb8848 100644 --- a/Makefile +++ b/Makefile @@ -54,18 +54,18 @@ stop: ## Stop FreshRSS container if any docker network rm $(NETWORK) || true ##@ Tests and linter -.PHONY: test -test: bin/phpunit ## Run the test suite - $(PHP) bin/phpunit --bootstrap ./tests/bootstrap.php ./tests - .PHONY: lint -lint: bin/phpcs ## Run the linter on the PHP files +lint: bin/phpcs ## Run the linter on PHP files $(PHP) bin/phpcs . -p -s .PHONY: lint-fix lint-fix: bin/phpcbf ## Fix the errors detected by the linter $(PHP) bin/phpcbf . -p -s +.PHONY: test +test: bin/phpunit ## Run the test suite + $(PHP) bin/phpunit --bootstrap ./tests/bootstrap.php ./tests + bin/composer: mkdir -p bin/ wget 'https://raw.githubusercontent.com/composer/getcomposer.org/9e43d8a9b16fffa4dc9b090b9104dab7d815424a/web/installer' -O - -q | php -- --quiet --install-dir='./bin/' --filename='composer' @@ -95,19 +95,6 @@ node_modules/.bin/rtlcss: npm install ##@ 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 - $(error To add a new language, you need to provide one in the "lang" variable) -endif - $(PHP) ./cli/manipulate.translation.php -a add -l $(lang) -o $(ref) - @echo Language added. - .PHONY: i18n-add-key i18n-add-key: ## Add a translation key to all supported languages ifndef key @@ -116,15 +103,54 @@ endif ifndef value $(error To add a key, you need to provide its value in the "value" variable) endif - @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)" + @$(PHP) ./cli/manipulate.translation.php --action add --key $(key) --value "$(value)" @echo Key added. +.PHONY: i18n-add-language +i18n-add-language: ## Add a new supported language +ifndef lang + $(error To add a new language, you need to provide one in the "lang" variable) +endif + $(PHP) ./cli/manipulate.translation.php --action add --language $(lang) --origin-language $(ref) + @echo Language added. + +.PHONY: i18n-format +i18n-format: ## Format I18N files + @$(PHP) ./cli/manipulate.translation.php --action format + @echo Files formatted. + +.PHONY: i18n-ignore-key +i18n-ignore-key: ## Ignore a translation key for the selected language +ifndef lang + $(error To ignore a key, you need to provide a language in the "lang" variable) +endif +ifndef key + $(error To ignore a key, you need to provide one in the "key" variable) +endif + @$(PHP) ./cli/manipulate.translation.php --action ignore --key $(key) --language $(lang) + @echo Key ignored. + +.PHONY: i18n-ignore-unmodified-keys +i18n-ignore-unmodified-keys: ## Ignore all unmodified translation keys for the selected language +ifndef lang + $(error To ignore unmodified keys, you need to provide a language in the "lang" variable) +endif + @$(PHP) ./cli/manipulate.translation.php --action ignore_unmodified --language $(lang) + @echo Unmodified keys ignored. + +.PHONY: i18n-key-exists +i18n-key-exists: ## Check if a translation key exists +ifndef key + $(error To check if a key exists, you need to provide one in the "key" variable) +endif + @$(PHP) ./cli/manipulate.translation.php --action exist --key $(key) + .PHONY: i18n-remove-key i18n-remove-key: ## Remove a translation key from all supported languages ifndef key $(error To remove a key, you need to provide one in the "key" variable) endif - @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key) + @$(PHP) ./cli/manipulate.translation.php --action delete --key $(key) @echo Key removed. .PHONY: i18n-update-key @@ -135,48 +161,26 @@ endif ifndef value $(error To update a key, you need to provide its value in the "value" variable) endif - @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)" -l en + @$(PHP) ./cli/manipulate.translation.php --action add --key $(key) --value "$(value)" --language en @echo Key updated. -.PHONY: i18n-ignore-key -i18n-ignore-key: ## Ignore a translation key for the selected language -ifndef lang - $(error To ignore a key, you need to provide a language in the "lang" variable) -endif -ifndef key - $(error To ignore a key, you need to provide one in the "key" variable) -endif - @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang) - @echo Key ignored. - -.PHONY: i18n-ignore-unmodified-keys -i18n-ignore-unmodified-keys: ## Ignore all unmodified translation keys for the selected language -ifndef lang - $(error To ignore unmodified keys, you need to provide a language in the "lang" variable) -endif - @$(PHP) ./cli/manipulate.translation.php -a ignore_unmodified -l $(lang) - @echo Unmodified keys ignored. - -.PHONY: i18n-key-exists -i18n-key-exists: ## Check if a translation key exists -ifndef key - $(error To check if a key exists, you need to provide one in the "key" variable) -endif - @$(PHP) ./cli/manipulate.translation.php -a exist -k $(key) - ##@ Tools -.PHONY: rtl -rtl: node_modules/.bin/rtlcss ## Generate RTL CSS files - npm run-script rtlcss - .PHONY: pot pot: ## Generate POT templates for docs cd docs && ../cli/translation-update.sh +.PHONY: readme +readme: ## Generate translation progress in README file + @$(PHP) ./cli/check.translation.php --generate-readme + .PHONY: refresh refresh: ## Refresh feeds by fetching new messages @$(PHP) ./app/actualize_script.php +.PHONY: rtl +rtl: node_modules/.bin/rtlcss ## Generate RTL CSS files + npm run-script rtlcss + ############################### ## New commands aligned on CI # ## Work in progress # diff --git a/composer.json b/composer.json index 13344713d..4c9d1f228 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,7 @@ "phpstan": "phpstan analyse .", "phpstan-next": "phpstan analyse -c phpstan-next.neon .", "phpunit": "phpunit --bootstrap ./tests/bootstrap.php --display-notices --display-phpunit-deprecations ./tests", - "translations": "cli/manipulate.translation.php -a format && cli/check.translation.php -g", + "translations": "cli/manipulate.translation.php --action format && cli/check.translation.php --generate-readme", "test": [ "@php-lint", "@phtml-lint",