typed-locales 1.0.57 → 1.0.58

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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { getTranslate, type ExtraFormatters, type Locales, type TranslationType } from '../index.js';
2
+ import { getTranslate, type ExtraFormatters, type Locales } from '../index.js';
3
3
  export interface TranslationContextType {
4
4
  isLoading: boolean;
5
5
  locale?: Locales;
@@ -12,8 +12,8 @@ type ExtraTranslation = {
12
12
  key: string;
13
13
  };
14
14
  type ExtraTranslations = ExtraTranslation[];
15
- export declare const initReact: (defaultTranslations: TranslationType, allTranslations: Record<Locales, () => Promise<{
16
- default: TranslationType;
15
+ export declare const initReact: (defaultTranslations: object, allTranslations: Record<Locales, () => Promise<{
16
+ default: object;
17
17
  }>>, extraFormatters: ExtraFormatters, defaultLocale: Locales, extraTranslations?: ExtraTranslations) => ({ children }: {
18
18
  children: React.ReactNode;
19
19
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/adapters/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAEf,OAAO,EACN,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,sBAAsB;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;CACnC;AAMD,KAAK,gBAAgB,GAAG;KACtB,MAAM,IAAI,OAAO,CAAC,CAAC,EAAE,MAAM;CAC5B,GAAG;IACH,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,i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E,CAAC;AAEF,eAAO,MAAM,cAAc,8BAM1B,CAAC"}
@@ -32,14 +32,7 @@ export const initReact = (defaultTranslations, allTranslations, extraFormatters,
32
32
  const setLocale = useCallback(async (targetLocale) => {
33
33
  try {
34
34
  const translationOrLoader = allTranslations[targetLocale];
35
- let translationData;
36
- if (typeof translationOrLoader === 'function') {
37
- setState(previous => ({ ...previous, isLoading: true }));
38
- translationData = await translationOrLoader().then(t => t.default);
39
- }
40
- else {
41
- translationData = translationOrLoader;
42
- }
35
+ const translationData = await translationOrLoader().then(t => t.default);
43
36
  setState({
44
37
  isLoading: false,
45
38
  locale: targetLocale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-locales",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "description": "Type safe utilities for translating strings",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",