Skip to content

Document i18n cache key prefix and configurable cache config (5.next)#8289

Draft
dereuromark wants to merge 1 commit into5.nextfrom
feature/i18n-cache-key-prefix-docs
Draft

Document i18n cache key prefix and configurable cache config (5.next)#8289
dereuromark wants to merge 1 commit into5.nextfrom
feature/i18n-cache-key-prefix-docs

Conversation

@dereuromark
Copy link
Copy Markdown
Member

Documents the new i18n APIs landing in cakephp/cakephp#19412:

  • TranslatorRegistry::setCacheKeyPrefix() — adds a prefix segment to both
    the persistent cache key and the in-memory lookup bucket. Accepts a static
    string or a Closure(string $name, string $locale): string for pulling
    the current tenant from user-land.
  • TranslatorRegistry::clearInMemoryRegistry() — drops the in-memory
    translator map without touching the persistent cacher. For long-running
    workers that switch tenants between jobs.
  • I18n::setCacheConfig() — replaces the hardcoded _cake_translations_
    Cache config with whichever config the app prefers. Throws if called
    after the registry has been built.

Adds an "Isolating Translations Per Tenant" subsection to the i18n core
library page covering the bootstrap snippet, per-package skip logic via
the Closure arguments, the queue-worker reset pattern, and the
setCacheConfig() ordering requirement. Also notes that
setCacheKeyPrefix() is unrelated to the gettext message context used by
__x().

Adds three bullets to the 5.4 migration guide under I18n new features.

Depends on cakephp/cakephp#19412.

Documents the new `TranslatorRegistry::setCacheKeyPrefix()`,
`clearInMemoryRegistry()` and `I18n::setCacheConfig()` APIs added in
5.4.0, with the multi-tenant translation cache isolation use case as
the worked example. Also adds entries to the 5.4 migration guide.
@dereuromark dereuromark added this to the 5.next milestone Apr 25, 2026
@dereuromark dereuromark marked this pull request as draft April 25, 2026 18:35
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.

1 participant