Skip to content

Commit

Permalink
docs: add fetch translation example using async function
Browse files Browse the repository at this point in the history
  • Loading branch information
orestbida committed Feb 17, 2024
1 parent 3efd0db commit 7716d62
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/advanced/language-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ The cleanest solution is to separate the translations from the plugin's configur
});
```

You can also use asynchronous functions to fetch the translation:
```javascript
CookieConsent.run({
language: {
default: 'en',
translations: {
en: async () => {
const res = await fetch('path-to-json');
return await res.json();
}
}
}
});
```

You can set up multiple languages by following the same steps!

## Inline translations
Expand Down

0 comments on commit 7716d62

Please sign in to comment.