This is a first stab at building a reusable module for internationalization, localization and translation of Svelte and Sapper apps.
yarn add --dev svelte-lingui @lingui/core@next # or npm i --save-dev svelte-lingui @lingui/core@next
Wrap your app in a provider:
<Provider config={{ ...LinguiConfig }}>
<App />
</Provider>
Use Text
component for messages:
<Text message={'Hello {name}'} props={{ name }} />
Or use context to access the i18n
object from Lingui directly:
const i18n = getContext("i18n"); // returns a store
$i18n._(message, props)
Checkout the code inside /dev
for a full example.
There is a dev app available inside the /dev
folder that can be used for
testing and experimenting with the components. To start it simply run:
yarn dev # or npm run dev