svelte-intl
Advanced tools
Comparing version
@@ -1670,4 +1670,4 @@ (function (global, factory) { | ||
function intl(store, ref) { | ||
if ( ref === void 0 ) ref = { locales: {} }; | ||
var locales = ref.locales; | ||
if ( ref === void 0 ) ref = { translations: {} }; | ||
var translations = ref.translations; | ||
var locale = ref.locale; | ||
@@ -1681,3 +1681,3 @@ | ||
) { | ||
var message = getPath(locales[currentLocale], path); | ||
var message = getPath(translations[currentLocale], path); | ||
if (!message) { return path; } | ||
@@ -1689,3 +1689,3 @@ | ||
store.on('locale', function (newLocale) { | ||
if (!(newLocale in locales)) { | ||
if (!(newLocale in translations)) { | ||
console.error(("[svelte-intl] Couldn't find the \"" + newLocale + "\" locale.")); | ||
@@ -1697,3 +1697,3 @@ return; | ||
locale: newLocale, | ||
translations: locales, | ||
translations: translations, | ||
missingTranslation: 'ignore' | ||
@@ -1713,4 +1713,4 @@ }); | ||
}, | ||
extendLocales: function extendLocales(newLocales) { | ||
locales = merge(locales, newLocales); | ||
extendTranslations: function extendTranslations(newTranslations) { | ||
translations = merge(translations, newTranslations); | ||
} | ||
@@ -1717,0 +1717,0 @@ }; |
@@ -19,4 +19,4 @@ import formatMessage from 'format-message'; | ||
export function intl(store, { | ||
locales, locale | ||
} = { locales: {} }) { | ||
translations, locale | ||
} = { translations: {} }) { | ||
let currentLocale; | ||
@@ -28,3 +28,3 @@ | ||
) => { | ||
const message = getPath(locales[currentLocale], path); | ||
const message = getPath(translations[currentLocale], path); | ||
if (!message) return path; | ||
@@ -36,3 +36,3 @@ | ||
store.on('locale', newLocale => { | ||
if (!(newLocale in locales)) { | ||
if (!(newLocale in translations)) { | ||
console.error(`[svelte-intl] Couldn't find the "${newLocale}" locale.`); | ||
@@ -44,3 +44,3 @@ return; | ||
locale: newLocale, | ||
translations: locales, | ||
translations, | ||
missingTranslation: 'ignore' | ||
@@ -60,4 +60,4 @@ }); | ||
}, | ||
extendLocales(newLocales) { | ||
locales = merge(locales, newLocales); | ||
extendTranslations(newTranslations) { | ||
translations = merge(translations, newTranslations); | ||
} | ||
@@ -64,0 +64,0 @@ }; |
{ | ||
"name": "svelte-intl", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"description": "Internationalize your Svelte apps", | ||
@@ -5,0 +5,0 @@ "main": "dist/svelte-intl.js", |
@@ -15,3 +15,3 @@ ## svelte-intl | ||
locale: 'en', | ||
locales: { | ||
translations: { | ||
en: { | ||
@@ -23,3 +23,3 @@ hello: 'Hello, {name}' | ||
store.intl.extendLocales({ | ||
store.intl.extendTranslations({ | ||
ru: { | ||
@@ -26,0 +26,0 @@ hello: 'Привет, {name}' |
62194
0.17%