Harden language catalog repair and syntax validation (#1114)

Improve language-update.sh script, fix missing semi-colons, cover languages/*.lang in ci with parallel-lint etc.
Fixes #1112 #1113

thanks @TrapoSAMA
This commit is contained in:
Rodrigo Cortés Cano authored and GitHub committed 2026-08-12 09:07:15 +01:00
1 parent 60f8c46514
commit 2008d06bf4
28 files changed
+224 -52

No files matched your search

+8 -1
View File
@@ -19,6 +19,10 @@ jobs:
tools: composer tools: composer
extensions: sqlite3, gd extensions: sqlite3, gd
- name: Check language catalogs
working-directory: languages
run: /bin/bash language-update.sh
- name: Get composer cache directory - name: Get composer cache directory
if: ${{ !env.ACT }} if: ${{ !env.ACT }}
id: composer-cache id: composer-cache
@@ -42,7 +46,10 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: composer update --prefer-dist -n run: composer update --prefer-dist -n
- name: check formatting - name: lint checks
run: composer lint
- name: formatting checks
run: composer check-format run: composer check-format
- name: touch config.local.php - name: touch config.local.php
+1 -1
View File
@@ -16,7 +16,7 @@
], ],
"check-format": "@php vendor/bin/php-cs-fixer fix --ansi --dry-run --diff", "check-format": "@php vendor/bin/php-cs-fixer fix --ansi --dry-run --diff",
"format": "@php vendor/bin/php-cs-fixer fix --ansi", "format": "@php vendor/bin/php-cs-fixer fix --ansi",
"lint": "@php ./vendor/bin/parallel-lint --exclude vendor/ --exclude debian/ .", "lint": "@php ./vendor/bin/parallel-lint --exclude vendor/ --exclude debian/ -e php,lang .",
"test": "@php ./vendor/bin/phpunit --coverage-clover ./clover.xml --do-not-cache-result tests/", "test": "@php ./vendor/bin/phpunit --coverage-clover ./clover.xml --do-not-cache-result tests/",
"test-fixup": "mkdir -p templates_c ; test -f config.local.php || touch config.local.php", "test-fixup": "mkdir -p templates_c ; test -f config.local.php || touch config.local.php",
"psalm": "@php ./vendor/bin/psalm.phar --no-cache --show-info=false ", "psalm": "@php ./vendor/bin/psalm.phar --no-cache --show-info=false ",
+2 -2
View File
@@ -470,8 +470,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
$PALANG['pLegal_char_warning'] = 'Illegal character'; # XXX $PALANG['pLegal_char_warning'] = 'Illegal character'; # XXX
+2 -2
View File
@@ -469,8 +469,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
$PALANG['pLegal_char_warning'] = 'Caràcter il·legal'; $PALANG['pLegal_char_warning'] = 'Caràcter il·legal';
+2 -2
View File
@@ -469,8 +469,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -483,8 +483,8 @@ $PALANG['pFetchmail_desc_date'] = 'Dato for seneste prøve/konfigura
$PALANG['pFetchmail_desc_returned_text'] = 'Tekstbesked fra seneste prøve'; $PALANG['pFetchmail_desc_returned_text'] = 'Tekstbesked fra seneste prøve';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -473,8 +473,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -468,8 +468,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -469,8 +469,8 @@ $PALANG['pFetchmail_desc_date'] = 'Viimeisen tarkistuksen/konfiguraa
$PALANG['pFetchmail_desc_returned_text'] = 'Viesti edellisestä tarkistuksesta'; $PALANG['pFetchmail_desc_returned_text'] = 'Viesti edellisestä tarkistuksesta';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -474,8 +474,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -468,8 +468,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -482,8 +482,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -469,8 +469,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -470,8 +470,8 @@ $PALANG['pFetchmail_desc_date'] = 'Data dell\'ultima modifica o atti
$PALANG['pFetchmail_desc_returned_text'] = 'Risultato dell\'ultima attività'; $PALANG['pFetchmail_desc_returned_text'] = 'Risultato dell\'ultima attività';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -480,8 +480,8 @@ $PALANG['pFetchmail_desc_date'] = '最終取得確認/設定変更
$PALANG['pFetchmail_desc_returned_text'] = '新着確認の戻りテキストメッセージ'; $PALANG['pFetchmail_desc_returned_text'] = '新着確認の戻りテキストメッセージ';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+46 -2
View File
@@ -28,6 +28,17 @@ function update_string_list() {
# order, which the old diff-based approach did. # order, which the old diff-based approach did.
PA_NOTEXT="$notext" PA_PATCH="$patch" php /dev/stdin en.lang $filelist <<'ENDOFPHP' PA_NOTEXT="$notext" PA_PATCH="$patch" php /dev/stdin en.lang $filelist <<'ENDOFPHP'
<?php <?php
# Validate the PHP syntax without executing the language file.
function validate_php_syntax(string $src, string $file): bool {
try {
token_get_all($src, TOKEN_PARSE);
return true;
} catch (ParseError $e) {
fwrite(STDERR, "*** $file: PHP syntax error: {$e->getMessage()} ***\n");
return false;
}
}
# Parse $PALANG['key'] = ...; statements from a language file's SOURCE (never # Parse $PALANG['key'] = ...; statements from a language file's SOURCE (never
# include()d, to avoid executing it) and return them in file order as # include()d, to avoid executing it) and return them in file order as
# [key, startLine, endLine, sourceText]. # [key, startLine, endLine, sourceText].
@@ -69,13 +80,22 @@ function parse_palang(string $src): array {
$notext = getenv('PA_NOTEXT') === '1'; $notext = getenv('PA_NOTEXT') === '1';
$patch = getenv('PA_PATCH') === '1'; $patch = getenv('PA_PATCH') === '1';
$failed = false;
$reference = 'en.lang'; $reference = 'en.lang';
if (!is_file($reference)) { if (!is_file($reference)) {
fwrite(STDERR, "*** $reference not found in current directory ***\n"); fwrite(STDERR, "*** $reference not found in current directory ***\n");
exit(1); exit(1);
} }
$enStmts = parse_palang(file_get_contents($reference)); $referenceSrc = file_get_contents($reference);
if ($referenceSrc === false) {
fwrite(STDERR, "*** unable to read $reference ***\n");
exit(1);
}
if (!validate_php_syntax($referenceSrc, $reference)) {
exit(1);
}
$enStmts = parse_palang($referenceSrc);
$enOrder = []; // ordered list of keys $enOrder = []; // ordered list of keys
$enSource = []; // key => source text $enSource = []; // key => source text
foreach ($enStmts as [$key, , , $text]) { foreach ($enStmts as [$key, , , $text]) {
@@ -92,10 +112,22 @@ foreach ($files as $file) {
} }
if (!is_file($file)) { if (!is_file($file)) {
fwrite(STDERR, "*** $file not found, skipping ***\n"); fwrite(STDERR, "*** $file not found, skipping ***\n");
$failed = true;
continue; continue;
} }
$src = file_get_contents($file); $src = file_get_contents($file);
if ($src === false) {
fwrite(STDERR, "*** unable to read $file ***\n");
$failed = true;
continue;
}
if (!validate_php_syntax($src, $file)) {
$failed = true;
break;
}
$transStmts = parse_palang($src); $transStmts = parse_palang($src);
$transKeys = []; // key => endLine (last definition wins) $transKeys = []; // key => endLine (last definition wins)
foreach ($transStmts as [$key, , $endLine, ]) { foreach ($transStmts as [$key, , $endLine, ]) {
@@ -121,6 +153,13 @@ foreach ($files as $file) {
continue; continue;
} }
// Read-only checks must report incomplete catalogs through the exit code.
// --patch can still succeed when it adds every missing key, but obsolete
// keys remain an error because that mode deliberately leaves them in place.
if (!$patch) {
$failed = true;
}
if ($notext) { if ($notext) {
echo "### $file ###\n"; echo "### $file ###\n";
foreach ($missing as [$key, ]) { foreach ($missing as [$key, ]) {
@@ -186,6 +225,7 @@ foreach ($files as $file) {
file_put_contents($file, implode("\n", $out)); file_put_contents($file, implode("\n", $out));
echo "*** $file: added " . count($missing) . " missing string(s)"; echo "*** $file: added " . count($missing) . " missing string(s)";
if ($obsolete) { if ($obsolete) {
$failed = true;
echo ", " . count($obsolete) . " obsolete string(s) left in place (see --remove/--obsolete)"; echo ", " . count($obsolete) . " obsolete string(s) left in place (see --remove/--obsolete)";
} }
echo " ***\n"; echo " ***\n";
@@ -193,6 +233,7 @@ foreach ($files as $file) {
fwrite(STDERR, "# obsolete in $file (not in en.lang): $key\n"); fwrite(STDERR, "# obsolete in $file (not in en.lang): $key\n");
} }
} }
exit($failed ? 1 : 0);
ENDOFPHP ENDOFPHP
} # end update_string_list() } # end update_string_list()
@@ -526,4 +567,7 @@ test "$comparetext" = 1 && { comparetext ; cleanup ; exit 0 ; }
test "$stats" = 1 && { statistics ; exit 0 ; } test "$stats" = 1 && { statistics ; exit 0 ; }
update_string_list ; cleanup # default operation update_string_list
status=$?
cleanup # default operation
exit $status
+2 -2
View File
@@ -475,8 +475,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -470,8 +470,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -470,8 +470,8 @@ $PALANG['pFetchmail_desc_date'] = 'Dato for siste spørring/konfigur
$PALANG['pFetchmail_desc_returned_text'] = 'Tekstmelding fra siste spørring'; $PALANG['pFetchmail_desc_returned_text'] = 'Tekstmelding fra siste spørring';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -469,8 +469,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -475,8 +475,8 @@ $PALANG['pFetchmail_desc_date'] = 'Data ostatniego sprawdzenia/zmian
$PALANG['pFetchmail_desc_returned_text'] = 'Wiadomość tekstowa z ostatniego sprawdzenia'; $PALANG['pFetchmail_desc_returned_text'] = 'Wiadomość tekstowa z ostatniego sprawdzenia';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -482,8 +482,8 @@ $PALANG['pFetchmail_desc_date'] = 'Data da última checagem/mudança
$PALANG['pFetchmail_desc_returned_text'] = 'Mensagem de texto da última checagem'; $PALANG['pFetchmail_desc_returned_text'] = 'Mensagem de texto da última checagem';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -481,8 +481,8 @@ $PALANG['pFetchmail_desc_returned_text'] = 'Mesaj text';
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -470,8 +470,8 @@ $PALANG['pFetchmail_desc_date'] = 'Dátum poslednej zmeny konfigurá
$PALANG['pFetchmail_desc_returned_text'] = 'Správa z posledného sťahovania'; $PALANG['pFetchmail_desc_returned_text'] = 'Správa z posledného sťahovania';
$PALANG['dateformat_pgsql'] = 'dd.mm.YYYY'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format $PALANG['dateformat_pgsql'] = 'dd.mm.YYYY'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format
$PALANG['dateformat_mysql'] = '%d.%m.%Y'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format $PALANG['dateformat_mysql'] = '%d.%m.%Y'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -469,8 +469,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -482,8 +482,8 @@ $PALANG['pFetchmail_desc_returned_text'] = 'Textmeddelande från senaste kont
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+2 -2
View File
@@ -471,8 +471,8 @@ $PALANG['pFetchmail_desc_date'] = 'Date of last polling/configuratio
$PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX $PALANG['pFetchmail_desc_returned_text'] = 'Text message from last polling'; # XXX
$PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX $PALANG['dateformat_pgsql'] = 'YYYY-mm-dd'; # translators: rearrange to your local date format, but make sure it's a valid PostgreSQL date format # XXX
$PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX $PALANG['dateformat_mysql'] = '%Y-%m-%d'; # translators: rearrange to your local date format, but make sure it's a valid MySQL date format # XXX
$PALANG['password_expiration'] = 'Password expiration (days)' # XXX $PALANG['password_expiration'] = 'Password expiration (days)'; # XXX
$PALANG['password_expiration_desc'] = 'Number of days before the password expires' # XXX $PALANG['password_expiration_desc'] = 'Number of days before the password expires'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX $PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX $PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX
+121
View File
@@ -0,0 +1,121 @@
<?php
use PHPUnit\Framework\TestCase;
class LanguageUpdateScriptTest extends TestCase
{
private string $directory;
private string $script;
protected function setUp(): void
{
if (PHP_OS_FAMILY === 'Windows' || !is_executable('/bin/bash')) {
$this->markTestSkipped('language-update.sh requires a Unix-like environment with Bash');
}
$this->directory = sys_get_temp_dir() . '/postfixadmin-language-update-' . bin2hex(random_bytes(6));
self::assertTrue(mkdir($this->directory));
$script = realpath(__DIR__ . '/../languages/language-update.sh');
self::assertNotFalse($script);
$this->script = $script;
file_put_contents($this->directory . '/en.lang', <<<'PHP'
<?php
$PALANG['one'] = 'One';
$PALANG['body'] = <<<EOM
Body
EOM;
$PALANG['three'] = 'Three';
PHP);
}
protected function tearDown(): void
{
if (!isset($this->directory) || !is_dir($this->directory)) {
return;
}
foreach (new DirectoryIterator($this->directory) as $file) {
if (!$file->isDot()) {
unlink($file->getPathname());
}
}
rmdir($this->directory);
}
public function testInvalidSyntaxStopsBeforeMissingKeyDetection(): void
{
file_put_contents($this->directory . '/test.lang', <<<'PHP'
<?php
$PALANG['one'] = 'One'
$PALANG['body'] = <<<EOM
Body
EOM;
$PALANG['three'] = 'Three';
PHP);
file_put_contents($this->directory . '/after.lang', <<<'PHP'
<?php
$PALANG['one'] = 'One';
$PALANG['three'] = 'Three';
PHP);
[$status, $stdout, $stderr] = $this->runScript(['test.lang', 'after.lang']);
self::assertSame(1, $status);
self::assertStringContainsString('PHP syntax error', $stderr);
self::assertStringNotContainsString('--fix', $stderr);
self::assertStringNotContainsString(' missing,', $stdout);
self::assertStringNotContainsString('after.lang', $stdout);
}
public function testMissingTranslationsReturnFailure(): void
{
file_put_contents($this->directory . '/test.lang', <<<'PHP'
<?php
$PALANG['one'] = 'One';
$PALANG['three'] = 'Three';
PHP);
[$status, $stdout, $stderr] = $this->runScript(['test.lang']);
self::assertSame(1, $status, $stderr);
self::assertStringContainsString('1 missing, 0 obsolete', $stdout);
}
public function testObsoleteTranslationsReturnFailure(): void
{
file_put_contents($this->directory . '/test.lang', <<<'PHP'
<?php
$PALANG['one'] = 'One';
$PALANG['body'] = <<<EOM
Body
EOM;
$PALANG['three'] = 'Three';
$PALANG['obsolete'] = 'Obsolete';
PHP);
[$status, $stdout, $stderr] = $this->runScript(['test.lang']);
self::assertSame(1, $status, $stderr);
self::assertStringContainsString('0 missing, 1 obsolete', $stdout);
}
private function runScript(array $arguments): array
{
$command = array_merge(['/bin/bash', $this->script], $arguments);
$pipes = [];
$process = proc_open($command, [
0 => ['pipe', 'r'],
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
], $pipes, $this->directory);
self::assertIsResource($process);
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
return [proc_close($process), $stdout, $stderr];
}
}