@sveltebase/i18n 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +10 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -224,9 +224,9 @@ function getI18nFromContext() {
224
224
  return get();
225
225
  }
226
226
  function getTranslations() {
227
+ const i18n = getI18nFromContext();
228
+ const { languages, fallbackLocale } = getI18nInternal(i18n);
227
229
  return ((key, values) => {
228
- const i18n = getI18nFromContext();
229
- const { languages, fallbackLocale } = getI18nInternal(i18n);
230
230
  const translate = createLocaleTranslator(
231
231
  languages,
232
232
  i18n.locale,
@@ -236,9 +236,9 @@ function getTranslations() {
236
236
  });
237
237
  }
238
238
  function getFormat() {
239
+ const i18n = getI18nFromContext();
240
+ const { languages, fallbackLocale } = getI18nInternal(i18n);
239
241
  return (value, options) => {
240
- const i18n = getI18nFromContext();
241
- const { languages, fallbackLocale } = getI18nInternal(i18n);
242
242
  const format = createFormatForLocale(
243
243
  languages,
244
244
  i18n.locale,
@@ -289,16 +289,15 @@ function createI18n(languages, localeStorageKey = DEFAULT_LOCALE_STORAGE_KEY) {
289
289
  );
290
290
  },
291
291
  init(cookies) {
292
- if (initialized) {
293
- return;
294
- }
295
- const resolvedCookies = typeof cookies === "function" ? cookies() : cookies;
296
- if (resolvedCookies) {
297
- localeState.init(resolvedCookies);
292
+ if (!initialized) {
293
+ const resolvedCookies = typeof cookies === "function" ? cookies() : cookies;
294
+ if (resolvedCookies) {
295
+ localeState.init(resolvedCookies);
296
+ }
297
+ initialized = true;
298
298
  }
299
299
  const { set } = ensureContext();
300
300
  set(i18n);
301
- initialized = true;
302
301
  }
303
302
  };
304
303
  i18nInternals.set(i18n, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltebase/i18n",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@sveltebase/state": "0.4.0",
21
+ "@sveltebase/state": "0.4.2",
22
22
  "use-intl": "^4.4.0"
23
23
  },
24
24
  "peerDependencies": {