gt-react-native 0.0.1-alpha.8 → 0.0.1
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.
- package/README.md +34 -11
- package/lib/module/errors-dir/constants.js +1 -1
- package/lib/module/errors-dir/constants.js.map +1 -1
- package/lib/module/errors-dir/errors.js +5 -0
- package/lib/module/errors-dir/errors.js.map +1 -0
- package/lib/module/errors-dir/warnings.js +12 -0
- package/lib/module/errors-dir/warnings.js.map +1 -0
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +4 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/plugin-dir/index.js +49 -0
- package/lib/module/plugin-dir/index.js.map +1 -0
- package/lib/module/plugin-dir/types.js +2 -0
- package/lib/module/plugin-dir/types.js.map +1 -0
- package/lib/module/plugin-dir/utils/resolveLocales.js +69 -0
- package/lib/module/plugin-dir/utils/resolveLocales.js.map +1 -0
- package/lib/module/plugin.js +4 -0
- package/lib/module/plugin.js.map +1 -0
- package/lib/module/tools/testLocalePolyfill.js +64 -0
- package/lib/module/tools/testLocalePolyfill.js.map +1 -0
- package/lib/typescript/src/errors-dir/constants.d.ts +1 -1
- package/lib/typescript/src/errors-dir/constants.d.ts.map +1 -1
- package/lib/typescript/src/errors-dir/errors.d.ts +2 -0
- package/lib/typescript/src/errors-dir/errors.d.ts.map +1 -0
- package/lib/typescript/src/errors-dir/warnings.d.ts +4 -0
- package/lib/typescript/src/errors-dir/warnings.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal.d.ts +2 -0
- package/lib/typescript/src/internal.d.ts.map +1 -0
- package/lib/typescript/src/plugin-dir/index.d.ts +6 -0
- package/lib/typescript/src/plugin-dir/index.d.ts.map +1 -0
- package/lib/typescript/src/plugin-dir/types.d.ts +10 -0
- package/lib/typescript/src/plugin-dir/types.d.ts.map +1 -0
- package/lib/typescript/src/plugin-dir/utils/resolveLocales.d.ts +13 -0
- package/lib/typescript/src/plugin-dir/utils/resolveLocales.d.ts.map +1 -0
- package/lib/typescript/src/plugin.d.ts +2 -0
- package/lib/typescript/src/plugin.d.ts.map +1 -0
- package/lib/typescript/src/tools/testLocalePolyfill.d.ts +12 -0
- package/lib/typescript/src/tools/testLocalePolyfill.d.ts.map +1 -0
- package/lib/typescript/vitest.config.d.ts +3 -0
- package/lib/typescript/vitest.config.d.ts.map +1 -0
- package/package.json +20 -13
- package/src/errors-dir/constants.ts +1 -1
- package/src/errors-dir/errors.ts +3 -0
- package/src/errors-dir/warnings.ts +14 -0
- package/src/index.tsx +0 -1
- package/src/internal.ts +1 -0
- package/src/plugin-dir/index.ts +80 -0
- package/src/plugin-dir/types.ts +10 -0
- package/src/plugin-dir/utils/resolveLocales.ts +95 -0
- package/src/plugin.ts +1 -0
- package/src/tools/testLocalePolyfill.ts +82 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeGtReactNativeSpec.java +0 -51
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -28
- package/android/app/build/generated/source/codegen/jni/GtReactNativeSpec-generated.cpp +0 -50
- package/android/app/build/generated/source/codegen/jni/GtReactNativeSpec.h +0 -31
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/GtReactNativeSpec/GtReactNativeSpecJSI-generated.cpp +0 -51
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/GtReactNativeSpec/GtReactNativeSpecJSI.h +0 -98
- package/lib/module/utils/polyfill.js +0 -33
- package/lib/module/utils/polyfill.js.map +0 -1
- package/lib/typescript/src/utils/polyfill.d.ts +0 -28
- package/lib/typescript/src/utils/polyfill.d.ts.map +0 -1
- package/src/utils/polyfill.ts +0 -36
package/README.md
CHANGED
|
@@ -8,21 +8,44 @@ An i18n package for React Native
|
|
|
8
8
|
npm install gt-react-native
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
## Local development
|
|
12
|
+
|
|
13
|
+
In order to link local librarys add this to your package.json:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"example-lib": "*"
|
|
19
|
+
},
|
|
20
|
+
"resolutions": {
|
|
21
|
+
"@generaltranslation/react-core": "portal:/absolute/path/to/test-lib"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
And update the `metro.config.js` in the `/example` directory for local linking:
|
|
17
27
|
|
|
18
|
-
|
|
28
|
+
```js
|
|
29
|
+
const testLibAbsolutePath = '/absolute/path/to/test-lib';
|
|
30
|
+
|
|
31
|
+
const mergedConfig = {
|
|
32
|
+
...defaultConfig,
|
|
33
|
+
resolver: {
|
|
34
|
+
...defaultConfig.resolver,
|
|
35
|
+
extraNodeModules: {
|
|
36
|
+
...defaultConfig.resolver.extraNodeModules,
|
|
37
|
+
'test-lib': testLibAbsolutePath,
|
|
38
|
+
},
|
|
39
|
+
nodeModulesPaths: [
|
|
40
|
+
...defaultConfig.resolver.nodeModulesPaths,
|
|
41
|
+
`${testLibAbsolutePath}/node_modules`,
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
watchFolders: [...defaultConfig.watchFolders, testLibAbsolutePath],
|
|
45
|
+
};
|
|
19
46
|
```
|
|
20
47
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- [Development workflow](CONTRIBUTING.md#development-workflow)
|
|
24
|
-
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
25
|
-
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
48
|
+
If you are having issues resolving a dependency in test-lib, then provide the direct path in `extraNodeModules` mapping to `'/absolute/path/to/test-lib/node_modules/example-lib'`.
|
|
26
49
|
|
|
27
50
|
---
|
|
28
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PACKAGE_NAME"],"sourceRoot":"../../../src","sources":["errors-dir/constants.ts"],"mappings":";;AAAA,OAAO,MAAMA,YAAY,GAAG,
|
|
1
|
+
{"version":3,"names":["PACKAGE_NAME"],"sourceRoot":"../../../src","sources":["errors-dir/constants.ts"],"mappings":";;AAAA,OAAO,MAAMA,YAAY,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PACKAGE_NAME","failedToReadConfigFileError","filePath"],"sourceRoot":"../../../src","sources":["errors-dir/errors.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,gBAAa;AAC1C,OAAO,MAAMC,2BAA2B,GAAIC,QAAgB,IAC1D,GAAGF,YAAY,uCAAuCE,QAAQ,GAAG","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { libraryDefaultLocale } from 'generaltranslation/internal';
|
|
4
|
+
import { PACKAGE_NAME } from "./constants.js";
|
|
5
|
+
export const resolveLocalesFailedWarning = `${PACKAGE_NAME}: Failed to resolve locales for polyfill. Falling back to ${libraryDefaultLocale}.
|
|
6
|
+
Specify a list of locales for the gt-react-native babel plugin by:
|
|
7
|
+
(1) Providing a list of locales
|
|
8
|
+
(2) Providing your GT Config to the plugin
|
|
9
|
+
(3) Providing the path to your GT Config file.`;
|
|
10
|
+
export const couldNotLocateConfigWarning = filePath => `${PACKAGE_NAME}: Could not locate GT Config at ${filePath}.`;
|
|
11
|
+
export const invalidLocalesWarning = invalidLocales => `${PACKAGE_NAME}: Invalid locales found in GT Config: ${invalidLocales.join(', ')}.`;
|
|
12
|
+
//# sourceMappingURL=warnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["libraryDefaultLocale","PACKAGE_NAME","resolveLocalesFailedWarning","couldNotLocateConfigWarning","filePath","invalidLocalesWarning","invalidLocales","join"],"sourceRoot":"../../../src","sources":["errors-dir/warnings.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,6BAA6B;AAClE,SAASC,YAAY,QAAQ,gBAAa;AAE1C,OAAO,MAAMC,2BAA2B,GAAG,GAAGD,YAAY,6DAA6DD,oBAAoB;AAC3I;AACA;AACA;AACA,+CAA+C;AAE/C,OAAO,MAAMG,2BAA2B,GAAIC,QAAgB,IAC1D,GAAGH,YAAY,mCAAmCG,QAAQ,GAAG;AAE/D,OAAO,MAAMC,qBAAqB,GAAIC,cAAwB,IAC5D,GAAGL,YAAY,yCAAyCK,cAAc,CAACC,IAAI,CAAC,IAAI,CAAC,GAAG","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GtReactNative","GTProvider","multiply","a","b","T","useGT","useTranslations","useDefaultLocale","useLocale","useRegion","Var","Num","Currency","DateTime","Plural","Branch","useLocales","useLocaleSelector","useSetLocale","useGTClass","useLocaleProperties","useRegionSelector","useLocaleDirection","useMessages","msg","decodeMsg","decodeOptions"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"names":["GtReactNative","GTProvider","multiply","a","b","T","useGT","useTranslations","useDefaultLocale","useLocale","useRegion","Var","Num","Currency","DateTime","Plural","Branch","useLocales","useLocaleSelector","useSetLocale","useGTClass","useLocaleProperties","useRegionSelector","useLocaleDirection","useMessages","msg","decodeMsg","decodeOptions"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,aAAa,MAAM,0BAAuB;AAEjD,SAASC,UAAU,QAAQ,0BAAuB;AAClD,OAAO,SAASC,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAU;EACrD,OAAOJ,aAAa,CAACE,QAAQ,CAACC,CAAC,EAAEC,CAAC,CAAC;AACrC;AAEA,SACEC,CAAC,EACDC,KAAK,EACLC,eAAe,EACfC,gBAAgB,EAChBC,SAAS,EACTC,SAAS,EACTC,GAAG,EACHC,GAAG,EACHC,QAAQ,EACRC,QAAQ,EACRC,MAAM,EACNC,MAAM,EACNC,UAAU,EACVC,iBAAiB,EACjBC,YAAY,EACZC,UAAU,EACVC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,GAAG,EACHC,SAAS,EACTC,aAAa,QACR,gCAAgC;AAOvC,SACEhB,GAAG,EACHC,GAAG,EACHC,QAAQ,EACRC,QAAQ,EACRT,CAAC,EACDJ,UAAU,EACVc,MAAM,EACNC,MAAM,EACNV,KAAK,EACLC,eAAe,EACfC,gBAAgB,EAChBC,SAAS,EACTQ,UAAU,EACVE,YAAY,EACZD,iBAAiB,EACjBR,SAAS,EACTY,iBAAiB,EACjBF,UAAU,EACVC,mBAAmB,EACnBE,kBAAkB,EAIlBE,GAAG,EACHC,SAAS,EACTC,aAAa,EACbH,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["testLocalePolyfill"],"sourceRoot":"../../src","sources":["internal.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,+BAA4B","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { resolveLocales } from "./utils/resolveLocales.js";
|
|
5
|
+
export default function (babel, {
|
|
6
|
+
locales,
|
|
7
|
+
config,
|
|
8
|
+
configFilePath,
|
|
9
|
+
entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx')
|
|
10
|
+
}) {
|
|
11
|
+
const {
|
|
12
|
+
types: t
|
|
13
|
+
} = babel;
|
|
14
|
+
return {
|
|
15
|
+
name: 'gt-react-native/plugin',
|
|
16
|
+
visitor: {
|
|
17
|
+
Program(programPath, state) {
|
|
18
|
+
const currentFilePath = path.resolve(state.filename || state.file.opts.filename || '');
|
|
19
|
+
|
|
20
|
+
// Only apply polyfills to files that import gt-react-native or generaltranslation
|
|
21
|
+
if (currentFilePath !== entryPointFilePath) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const resolvedLocales = resolveLocales({
|
|
25
|
+
locales,
|
|
26
|
+
config,
|
|
27
|
+
configFilePath
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// TODO: smart imports based on if the polyfill is required, do this as a wrapper around AppRegistry.registerComponent()
|
|
31
|
+
const imports = ['@formatjs/intl-getcanonicallocales/polyfill', '@formatjs/intl-locale/polyfill', '@formatjs/intl-displaynames/polyfill', '@formatjs/intl-listformat/polyfill', '@formatjs/intl-pluralrules/polyfill-force',
|
|
32
|
+
// https://github.com/formatjs/formatjs/issues/4463
|
|
33
|
+
'@formatjs/intl-numberformat/polyfill', '@formatjs/intl-relativetimeformat/polyfill', '@formatjs/intl-datetimeformat/polyfill', '@formatjs/intl-datetimeformat/add-all-tz', ...resolvedLocales.flatMap(locale => [`@formatjs/intl-displaynames/locale-data/${locale}`, `@formatjs/intl-listformat/locale-data/${locale}`, `@formatjs/intl-pluralrules/locale-data/${locale}`, `@formatjs/intl-numberformat/locale-data/${locale}`, `@formatjs/intl-relativetimeformat/locale-data/${locale}`, `@formatjs/intl-datetimeformat/locale-data/${locale}`])];
|
|
34
|
+
const existingImports = new Set();
|
|
35
|
+
programPath.node.body.forEach(node => {
|
|
36
|
+
if (t.isImportDeclaration(node) && typeof node.source.value === 'string' && imports.includes(node.source.value)) {
|
|
37
|
+
existingImports.add(node.source.value);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const importsToAdd = imports.filter(imp => !existingImports.has(imp));
|
|
41
|
+
if (importsToAdd.length > 0) {
|
|
42
|
+
const newImports = importsToAdd.map(importPath => t.importDeclaration([], t.stringLiteral(importPath)));
|
|
43
|
+
programPath.node.body.unshift(...newImports);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["path","resolveLocales","babel","locales","config","configFilePath","entryPointFilePath","resolve","process","cwd","types","t","name","visitor","Program","programPath","state","currentFilePath","filename","file","opts","resolvedLocales","imports","flatMap","locale","existingImports","Set","node","body","forEach","isImportDeclaration","source","value","includes","add","importsToAdd","filter","imp","has","length","newImports","map","importPath","importDeclaration","stringLiteral","unshift"],"sourceRoot":"../../../src","sources":["plugin-dir/index.ts"],"mappings":";;AAAA,OAAO,KAAKA,IAAI,MAAM,MAAM;AAG5B,SAASC,cAAc,QAAQ,2BAAwB;AAEvD,eAAe,UACbC,KAA8B,EAC9B;EACEC,OAAO;EACPC,MAAM;EACNC,cAAc;EACdC,kBAAkB,GAAGN,IAAI,CAACO,OAAO,CAACC,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS;AACpD,CAAC,EACL;EACX,MAAM;IAAEC,KAAK,EAAEC;EAAE,CAAC,GAAGT,KAAK;EAE1B,OAAO;IACLU,IAAI,EAAE,wBAAwB;IAC9BC,OAAO,EAAE;MACPC,OAAOA,CAACC,WAAW,EAAEC,KAAK,EAAE;QAC1B,MAAMC,eAAe,GAAGjB,IAAI,CAACO,OAAO,CAClCS,KAAK,CAACE,QAAQ,IAAIF,KAAK,CAACG,IAAI,CAACC,IAAI,CAACF,QAAQ,IAAI,EAChD,CAAC;;QAED;QACA,IAAID,eAAe,KAAKX,kBAAkB,EAAE;UAC1C;QACF;QAEA,MAAMe,eAAe,GAAGpB,cAAc,CAAC;UACrCE,OAAO;UACPC,MAAM;UACNC;QACF,CAAC,CAAC;;QAEF;QACA,MAAMiB,OAAO,GAAG,CACd,6CAA6C,EAC7C,gCAAgC,EAChC,sCAAsC,EACtC,oCAAoC,EACpC,2CAA2C;QAAE;QAC7C,sCAAsC,EACtC,4CAA4C,EAC5C,wCAAwC,EACxC,0CAA0C,EAC1C,GAAGD,eAAe,CAACE,OAAO,CAAEC,MAAM,IAAK,CACrC,2CAA2CA,MAAM,EAAE,EACnD,yCAAyCA,MAAM,EAAE,EACjD,0CAA0CA,MAAM,EAAE,EAClD,2CAA2CA,MAAM,EAAE,EACnD,iDAAiDA,MAAM,EAAE,EACzD,6CAA6CA,MAAM,EAAE,CACtD,CAAC,CACH;QAED,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAS,CAAC;QACzCX,WAAW,CAACY,IAAI,CAACC,IAAI,CAACC,OAAO,CAAEF,IAAI,IAAK;UACtC,IACEhB,CAAC,CAACmB,mBAAmB,CAACH,IAAI,CAAC,IAC3B,OAAOA,IAAI,CAACI,MAAM,CAACC,KAAK,KAAK,QAAQ,IACrCV,OAAO,CAACW,QAAQ,CAACN,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC,EACnC;YACAP,eAAe,CAACS,GAAG,CAACP,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC;UACxC;QACF,CAAC,CAAC;QAEF,MAAMG,YAAY,GAAGb,OAAO,CAACc,MAAM,CAAEC,GAAG,IAAK,CAACZ,eAAe,CAACa,GAAG,CAACD,GAAG,CAAC,CAAC;QAEvE,IAAIF,YAAY,CAACI,MAAM,GAAG,CAAC,EAAE;UAC3B,MAAMC,UAAU,GAAGL,YAAY,CAACM,GAAG,CAAEC,UAAU,IAC7C/B,CAAC,CAACgC,iBAAiB,CAAC,EAAE,EAAEhC,CAAC,CAACiC,aAAa,CAACF,UAAU,CAAC,CACrD,CAAC;UAED3B,WAAW,CAACY,IAAI,CAACC,IAAI,CAACiB,OAAO,CAAC,GAAGL,UAAU,CAAC;QAC9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["plugin-dir/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { couldNotLocateConfigWarning, invalidLocalesWarning, resolveLocalesFailedWarning } from "../../errors-dir/warnings.js";
|
|
5
|
+
import { libraryDefaultLocale } from 'generaltranslation/internal';
|
|
6
|
+
import { failedToReadConfigFileError } from "../../errors-dir/errors.js";
|
|
7
|
+
import { getSupportedLocale } from '@generaltranslation/supported-locales';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
const DEFAULT_CONFIG_FILE_PATHS = [path.join(process.cwd(), 'gt.config.json'), path.join(process.cwd(), '.locadex', 'gt.config.json')];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Given a list of locales or a config object or a path to a config file, return a list of locales to polyfill.
|
|
13
|
+
* Preference order: locales > config > configFilePaths > library default locale
|
|
14
|
+
*/
|
|
15
|
+
export function resolveLocales({
|
|
16
|
+
locales,
|
|
17
|
+
config,
|
|
18
|
+
configFilePath
|
|
19
|
+
}) {
|
|
20
|
+
let result = [];
|
|
21
|
+
|
|
22
|
+
// Resolve locales from the given options
|
|
23
|
+
if (locales) {
|
|
24
|
+
result = Array.from(new Set(locales));
|
|
25
|
+
} else if (config) {
|
|
26
|
+
result = Array.from(new Set([config.defaultLocale, ...config.locales]));
|
|
27
|
+
} else {
|
|
28
|
+
result = resolveLocalesFromConfig(configFilePath);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Validate the result
|
|
32
|
+
const invalidLocales = result.filter(locale => !getSupportedLocale(locale));
|
|
33
|
+
if (invalidLocales.length) {
|
|
34
|
+
console.warn(invalidLocalesWarning(invalidLocales));
|
|
35
|
+
result = result.filter(locale => !invalidLocales.includes(locale));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Fallback to default locale if no locales were found
|
|
39
|
+
if (result.length === 0) {
|
|
40
|
+
console.warn(resolveLocalesFailedWarning);
|
|
41
|
+
result = [libraryDefaultLocale];
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolve locales from a config file
|
|
48
|
+
* @param configFilePath - The path to the config file
|
|
49
|
+
* @returns A list of locales
|
|
50
|
+
*/
|
|
51
|
+
function resolveLocalesFromConfig(configFilePath) {
|
|
52
|
+
const configFilePaths = [...(configFilePath ? [configFilePath] : []), ...DEFAULT_CONFIG_FILE_PATHS];
|
|
53
|
+
let result = [];
|
|
54
|
+
for (const filePath of configFilePaths) {
|
|
55
|
+
try {
|
|
56
|
+
if (!fs.existsSync(filePath)) {
|
|
57
|
+
console.warn(couldNotLocateConfigWarning(filePath));
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const resolvedConfig = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
61
|
+
result = Array.from(new Set([...(resolvedConfig.defaultLocale ? [resolvedConfig.defaultLocale] : []), ...(resolvedConfig.locales || [])]));
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(failedToReadConfigFileError(filePath), error);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=resolveLocales.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fs","couldNotLocateConfigWarning","invalidLocalesWarning","resolveLocalesFailedWarning","libraryDefaultLocale","failedToReadConfigFileError","getSupportedLocale","path","DEFAULT_CONFIG_FILE_PATHS","join","process","cwd","resolveLocales","locales","config","configFilePath","result","Array","from","Set","defaultLocale","resolveLocalesFromConfig","invalidLocales","filter","locale","length","console","warn","includes","configFilePaths","filePath","existsSync","resolvedConfig","JSON","parse","readFileSync","error"],"sourceRoot":"../../../../src","sources":["plugin-dir/utils/resolveLocales.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default"],"sourceRoot":"../../src","sources":["plugin.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,uBAAc","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function testLocalePolyfill(locale = 'en-US') {
|
|
4
|
+
const problems = [];
|
|
5
|
+
|
|
6
|
+
// 1. basic presence
|
|
7
|
+
if (!global.Intl) problems.push('Intl missing entirely');
|
|
8
|
+
const apis = ['Locale', 'NumberFormat', 'DateTimeFormat', 'PluralRules', 'RelativeTimeFormat', 'ListFormat', 'DisplayNames'];
|
|
9
|
+
apis.forEach(a => {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
if (!Intl[a]) problems.push(`Intl.${a} missing`);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// 2. locale actually supported (no silent fallback)
|
|
15
|
+
const dtfSupported = Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
|
|
16
|
+
const nfSupported = Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
|
|
17
|
+
if (!dtfSupported) problems.push(`${locale} not supported by DateTimeFormat`);
|
|
18
|
+
if (!nfSupported) problems.push(`${locale} not supported by NumberFormat`);
|
|
19
|
+
|
|
20
|
+
// 3. numeric separators sanity
|
|
21
|
+
let group, decimal;
|
|
22
|
+
try {
|
|
23
|
+
const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);
|
|
24
|
+
group = parts.find(p => p.type === 'group')?.value;
|
|
25
|
+
decimal = parts.find(p => p.type === 'decimal')?.value;
|
|
26
|
+
if (!group || !decimal) problems.push('formatToParts missing group/decimal separators');
|
|
27
|
+
} catch (e) {
|
|
28
|
+
problems.push(`NumberFormat threw: ${e instanceof Error ? e.message : String(e)}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 4. plural rules sanity
|
|
32
|
+
try {
|
|
33
|
+
const pr = new Intl.PluralRules(locale);
|
|
34
|
+
const sample = pr.select(5);
|
|
35
|
+
if (!sample) problems.push('PluralRules returned undefined');
|
|
36
|
+
} catch (e) {
|
|
37
|
+
problems.push(`PluralRules threw: ${e instanceof Error ? e.message : String(e)}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 5. show example formatted values
|
|
41
|
+
const example = {
|
|
42
|
+
number: new Intl.NumberFormat(locale).format(1234.5),
|
|
43
|
+
date: new Intl.DateTimeFormat(locale, {
|
|
44
|
+
dateStyle: 'long'
|
|
45
|
+
}).format(new Date('2020-01-02')),
|
|
46
|
+
weekday: new Intl.DateTimeFormat(locale, {
|
|
47
|
+
weekday: 'long'
|
|
48
|
+
}).format(new Date('2020-01-02'))
|
|
49
|
+
};
|
|
50
|
+
const result = {
|
|
51
|
+
ok: problems.length === 0,
|
|
52
|
+
problems,
|
|
53
|
+
group,
|
|
54
|
+
decimal,
|
|
55
|
+
example
|
|
56
|
+
};
|
|
57
|
+
if (result.ok) {
|
|
58
|
+
console.log(`✅ Locale polyfill looks OK for ${locale}`, example);
|
|
59
|
+
} else {
|
|
60
|
+
console.warn(`❌ Locale polyfill check failed for ${locale}:`, problems, example);
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=testLocalePolyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["testLocalePolyfill","locale","problems","global","Intl","push","apis","forEach","a","dtfSupported","DateTimeFormat","supportedLocalesOf","nfSupported","NumberFormat","group","decimal","parts","formatToParts","find","p","type","value","e","Error","message","String","pr","PluralRules","sample","select","example","number","format","date","dateStyle","Date","weekday","result","ok","length","console","log","warn"],"sourceRoot":"../../../src","sources":["tools/testLocalePolyfill.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PACKAGE_NAME = "gt-react";
|
|
1
|
+
export declare const PACKAGE_NAME = "gt-react-native";
|
|
2
2
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/errors-dir/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/errors-dir/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/errors-dir/errors.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,2BAA2B,GAAI,UAAU,MAAM,WACO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.d.ts","sourceRoot":"","sources":["../../../../src/errors-dir/warnings.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,2BAA2B,QAIO,CAAC;AAEhD,eAAO,MAAM,2BAA2B,GAAI,UAAU,MAAM,WACG,CAAC;AAEhE,eAAO,MAAM,qBAAqB,GAAI,gBAAgB,MAAM,EAAE,WACwB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import './utils/polyfill';
|
|
2
1
|
import { GTProvider } from './provider/GTProvider';
|
|
3
2
|
export declare function multiply(a: number, b: number): number;
|
|
4
3
|
import { T, useGT, useTranslations, useDefaultLocale, useLocale, useRegion, Var, Num, Currency, DateTime, Plural, Branch, useLocales, useLocaleSelector, useSetLocale, useGTClass, useLocaleProperties, useRegionSelector, useLocaleDirection, useMessages, msg, decodeMsg, decodeOptions } from '@generaltranslation/react-core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,OAAO,EACL,CAAC,EACD,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,GAAG,EACH,SAAS,EACT,aAAa,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,CAAC,EACD,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,GAAG,EACH,SAAS,EACT,aAAa,EACb,WAAW,GACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PluginObj, types } from '@babel/core';
|
|
2
|
+
import type { PluginOptions } from './types';
|
|
3
|
+
export default function (babel: {
|
|
4
|
+
types: typeof types;
|
|
5
|
+
}, { locales, config, configFilePath, entryPointFilePath, }: PluginOptions): PluginObj;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugin-dir/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,MAAM,CAAC,OAAO,WACZ,KAAK,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,EAC9B,EACE,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkE,GACnE,EAAE,aAAa,GACf,SAAS,CAkEX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugin-dir/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,MAAM,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a list of locales or a config object or a path to a config file, return a list of locales to polyfill.
|
|
3
|
+
* Preference order: locales > config > configFilePaths > library default locale
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveLocales({ locales, config, configFilePath, }: {
|
|
6
|
+
locales?: string[];
|
|
7
|
+
config?: {
|
|
8
|
+
defaultLocale: string;
|
|
9
|
+
locales: string[];
|
|
10
|
+
} & Record<string, any>;
|
|
11
|
+
configFilePath?: string;
|
|
12
|
+
}): string[];
|
|
13
|
+
//# sourceMappingURL=resolveLocales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveLocales.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/utils/resolveLocales.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,MAAM,EACN,cAAc,GACf,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,EAAE,CA0BX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function testLocalePolyfill(locale?: string): {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
problems: string[];
|
|
4
|
+
group: string | undefined;
|
|
5
|
+
decimal: string | undefined;
|
|
6
|
+
example: {
|
|
7
|
+
number: string;
|
|
8
|
+
date: string;
|
|
9
|
+
weekday: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=testLocalePolyfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testLocalePolyfill.d.ts","sourceRoot":"","sources":["../../../../src/tools/testLocalePolyfill.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,MAAM,SAAU;;;;;;;;;;EAiFlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAkBG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-react-native",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "An i18n package for React Native",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -10,7 +10,16 @@
|
|
|
10
10
|
"types": "./lib/typescript/src/index.d.ts",
|
|
11
11
|
"default": "./lib/module/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./
|
|
13
|
+
"./plugin": {
|
|
14
|
+
"source": "./src/plugin.ts",
|
|
15
|
+
"types": "./lib/typescript/src/plugin.d.ts",
|
|
16
|
+
"default": "./lib/module/plugin.js"
|
|
17
|
+
},
|
|
18
|
+
"./internal": {
|
|
19
|
+
"source": "./src/internal.ts",
|
|
20
|
+
"types": "./lib/typescript/src/internal.d.ts",
|
|
21
|
+
"default": "./lib/module/internal.js"
|
|
22
|
+
}
|
|
14
23
|
},
|
|
15
24
|
"files": [
|
|
16
25
|
"src",
|
|
@@ -18,6 +27,7 @@
|
|
|
18
27
|
"android",
|
|
19
28
|
"ios",
|
|
20
29
|
"cpp",
|
|
30
|
+
"package.json",
|
|
21
31
|
"*.podspec",
|
|
22
32
|
"!ios/build",
|
|
23
33
|
"!android/build",
|
|
@@ -32,7 +42,8 @@
|
|
|
32
42
|
],
|
|
33
43
|
"scripts": {
|
|
34
44
|
"example": "yarn workspace gt-react-native-example",
|
|
35
|
-
"test": "
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest",
|
|
36
47
|
"typecheck": "tsc",
|
|
37
48
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
38
49
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
@@ -59,6 +70,8 @@
|
|
|
59
70
|
"registry": "https://registry.npmjs.org/"
|
|
60
71
|
},
|
|
61
72
|
"devDependencies": {
|
|
73
|
+
"@babel/core": "^7.28.4",
|
|
74
|
+
"@babel/types": "^7.28.4",
|
|
62
75
|
"@commitlint/config-conventional": "^19.8.1",
|
|
63
76
|
"@eslint/compat": "^1.3.2",
|
|
64
77
|
"@eslint/eslintrc": "^3.3.1",
|
|
@@ -68,20 +81,21 @@
|
|
|
68
81
|
"@react-native/babel-preset": "0.81.1",
|
|
69
82
|
"@react-native/eslint-config": "^0.81.1",
|
|
70
83
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
71
|
-
"@types/jest": "^29.5.14",
|
|
72
84
|
"@types/react": "^19.1.0",
|
|
85
|
+
"@vitest/coverage-v8": "^1.0.4",
|
|
86
|
+
"@vitest/ui": "^1.0.4",
|
|
73
87
|
"commitlint": "^19.8.1",
|
|
74
88
|
"del-cli": "^6.0.0",
|
|
75
89
|
"eslint": "^9.35.0",
|
|
76
90
|
"eslint-config-prettier": "^10.1.8",
|
|
77
91
|
"eslint-plugin-prettier": "^5.5.4",
|
|
78
|
-
"jest": "^29.7.0",
|
|
79
92
|
"prettier": "^3.6.2",
|
|
80
93
|
"react": "19.1.0",
|
|
81
94
|
"react-native": "0.81.1",
|
|
82
95
|
"react-native-builder-bob": "^0.40.13",
|
|
83
96
|
"turbo": "^2.5.6",
|
|
84
|
-
"typescript": "^5.9.2"
|
|
97
|
+
"typescript": "^5.9.2",
|
|
98
|
+
"vitest": "^1.0.4"
|
|
85
99
|
},
|
|
86
100
|
"dependencies": {
|
|
87
101
|
"@formatjs/intl-datetimeformat": "^6.18.2",
|
|
@@ -104,13 +118,6 @@
|
|
|
104
118
|
"example"
|
|
105
119
|
],
|
|
106
120
|
"packageManager": "yarn@3.6.1",
|
|
107
|
-
"jest": {
|
|
108
|
-
"preset": "react-native",
|
|
109
|
-
"modulePathIgnorePatterns": [
|
|
110
|
-
"<rootDir>/example/node_modules",
|
|
111
|
-
"<rootDir>/lib/"
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
121
|
"commitlint": {
|
|
115
122
|
"extends": [
|
|
116
123
|
"@commitlint/config-conventional"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_NAME = 'gt-react';
|
|
1
|
+
export const PACKAGE_NAME = 'gt-react-native';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { libraryDefaultLocale } from 'generaltranslation/internal';
|
|
2
|
+
import { PACKAGE_NAME } from './constants';
|
|
3
|
+
|
|
4
|
+
export const resolveLocalesFailedWarning = `${PACKAGE_NAME}: Failed to resolve locales for polyfill. Falling back to ${libraryDefaultLocale}.
|
|
5
|
+
Specify a list of locales for the gt-react-native babel plugin by:
|
|
6
|
+
(1) Providing a list of locales
|
|
7
|
+
(2) Providing your GT Config to the plugin
|
|
8
|
+
(3) Providing the path to your GT Config file.`;
|
|
9
|
+
|
|
10
|
+
export const couldNotLocateConfigWarning = (filePath: string) =>
|
|
11
|
+
`${PACKAGE_NAME}: Could not locate GT Config at ${filePath}.`;
|
|
12
|
+
|
|
13
|
+
export const invalidLocalesWarning = (invalidLocales: string[]) =>
|
|
14
|
+
`${PACKAGE_NAME}: Invalid locales found in GT Config: ${invalidLocales.join(', ')}.`;
|
package/src/index.tsx
CHANGED
package/src/internal.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { testLocalePolyfill } from './tools/testLocalePolyfill';
|