typed-locales 1.0.66 → 1.0.67

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.
@@ -5,6 +5,8 @@ export interface TranslationContextType {
5
5
  locale?: Locales;
6
6
  setLocale: (locale: Locales) => Promise<Locales>;
7
7
  t: ReturnType<typeof getTranslate>;
8
+ setShowKeys: (showKeys: boolean) => void;
9
+ showKeys: boolean;
8
10
  }
9
11
  type ExtraTranslation = {
10
12
  [locale in Locales]?: string;
@@ -14,7 +16,7 @@ type ExtraTranslation = {
14
16
  type ExtraTranslations = ExtraTranslation[];
15
17
  export declare const initReact: (defaultTranslations: object, allTranslations: Record<Locales, () => Promise<{
16
18
  default: object;
17
- }>>, extraFormatters: ExtraFormatters, defaultLocale: Locales, extraTranslations?: ExtraTranslations, showKeys?: boolean) => ({ children }: {
19
+ }>>, extraFormatters: ExtraFormatters, defaultLocale: Locales, extraTranslations?: ExtraTranslations) => ({ children }: {
18
20
  children: React.ReactNode;
19
21
  }) => import("react/jsx-runtime").JSX.Element;
20
22
  export declare const useTranslation: () => TranslationContextType;
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/adapters/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAEf,OAAO,EACN,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,OAAO,EAEZ,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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,MAAM,CAAA;CAAE,CAAC,CAAC,EACpE,iBAAiB,eAAe,EAChC,eAAe,OAAO,EACtB,oBAAoB,iBAAiB,oBAEM;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CAoFxE,CAAC;AAEF,eAAO,MAAM,cAAc,8BAM1B,CAAC"}
@@ -21,9 +21,10 @@ const addExtraTranslations = (translation, extraTranslations, locale) => {
21
21
  return translation;
22
22
  };
23
23
  // Initial translation always should be loaded
24
- export const initReact = (defaultTranslations, allTranslations, extraFormatters, defaultLocale, extraTranslations, showKeys) => {
24
+ export const initReact = (defaultTranslations, allTranslations, extraFormatters, defaultLocale, extraTranslations) => {
25
25
  const TranslationProvider = ({ children }) => {
26
26
  const defaultTranslate = useMemo(() => getTranslate(addExtraTranslations(defaultTranslations, extraTranslations ?? [], defaultLocale), defaultLocale, extraFormatters), []);
27
+ const [showKeys, setShowKeys] = useState(false);
27
28
  const [state, setState] = useState({
28
29
  isLoading: false,
29
30
  locale: defaultLocale,
@@ -56,6 +57,8 @@ export const initReact = (defaultTranslations, allTranslations, extraFormatters,
56
57
  locale: state.locale,
57
58
  setLocale,
58
59
  t: showKeys ? ((key) => key) : state.translate,
60
+ setShowKeys,
61
+ showKeys,
59
62
  }, children: children }));
60
63
  };
61
64
  return TranslationProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-locales",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "description": "Type safe utilities for translating strings",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",