typed-locales 1.0.14 → 1.0.16

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-utilities.d.ts","sourceRoot":"","sources":["../src/react-utilities.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAqB,MAAM,SAAS,CAAC;AAEtH,MAAM,WAAW,sBAAsB;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;CACnC;AAGD,eAAO,MAAM,SAAS,GACrB,iBAAiB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,CAAC,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EACxF,eAAe,OAAO,EACtB,iBAAiB,eAAe;wCAGW;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;CAgExE,CAAC"}
1
+ {"version":3,"file":"react-utilities.d.ts","sourceRoot":"","sources":["../src/react-utilities.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAqB,MAAM,SAAS,CAAC;AAEtH,MAAM,WAAW,sBAAsB;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;CACnC;AAGD,eAAO,MAAM,SAAS,GACrB,iBAAiB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,CAAC,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EACxF,eAAe,OAAO,EACtB,iBAAiB,eAAe;wCAGW;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;CAwExE,CAAC"}
@@ -11,15 +11,20 @@ export const initReact = (allTranslations, initialLocale, extraFormatters) => {
11
11
  return getTranslate(allTranslations[locale], locale, extraFormatters);
12
12
  });
13
13
  const [isLoading, setIsLoading] = useState(true);
14
+ console.log('translate', translate);
15
+ console.log('locale', locale);
16
+ console.log('isLoading', isLoading);
14
17
  const loadTranslation = async (targetLocale) => {
15
18
  try {
16
19
  const translationOrLoader = allTranslations[targetLocale];
17
20
  let translationData;
18
21
  if (typeof translationOrLoader === 'function') {
22
+ console.log('loading translation', targetLocale);
19
23
  setIsLoading(true);
20
24
  translationData = await translationOrLoader();
21
25
  }
22
26
  else {
27
+ console.log('sync translation', targetLocale);
23
28
  translationData = translationOrLoader;
24
29
  }
25
30
  console.log('setting translation to', translationData);
@@ -42,7 +47,11 @@ export const initReact = (allTranslations, initialLocale, extraFormatters) => {
42
47
  await loadTranslation(newLocale);
43
48
  }
44
49
  },
45
- t: translate,
50
+ // @ts-ignore
51
+ t: (...args) => {
52
+ console.trace('Performing translation', args);
53
+ return translate(...args);
54
+ },
46
55
  }, children: children }));
47
56
  };
48
57
  const useTranslation = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-locales",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Type safe utilities for translating strings",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "build": "npm-run-all -s -c build:*",
10
10
  "build:tsc": "rimraf dist && tsc",
11
- "build:tsc-alias": "tsc-alias -p tsconfig.json --debug",
11
+ "build:tsc-alias": "tsc-alias -p tsconfig.json",
12
12
  "dev": "tsx watch src/test.tsx",
13
13
  "deploy": "npm run build && npm publish --access public"
14
14
  },