Skip to content

Fix admin label fallback for regioned locales#11

Merged
rhukster merged 1 commit into
getgrav:developfrom
Sogl:fix/admin-label-region-fallback
Jun 28, 2026
Merged

Fix admin label fallback for regioned locales#11
rhukster merged 1 commit into
getgrav:developfrom
Sogl:fix/admin-label-region-fallback

Conversation

@Sogl

@Sogl Sogl commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Expand the admin label language fallback chain so regioned admin preferences also try the primary subtag before English.
  • Keep the existing primary-to-region expansion for Admin Next dictionaries such as en -> en-US.
  • Add unit coverage for ru-RU, es-MX, and bare en fallback chains.

This lets dual-target plugins keep normal short-code language files such as ru.yaml / en.yaml unless they intentionally need region-specific translations.

Testing

  • /usr/local/opt/php@8.3/bin/php -l classes/Api/Controllers/TranslatesAdminLabels.php
  • /usr/local/opt/php@8.3/bin/php -l tests/Unit/Controllers/TranslatesAdminLabelsTest.php
  • /usr/local/opt/php@8.3/bin/php vendor/phpunit/phpunit/phpunit --configuration phpunit.xml tests/Unit/Controllers/TranslatesAdminLabelsTest.php
  • GRAV_ROOT=/Users/artyom/domains/palagin2 /usr/local/opt/php@8.3/bin/php vendor/phpunit/phpunit/phpunit --configuration phpunit.xml tests/Unit/Controllers/TranslatesAdminLabelsTest.php

Full suite check:

  • GRAV_ROOT=/Users/artyom/domains/palagin2 /usr/local/opt/php@8.3/bin/php vendor/phpunit/phpunit/phpunit --configuration phpunit.xml currently fails on the unchanged develop baseline with 8 existing auth errors in ApiKeyManager and 1 existing CORS exposed-headers failure. The same failures reproduce after stashing this PR's changes.

@rhukster rhukster merged commit 80437db into getgrav:develop Jun 28, 2026
@rhukster

Copy link
Copy Markdown
Member

Thanks for this, and for the thorough tests. I reproduced it on a clean develop: a regioned admin preference like ru-RU built the chain ['ru-RU', 'en', 'en-US'] and skipped the bare ru, so a plugin shipping a plain ru.yaml never got a look in and labels dropped to English. Your two new cases fail before the change and pass after it, exactly as expected.

Merged, and I added a CHANGELOG entry for the next release. Appreciate the clear write-up and the fix keeping the existing en -> en-US expansion intact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants