feat(i18n): consume central translations from escalated-dev/locale#53
Merged
feat(i18n): consume central translations from escalated-dev/locale#53
Conversation
Adds the central locale Composer package to require and prepends its translations/ directory onto framework.translator.paths via the bundle's prependExtension hook. The plugin-local translations/ path is registered after the central path so it remains higher priority and can override individual keys.
Adds a Translations section to the README explaining that strings are sourced from escalated-dev/locale and overridable by the plugin-local or host app translations/ directories. Notes the change in CHANGELOG.
Composer resolves escalated-dev/locale ^0.1 from github.com/escalated-dev/escalated-locale via vcs repository (v0.1.1 tag). Once the package is submitted to Packagist this block can be removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires this bundle to consume UI translations from the central
escalated-dev/localeComposer package instead of carrying its own copy in perpetuity.
composer.jsonnow requiresescalated-dev/locale: ^0.1(additive,preserves the existing multi-major constraint idiom established by chore(deps): widen multi-major constraints #52).
EscalatedBundle::prependExtension()registers the central package'stranslations/directory ontoframework.translator.paths, with theplugin-local
translations/directory listed after it so it (and thehost app's
translations/) continue to override on a per-key basis.translations/directory is unchanged and serves asthe override location — no translation content is modified by this PR.
CHANGELOG records the change under
[Unreleased].Wiring details
The central package is a plain Composer library, not a Symfony bundle, so
it cannot self-register. The bundle's
prependExtensionresolves theinstalled package's
translations/path at boot and prepends it ontoframework.translator.paths. Symfony's translator gives later-registeredpaths higher priority, which is why the order is:
vendor/escalated-dev/locale/translations(central, low priority)<bundle>/translations(plugin-local, higher priority)translations/(highest, auto-discovered)A
nullguard around the path lookup keeps the bundle bootable inisolated test environments where the central package isn't installed.
Blocked
Blocked on
escalated-dev/escalated-localev0.1.0 Packagist publish.CI will fail at
composer installuntil the central package tags v0.1.0and is registered on Packagist. Marked as draft until then.
Test plan
escalated-dev/localev0.1.0 published to Packagistcomposer installresolves successfully on CIcomposer installresolves locally on PHP 8.2 / 8.3appear via
bin/console debug:translation <locale>translations/messages.en.yamloverrides the central package's value