DEV Community

Discussion on: Using i18Next with Svelte

sbelzile profile image
Sébastien Belzile Author

(1) Where should getContext be defined?

getContext is provided by Svelte.
Link to documentation:
So, import { getContext } from 'svelte';

(2) Does it fit?

index.svelte is fine, though I don't think it should go inside a <svelte:head> tag.

I would place that in the Svelte script section of your file, not in the markup. (add the script tag directly to the root)

    import { initLocalizationContext } from "../i18n/index.ts";

Enter fullscreen mode Exit fullscreen mode

(3) Is the complete program as described in the post available somewhere to try?

Unfortunately it is not, all the snippets are adapted copies of a non-public codebase I worked on.

I encourage you to go through the tutorial on the Svelte site: . It does not take long to complete and shows very well most of Svelte features. I feel like this page and this page could have provided answers your questions.