Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eduardoacskimlinks/11c10c82ba2df0234a90af806ee0f09f to your computer and use it in GitHub Desktop.
Save eduardoacskimlinks/11c10c82ba2df0234a90af806ee0f09f to your computer and use it in GitHub Desktop.
i18next setup for service worker to fetch translations
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