typed-locales 1.0.59 → 1.0.60

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 +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,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,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,iBAAiB,GAAG,gBAAgB,EAAE,CAAC;AA2B5C,eAAO,MAAM,SAAS,GACrB,qBAAqB,MAAM,EAC3B,iBAAiB,MAAM,CACtB,OAAO,EACP,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAClC,EACD,iBAAiB,eAAe,EAChC,eAAe,OAAO,EACtB,oBAAoB,iBAAiB,oBAEM;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CA6DxE,CAAC;AAEF,eAAO,MAAM,cAAc,8BAM1B,CAAC"}
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,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,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,iBAAiB,GAAG,gBAAgB,EAAE,CAAC;AA2B5C,eAAO,MAAM,SAAS,GACrB,qBAAqB,MAAM,EAC3B,iBAAiB,MAAM,CACtB,OAAO,EACP,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAClC,EACD,iBAAiB,eAAe,EAChC,eAAe,OAAO,EACtB,oBAAoB,iBAAiB,oBAEM;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CAiExE,CAAC;AAEF,eAAO,MAAM,cAAc,8BAM1B,CAAC"}
@@ -30,6 +30,9 @@ export const initReact = (defaultTranslations, allTranslations, extraFormatters,
30
30
  translate: defaultTranslate,
31
31
  });
32
32
  const setLocale = useCallback(async (targetLocale) => {
33
+ if (state.locale === targetLocale) {
34
+ return targetLocale;
35
+ }
33
36
  try {
34
37
  const translationOrLoader = allTranslations[targetLocale];
35
38
  const translationData = await translationOrLoader().then(t => t.default);
package/dist/index.d.ts CHANGED
@@ -83,9 +83,9 @@ export { initZustand } from './adapters/zustand.js';
83
83
  export { type Formatter, default as defaultFormatters } from './formatters.js';
84
84
  export { type ValidateTranslation, type EnsureValidTranslation, } from './validation.js';
85
85
  /**
86
- * @description Convert import.meta.glob to a record of locales and their translation functions
86
+ * @description Convert import.meta.glob to a record of locales and the function to import the translations
87
87
  * @param files - The files to convert
88
- * @returns A record of locales and their translation functions
88
+ * @returns A record of locales and the function to import the translations
89
89
  * @example
90
90
  * ```ts
91
91
  * const translations = translationsFromImportMeta(import.meta.glob('../translations/*.ts'));
package/dist/index.js CHANGED
@@ -86,9 +86,9 @@ export { initReact, useTranslation } from './adapters/react.js';
86
86
  export { initZustand } from './adapters/zustand.js';
87
87
  export { default as defaultFormatters } from './formatters.js';
88
88
  /**
89
- * @description Convert import.meta.glob to a record of locales and their translation functions
89
+ * @description Convert import.meta.glob to a record of locales and the function to import the translations
90
90
  * @param files - The files to convert
91
- * @returns A record of locales and their translation functions
91
+ * @returns A record of locales and the function to import the translations
92
92
  * @example
93
93
  * ```ts
94
94
  * const translations = translationsFromImportMeta(import.meta.glob('../translations/*.ts'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-locales",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "Type safe utilities for translating strings",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",