Skip to main content

Cached Translations

If the translations are not available locally or if they are possibly always updated on an external server, it may make sense to cache the results. To handle this use case, Text Localizer provides the possibility of specifying the following parameters in the setOptions function:

  • the storage;
  • the storageKey;
  • cacheDurationMs.
  await localizer.setOptions({    language: 'gb',    storage: myStorage,    storageKey: '@MY_STORAGE_KEY'    cacheDurationMs: ONE_DAY_MS,  });