maxLocalesInMemory

Sets the maximum number of locales to keep in memory cache.

Uses LRU (Least Recently Used) eviction when the limit is reached. Each cached locale consumes memory proportional to its translation file size.

Use Cases:

  • Multi-language apps with frequent locale switching

  • Apps where users switch between 2-3 preferred languages

Default: 1 (caches only one locale)

Return

The Builder instance, enabling method chaining.

Parameters

max

Maximum number of locales to cache. Use null for unlimited caching, or a positive integer (>= 1) for limited caching with LRU eviction.

Throws

if max < 1 (when not null)

Samples


Maximum number of locales to keep in memory cache.

Uses LRU (Least Recently Used) eviction when the limit is reached.

  • null: unlimited cache (no eviction)

  • 1: default (caches only one locale, same as current behavior)

  • 2+: caches multiple locales with LRU eviction

Each cached locale consumes memory proportional to its translation file size.