svelte-3-intl
Sizes (svelte-3-intl and format-message):
Internationalize your Svelte 3 apps using format-message.
Installation
npm i svelte-3-intl format-message # format message is a peer dependency
Usage
{$_('hello', { name })}
API
translate
(or "_
")
Translation store
- Type:
svelte.Readable<typeof formatMessage>
Example
Title: {title} Reactive Title: {$translate('title')}
translations
Available translations
- Type: Object
set(translations) => void
: Replace translations (avoid this)update(translations) => void
: Add more translationssubscribe
: Store subscription, avoid using this directly
locale
Current locale
- Type: like
svelte.Readable<string>
, but with safe update and set (logs error if locale is not found) - Note: Set and update return a
boolean
indicating if the locale was found
locales
Available locales, derived from translation
- Type:
svelte.Readable<string[]>
Usage
<!-- LanguageSelector.svelte --> {#each $locales as l} {l} {/each}
options
See format-message options
Just calloptions.set({ })
:)
- Type:
svelte.Readable<formatMessage.SetupOptions>
(but update merges with current config)
getBrowserLocale
Tries to match the
window.navigator.language
to the available dictionaries
- Params:
- defaultLocale {string}: If no match is found, returns this