react-native-intlayer 5.3.1 → 5.3.2
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
CHANGED
|
@@ -5,70 +5,68 @@
|
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/
|
|
9
|
-
<img alt="npm" src="https://img.shields.io/npm/v/
|
|
8
|
+
<a href="https://www.npmjs.com/package/react-native-intlayer">
|
|
9
|
+
<img alt="npm" src="https://img.shields.io/npm/v/react-native-intlayer.svg?labelColor=49516F&color=8994BC" />
|
|
10
10
|
</a>
|
|
11
|
-
<a href="https://npmjs.org/package/
|
|
12
|
-
<img alt="downloads" src="https://badgen.net/npm/dm/
|
|
11
|
+
<a href="https://npmjs.org/package/react-native-intlayer">
|
|
12
|
+
<img alt="downloads" src="https://badgen.net/npm/dm/react-native-intlayer?labelColor=49516F&color=8994BC" />
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://npmjs.org/package/
|
|
15
|
-
<img alt="types included" src="https://badgen.net/npm/types/
|
|
14
|
+
<a href="https://npmjs.org/package/react-native-intlayer">
|
|
15
|
+
<img alt="types included" src="https://badgen.net/npm/types/react-native-intlayer?labelColor=49516F&color=8994BC"
|
|
16
16
|
/>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# react-native-intlayer: Internationalize (i18n) an React Native application
|
|
20
20
|
|
|
21
21
|
**Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
|
|
22
22
|
|
|
23
|
-
**The `
|
|
23
|
+
**The `react-native-intlayer` package** allows you to internationalize your Vite application. It includes the Metro plugin to set the configuration through environment variables into the [Metro bundler](https://docs.expo.dev/guides/customizing-metro/).
|
|
24
24
|
|
|
25
|
-
## Why Internationalize Your
|
|
25
|
+
## Why Internationalize Your React Native Application?
|
|
26
26
|
|
|
27
|
-
Internationalizing your
|
|
27
|
+
Internationalizing your React Native application is essential for serving a global audience effectively. It allows your application to deliver content and messages in the preferred language of each user. This capability enhances user experience and broadens your application's reach by making it more accessible and relevant to people from different linguistic backgrounds.
|
|
28
28
|
|
|
29
29
|
## Configuration
|
|
30
30
|
|
|
31
|
-
The `
|
|
31
|
+
The `react-native-intlayer` package works seamlessly with the [`react-intlayer` package](https://github.com/aymericzip/intlayer/blob/main/docs/en/packages/react-intlayer/index.md), and the [`intlayer` package](https://github.com/aymericzip/intlayer/blob/main/docs/en/packages/intlayer/index.md). Have a look at the relevant documentation for more information.
|
|
32
32
|
|
|
33
33
|
## Installation
|
|
34
34
|
|
|
35
35
|
Install the necessary package using your preferred package manager:
|
|
36
36
|
|
|
37
37
|
```bash packageManager="npm"
|
|
38
|
-
npm install
|
|
38
|
+
npm install react-native-intlayer
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
```bash packageManager="yarn"
|
|
42
|
-
yarn add
|
|
42
|
+
yarn add react-native-intlayer
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
```bash packageManager="pnpm"
|
|
46
|
-
pnpm add
|
|
46
|
+
pnpm add react-native-intlayer
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
## Example of usage
|
|
50
50
|
|
|
51
51
|
See an example of how to include the plugins into your vite configuration.
|
|
52
52
|
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
```js
|
|
54
|
+
// metro.config.js
|
|
55
|
+
const { getDefaultConfig } = require("expo/metro-config");
|
|
56
|
+
const { configMetroIntlayer } = require("react-native-intlayer/metro");
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
plugins: [intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
> The `intlayerPlugin()` Vite plugin is used to integrate Intlayer with Vite. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Vite application. Additionally, it provides aliases to optimize performance.
|
|
58
|
+
module.exports = (async () => {
|
|
59
|
+
const defaultConfig = getDefaultConfig(__dirname);
|
|
64
60
|
|
|
65
|
-
|
|
61
|
+
return await configMetroIntlayer(defaultConfig);
|
|
62
|
+
})();
|
|
63
|
+
```
|
|
66
64
|
|
|
67
65
|
## Mastering the internationalization of your Vite application
|
|
68
66
|
|
|
69
67
|
Intlayer provides a lot of features to help you internationalize your Vite application.
|
|
70
68
|
|
|
71
|
-
**To learn more about these features, refer to the [React Internationalization (i18n) with Intlayer and
|
|
69
|
+
**To learn more about these features, refer to the [React Internationalization (i18n) with Intlayer and React Native](https://github.com/aymericzip/intlayer/blob/main/docs/en/intlayer_with_react_native+expo.md) guide for React Native Application.**
|
|
72
70
|
|
|
73
71
|
## Read about Intlayer
|
|
74
72
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { getDefaultConfig } from 'expo/metro-config';\nimport { getConfiguration } from '@intlayer/config';\nimport { join } from 'path';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\nimport { prepareIntlayer } from '@intlayer/chokidar';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\nexport const configMetroIntlayer = async (\n baseConfig: MetroConfig\n): Promise<MetroConfig> => {\n const intlayerConfig = getConfiguration();\n\n await prepareIntlayer(intlayerConfig);\n\n const { mainDir, configDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.cjs');\n const configurationPath = join(configDir, 'configuration.json');\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig.resolver,\n resolveRequest: (context, moduleName, platform) => {\n if (moduleName === '@intlayer/dictionaries-entry') {\n return {\n filePath: require.resolve(dictionariesPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/built') {\n return {\n filePath: require.resolve(configurationPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Prevent infinite recursion\n return resolve(context, moduleName, platform);\n },\n blockList: exclusionList([\n ...[baseConfig.resolver?.blockList ?? []].flat(),\n // the following instruction should be replaced intlayerConfig.content.watchedFilesPattern\n // but using watchedFilesPattern does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } satisfies MetroConfig;\n\n return config;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAiC;AACjC,kBAAqB;AACrB,4BAAwB;AACxB,2BAA8B;AAC9B,sBAAgC;
|
|
1
|
+
{"version":3,"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { getDefaultConfig } from 'expo/metro-config';\nimport { getConfiguration } from '@intlayer/config';\nimport { join } from 'path';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\nimport { prepareIntlayer } from '@intlayer/chokidar';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n *\n * module.exports = (async () => {\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return await configMetroIntlayer(defaultConfig);\n * })();\n * ```\n */\nexport const configMetroIntlayer = async (\n baseConfig: MetroConfig\n): Promise<MetroConfig> => {\n const intlayerConfig = getConfiguration();\n\n await prepareIntlayer(intlayerConfig);\n\n const { mainDir, configDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.cjs');\n const configurationPath = join(configDir, 'configuration.json');\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig.resolver,\n resolveRequest: (context, moduleName, platform) => {\n if (moduleName === '@intlayer/dictionaries-entry') {\n return {\n filePath: require.resolve(dictionariesPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/built') {\n return {\n filePath: require.resolve(configurationPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Prevent infinite recursion\n return resolve(context, moduleName, platform);\n },\n blockList: exclusionList([\n ...[baseConfig.resolver?.blockList ?? []].flat(),\n // the following instruction should be replaced intlayerConfig.content.watchedFilesPattern\n // but using watchedFilesPattern does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } satisfies MetroConfig;\n\n return config;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAiC;AACjC,kBAAqB;AACrB,4BAAwB;AACxB,2BAA8B;AAC9B,sBAAgC;AAgBzB,MAAM,sBAAsB,OACjC,eACyB;AACzB,QAAM,qBAAiB,gCAAiB;AAExC,YAAM,iCAAgB,cAAc;AAEpC,QAAM,EAAE,SAAS,UAAU,IAAI,eAAe;AAE9C,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,wBAAoB,kBAAK,WAAW,oBAAoB;AAE9D,QAAM,SAAS;AAAA,IACb,GAAG;AAAA,IAEH,UAAU;AAAA,MACR,GAAG,WAAW;AAAA,MACd,gBAAgB,CAAC,SAAS,YAAY,aAAa;AACjD,YAAI,eAAe,gCAAgC;AACjD,iBAAO;AAAA,YACL,UAAU,QAAQ,QAAQ,gBAAgB;AAAA,YAC1C,MAAM;AAAA,UACR;AAAA,QACF,WAAW,eAAe,0BAA0B;AAClD,iBAAO;AAAA,YACL,UAAU,QAAQ,QAAQ,iBAAiB;AAAA,YAC3C,MAAM;AAAA,UACR;AAAA,QACF,WAAW,eAAe,2BAA2B;AACnD,iBAAO;AAAA,YACL,UAAU,gBAAgB,yBAAyB;AAAA,YACnD,MAAM;AAAA,UACR;AAAA,QACF;AAGA,mBAAO,+BAAQ,SAAS,YAAY,QAAQ;AAAA,MAC9C;AAAA,MACA,eAAW,oCAAc;AAAA,QACvB,GAAG,CAAC,WAAW,UAAU,aAAa,CAAC,CAAC,EAAE,KAAK;AAAA;AAAA;AAAA,QAG/C;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { getDefaultConfig } from 'expo/metro-config';\nimport { getConfiguration } from '@intlayer/config';\nimport { join } from 'path';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\nimport { prepareIntlayer } from '@intlayer/chokidar';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\nexport const configMetroIntlayer = async (\n baseConfig: MetroConfig\n): Promise<MetroConfig> => {\n const intlayerConfig = getConfiguration();\n\n await prepareIntlayer(intlayerConfig);\n\n const { mainDir, configDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.cjs');\n const configurationPath = join(configDir, 'configuration.json');\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig.resolver,\n resolveRequest: (context, moduleName, platform) => {\n if (moduleName === '@intlayer/dictionaries-entry') {\n return {\n filePath: require.resolve(dictionariesPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/built') {\n return {\n filePath: require.resolve(configurationPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Prevent infinite recursion\n return resolve(context, moduleName, platform);\n },\n blockList: exclusionList([\n ...[baseConfig.resolver?.blockList ?? []].flat(),\n // the following instruction should be replaced intlayerConfig.content.watchedFilesPattern\n // but using watchedFilesPattern does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } satisfies MetroConfig;\n\n return config;\n};\n"],"mappings":"AACA,SAAS,wBAAwB;AACjC,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;
|
|
1
|
+
{"version":3,"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { getDefaultConfig } from 'expo/metro-config';\nimport { getConfiguration } from '@intlayer/config';\nimport { join } from 'path';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\nimport { prepareIntlayer } from '@intlayer/chokidar';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n *\n * module.exports = (async () => {\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return await configMetroIntlayer(defaultConfig);\n * })();\n * ```\n */\nexport const configMetroIntlayer = async (\n baseConfig: MetroConfig\n): Promise<MetroConfig> => {\n const intlayerConfig = getConfiguration();\n\n await prepareIntlayer(intlayerConfig);\n\n const { mainDir, configDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.cjs');\n const configurationPath = join(configDir, 'configuration.json');\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig.resolver,\n resolveRequest: (context, moduleName, platform) => {\n if (moduleName === '@intlayer/dictionaries-entry') {\n return {\n filePath: require.resolve(dictionariesPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/built') {\n return {\n filePath: require.resolve(configurationPath),\n type: 'sourceFile',\n };\n } else if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Prevent infinite recursion\n return resolve(context, moduleName, platform);\n },\n blockList: exclusionList([\n ...[baseConfig.resolver?.blockList ?? []].flat(),\n // the following instruction should be replaced intlayerConfig.content.watchedFilesPattern\n // but using watchedFilesPattern does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } satisfies MetroConfig;\n\n return config;\n};\n"],"mappings":"AACA,SAAS,wBAAwB;AACjC,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAgBzB,MAAM,sBAAsB,OACjC,eACyB;AACzB,QAAM,iBAAiB,iBAAiB;AAExC,QAAM,gBAAgB,cAAc;AAEpC,QAAM,EAAE,SAAS,UAAU,IAAI,eAAe;AAE9C,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,oBAAoB,KAAK,WAAW,oBAAoB;AAE9D,QAAM,SAAS;AAAA,IACb,GAAG;AAAA,IAEH,UAAU;AAAA,MACR,GAAG,WAAW;AAAA,MACd,gBAAgB,CAAC,SAAS,YAAY,aAAa;AACjD,YAAI,eAAe,gCAAgC;AACjD,iBAAO;AAAA,YACL,UAAU,QAAQ,QAAQ,gBAAgB;AAAA,YAC1C,MAAM;AAAA,UACR;AAAA,QACF,WAAW,eAAe,0BAA0B;AAClD,iBAAO;AAAA,YACL,UAAU,QAAQ,QAAQ,iBAAiB;AAAA,YAC3C,MAAM;AAAA,UACR;AAAA,QACF,WAAW,eAAe,2BAA2B;AACnD,iBAAO;AAAA,YACL,UAAU,gBAAgB,yBAAyB;AAAA,YACnD,MAAM;AAAA,UACR;AAAA,QACF;AAGA,eAAO,QAAQ,SAAS,YAAY,QAAQ;AAAA,MAC9C;AAAA,MACA,WAAW,cAAc;AAAA,QACvB,GAAG,CAAC,WAAW,UAAU,aAAa,CAAC,CAAC,EAAE,KAAK;AAAA;AAAA;AAAA,QAG/C;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { getDefaultConfig } from 'expo/metro-config';
|
|
2
2
|
type MetroConfig = ReturnType<typeof getDefaultConfig>;
|
|
3
|
+
/**
|
|
4
|
+
* // metro.config.js
|
|
5
|
+
* const { getDefaultConfig } = require("expo/metro-config");
|
|
6
|
+
* const { configMetroIntlayer } = require("react-native-intlayer/metro");
|
|
7
|
+
*
|
|
8
|
+
* module.exports = (async () => {
|
|
9
|
+
* const defaultConfig = getDefaultConfig(__dirname);
|
|
10
|
+
*
|
|
11
|
+
* return await configMetroIntlayer(defaultConfig);
|
|
12
|
+
* })();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
3
15
|
export declare const configMetroIntlayer: (baseConfig: MetroConfig) => Promise<MetroConfig>;
|
|
4
16
|
export {};
|
|
5
17
|
//# sourceMappingURL=configMetroIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configMetroIntlayer.d.ts","sourceRoot":"","sources":["../../src/configMetroIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEvD,eAAO,MAAM,mBAAmB,GAC9B,YAAY,WAAW,KACtB,OAAO,CAAC,WAAW,CA8CrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"configMetroIntlayer.d.ts","sourceRoot":"","sources":["../../src/configMetroIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAC9B,YAAY,WAAW,KACtB,OAAO,CAAC,WAAW,CA8CrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-intlayer",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A React Native plugin for seamless internationalization (i18n), providing locale detection, redirection, and environment-based configuration",
|
|
6
6
|
"keywords": [
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"./package.json"
|
|
64
64
|
],
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@intlayer/chokidar": "5.3.
|
|
67
|
-
"@intlayer/config": "5.3.
|
|
68
|
-
"@intlayer/core": "5.3.
|
|
66
|
+
"@intlayer/chokidar": "5.3.2",
|
|
67
|
+
"@intlayer/config": "5.3.2",
|
|
68
|
+
"@intlayer/core": "5.3.2"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^22.10.6",
|
|
@@ -81,15 +81,15 @@
|
|
|
81
81
|
"typescript": "^5.7.3",
|
|
82
82
|
"@utils/eslint-config": "1.0.4",
|
|
83
83
|
"@utils/ts-config": "1.0.4",
|
|
84
|
-
"@utils/
|
|
85
|
-
"@utils/
|
|
84
|
+
"@utils/ts-config-types": "1.0.4",
|
|
85
|
+
"@utils/tsup-config": "1.0.4"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"expo": "^52.0.37",
|
|
89
89
|
"metro-resolver": "^0.82.0",
|
|
90
|
-
"@intlayer/chokidar": "5.3.
|
|
91
|
-
"@intlayer/core": "5.3.
|
|
92
|
-
"@intlayer/config": "5.3.
|
|
90
|
+
"@intlayer/chokidar": "5.3.2",
|
|
91
|
+
"@intlayer/core": "5.3.2",
|
|
92
|
+
"@intlayer/config": "5.3.2"
|
|
93
93
|
},
|
|
94
94
|
"engines": {
|
|
95
95
|
"node": ">=14.18"
|