Created
June 9, 2022 10:43
-
-
Save eduardoacskimlinks/11c10c82ba2df0234a90af806ee0f09f to your computer and use it in GitHub Desktop.
i18next setup for service worker to fetch translations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import i18next from "i18next" | |
import Fetch from "i18next-fetch-backend" | |
i18next.use(Fetch).init({ | |
debug: true, | |
fallbackLng: "en", | |
preload: ["en"], | |
keySeparator: false, // Allow usage of dots in keys | |
backend: { | |
loadPath: "https://{API_PATH}/translations/{{lng}}.json", | |
parse: (data) => JSON.parse(data), | |
}, | |
}) | |
export default i18next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment