i18n-translations
v1.0.1
Published
Translation module. Gathers data from cotentful and manage a cache to return different texts, filtering by language.
Downloads
7
Readme
i18n Translations
The aim of this repository is to create a library to get different texts by different languages that are store in Contentful.
Task
npm run build
: Generates the library build.npm run benckmark
: Runs a performance benchmark for different module functions.npm run test
: Runs unit tests.
Usage
Include the module
const {
getTranslation,
initTranslations } = require('i18-translation')
Initialize the module (returns a promise)
initTranslations({
space,
accessToken,
invalidationUrl,
languages
})
in which the parameters have the following meaning:
- space: String. Space id from Contentful.
- accesToken: String. Contentful access token.
- invalidationUrl: String. Url for the invalidation server
- languages: Array with the languages name. E.g.:
['es', 'en', 'fr']
.
Get a translation
getTranslation(lang, key);
where the parameters means:
- lang: String. Language key, e.g.: 'en'
- key: String. Translation key present in marketo