Tests | Coverage | Security |
---|---|---|
Minimal translation cache module. It provides following functions:
- Initializes with target language (to use separate stores for each language)
- Allows fetching existing translation (or should return null)
- Allows saving new translations for future use
For usage example see test.js
.
The class is not optimized much.
To prevent re-reads, the class stores all translations in memory (per initialized instance, each with different language). This can result in a huge memory load, when pre-stored translations. Pre-stored translations can be pushed (on a new branch and PR, please) and will be therefore reviewed on each pull-request.
- Fetch translation (returns null)
- Translate using DeepL or anything else (if no translation available)
- Store and return fetched translation
- Fetch translation (reloads store and returns value for key from memory)
- Optimize: check translation in memory first; if not available: reload store and retry... return null on failure