You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add docs for i18n cache key prefix and configurable cache config
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.
* Update docs for renamed `TranslatorRegistry::clear()` method
Reflects the rename from `clearInMemoryRegistry()` after review feedback.
* Update docs/en/core-libraries/internationalization-and-localization.md
Co-authored-by: Mark Story <mark@mark-story.com>
---------
Co-authored-by: Mark Story <mark@mark-story.com>
Copy file name to clipboardExpand all lines: docs/en/core-libraries/internationalization-and-localization.md
+88Lines changed: 88 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -562,6 +562,94 @@ I18n::config('_fallback', function ($domain, $locale) {
562
562
});
563
563
```
564
564
565
+
### Isolating Translations Per Tenant
566
+
567
+
::: info Added in version 5.4.0
568
+
The cache key prefix and configurable cache config APIs were added in 5.4.0.
569
+
:::
570
+
571
+
If your application needs to serve tenant specific translated content for a given domain & locale, you need to use a cache key prefix to scope both translator cache data to the tenant.
572
+
573
+
#### Cache Key Prefix
574
+
575
+
`TranslatorRegistry::setCacheKeyPrefix()` adds a segment to both the persistent
576
+
cache key and the in-memory lookup bucket. It accepts either a static string or
577
+
a `Closure` that returns one. When given a `Closure`, it is evaluated on every
578
+
`get()` call, so the current tenant identifier is pulled *from* user-land
0 commit comments