Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
Button.svelte
Content.svelte
Trans.svelte
<script>
import { I18nProvider } from "val-i18n-svelte";
import { I18n, detectLang } from "val-i18n";
import Content from "./Content.svelte";
const fakeLocaleFetcher = async lang => {
const locales = {
en: {
hello: "Hello, World!",
title: "This is a title",
language: {
"en": "English",
"zh": "Chinese"
},
publish: "{{name}} published {{project}} yesterday."
},
["zh-CN"]: {
hello: "你好,世界!",
title: "这是一个标题",
language: {
"en": "英文",
"zh": "中文"
},
publish: "昨天 {{name}} 发布了 {{project}}。"
}
};
return locales[lang] || locales.en;
};
const i18nLoader = I18n.preload(detectLang(["en", "zh-CN"]) || "en", fakeLocaleFetcher);
</script>

<I18nProvider i18n={i18nLoader} let:t>
<h1>{t("hello")}</h1>
<Content />
</I18nProvider>
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */