1.0.3 • Published 1 year ago
trans-cache v1.0.3
TransCache
Tests | Coverage | Security |
---|---|---|
Purpose
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
Usage
For usage example see index.js
.
Internal details
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.
Expected use
Making a new translation:
- Fetch translation (returns null)
- Translate using DeepL or anything else (if no translation available)
- Store and return fetched translation
Fething existing translation:
- Fetch translation (reloads store and returns value for key from memory)
TODOs
- Optimize: check translation in memory first; if not available: reload store and retry... return null on failure