From 7716d62d175ab1ea818158f3222a245ffdf2987e Mon Sep 17 00:00:00 2001 From: Orest Bida Date: Sat, 17 Feb 2024 23:33:51 +0100 Subject: [PATCH] docs: add fetch translation example using async function --- docs/advanced/language-configuration.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/advanced/language-configuration.md b/docs/advanced/language-configuration.md index 0b615061..976dbcfb 100644 --- a/docs/advanced/language-configuration.md +++ b/docs/advanced/language-configuration.md @@ -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