@norcy/react-native-toolkit 0.1.9 → 0.1.11
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/lib/commonjs/WeChatLoginUtil.js +2 -2
- package/lib/commonjs/WeChatLoginUtil.js.map +1 -1
- package/lib/commonjs/i18n.js +7 -8
- package/lib/commonjs/i18n.js.map +1 -1
- package/lib/module/WeChatLoginUtil.js +2 -2
- package/lib/module/WeChatLoginUtil.js.map +1 -1
- package/lib/module/i18n.js +5 -5
- package/lib/module/i18n.js.map +1 -1
- package/package.json +1 -1
- package/src/WeChatLoginUtil.ts +2 -2
- package/src/i18n.ts +6 -5
- /package/lib/typescript/{src/AppleLoginUtil.d.ts → AppleLoginUtil.d.ts} +0 -0
- /package/lib/typescript/{src/Notification.d.ts → Notification.d.ts} +0 -0
- /package/lib/typescript/{src/PrefData.d.ts → PrefData.d.ts} +0 -0
- /package/lib/typescript/{src/ReportUtil.d.ts → ReportUtil.d.ts} +0 -0
- /package/lib/typescript/{src/SentryManager.d.ts → SentryManager.d.ts} +0 -0
- /package/lib/typescript/{src/SyncPrefData.d.ts → SyncPrefData.d.ts} +0 -0
- /package/lib/typescript/{src/WeChatLoginUtil.d.ts → WeChatLoginUtil.d.ts} +0 -0
- /package/lib/typescript/{src/constant.d.ts → constant.d.ts} +0 -0
- /package/lib/typescript/{src/i18n.d.ts → i18n.d.ts} +0 -0
- /package/lib/typescript/{src/index.d.ts → index.d.ts} +0 -0
|
@@ -17,8 +17,8 @@ const WeChatLoginUtil = exports.WeChatLoginUtil = {
|
|
|
17
17
|
}).then(res => {
|
|
18
18
|
console.log('wechat get access code success: ', res.access_token);
|
|
19
19
|
let userInfoUrl = 'https://api.weixin.qq.com/sns/userinfo?access_token=' + res.access_token + '&openid=' + res.openid;
|
|
20
|
-
fetch(userInfoUrl).then(
|
|
21
|
-
return
|
|
20
|
+
fetch(userInfoUrl).then(res2 => {
|
|
21
|
+
return res2.json();
|
|
22
22
|
}).then(json => {
|
|
23
23
|
console.log('wechat get user info success: ', json);
|
|
24
24
|
callback({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WeChat","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","WeChatLoginUtil","exports","doLogin","WeiXinId","WeiXinSecret","callback","sendAuthRequest","then","ret","console","log","accessTokenUrl","code","fetch","res","json","access_token","userInfoUrl","openid","nickname","headimgurl","unionid","catch","e","warn","error"],"sources":["WeChatLoginUtil.ts"],"sourcesContent":["import * as WeChat from 'react-native-wechat-lib';\n\nexport const WeChatLoginUtil = {\n doLogin: (WeiXinId: string, WeiXinSecret: string, callback: Function) => {\n WeChat.sendAuthRequest('snsapi_userinfo')\n .then((ret) => {\n console.log('wechat auth success ', ret);\n\n let accessTokenUrl =\n 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' +\n WeiXinId +\n '&secret=' +\n WeiXinSecret +\n '&code=' +\n ret.code +\n '&grant_type=authorization_code';\n fetch(accessTokenUrl)\n .then((res) => {\n return res.json();\n })\n .then((res) => {\n console.log('wechat get access code success: ', res.access_token);\n let userInfoUrl =\n 'https://api.weixin.qq.com/sns/userinfo?access_token=' +\n res.access_token +\n '&openid=' +\n res.openid;\n fetch(userInfoUrl)\n .then((
|
|
1
|
+
{"version":3,"names":["WeChat","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","WeChatLoginUtil","exports","doLogin","WeiXinId","WeiXinSecret","callback","sendAuthRequest","then","ret","console","log","accessTokenUrl","code","fetch","res","json","access_token","userInfoUrl","openid","res2","nickname","headimgurl","unionid","catch","e","warn","error"],"sources":["WeChatLoginUtil.ts"],"sourcesContent":["import * as WeChat from 'react-native-wechat-lib';\n\nexport const WeChatLoginUtil = {\n doLogin: (WeiXinId: string, WeiXinSecret: string, callback: Function) => {\n WeChat.sendAuthRequest('snsapi_userinfo')\n .then((ret) => {\n console.log('wechat auth success ', ret);\n\n let accessTokenUrl =\n 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' +\n WeiXinId +\n '&secret=' +\n WeiXinSecret +\n '&code=' +\n ret.code +\n '&grant_type=authorization_code';\n fetch(accessTokenUrl)\n .then((res) => {\n return res.json();\n })\n .then((res) => {\n console.log('wechat get access code success: ', res.access_token);\n let userInfoUrl =\n 'https://api.weixin.qq.com/sns/userinfo?access_token=' +\n res.access_token +\n '&openid=' +\n res.openid;\n fetch(userInfoUrl)\n .then((res2) => {\n return res2.json();\n })\n .then((json) => {\n console.log('wechat get user info success: ', json);\n callback({\n nickname: json.nickname,\n headimgurl: json.headimgurl,\n openid: json.openid,\n unionid: json.unionid,\n });\n })\n .catch((e) => {\n console.warn('wechat get user info fail ', e);\n callback({ error: e });\n });\n })\n .catch((e) => {\n console.warn('wechat get access code fail ', e);\n callback({ error: e });\n });\n })\n .catch((e: any) => {\n console.warn('wechat auth fail ', e);\n callback({ error: e });\n });\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAkD,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,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 +7,33 @@ exports.i18n = void 0;
|
|
|
7
7
|
var _reactNativeToolkit = require("@norcy/react-native-toolkit");
|
|
8
8
|
var _i18nJs = require("i18n-js");
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
|
-
var _enUS = _interopRequireDefault(require("../locales/en-US.json"));
|
|
11
|
-
var _zhCN = _interopRequireDefault(require("../locales/zh-CN.json"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
10
|
/**
|
|
14
11
|
* 多语言配置文件
|
|
15
12
|
*/
|
|
16
13
|
|
|
14
|
+
const en = require('../locales/en-US.json');
|
|
15
|
+
const zh = require('../locales/zh-CN.json');
|
|
17
16
|
const i18n = exports.i18n = new _i18nJs.I18n();
|
|
18
17
|
i18n.enableFallback = true;
|
|
19
18
|
|
|
20
19
|
// 加载语言包
|
|
21
20
|
i18n.translations = {
|
|
22
|
-
zh
|
|
23
|
-
en
|
|
21
|
+
zh,
|
|
22
|
+
en
|
|
24
23
|
};
|
|
25
24
|
i18n.locale = 'zh';
|
|
26
25
|
const language = _reactNativeToolkit.SyncPrefData.getPrefString('language');
|
|
27
26
|
console.log('i18n init', language);
|
|
28
|
-
if (language
|
|
27
|
+
if (language === 'en') {
|
|
29
28
|
i18n.locale = 'en';
|
|
30
|
-
} else if (language
|
|
29
|
+
} else if (language === 'zh') {} else {
|
|
31
30
|
// 空的 或 auto
|
|
32
31
|
if (_reactNative.NativeModules.RNLocalize) {
|
|
33
32
|
var _locales$;
|
|
34
33
|
const RNLocalize = require('react-native-localize');
|
|
35
34
|
const locales = RNLocalize.getLocales();
|
|
36
35
|
const systemLanguage = (_locales$ = locales[0]) === null || _locales$ === void 0 ? void 0 : _locales$.languageCode;
|
|
37
|
-
if (systemLanguage
|
|
36
|
+
if (systemLanguage === 'en') {
|
|
38
37
|
i18n.locale = 'en';
|
|
39
38
|
}
|
|
40
39
|
}
|
package/lib/commonjs/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeToolkit","require","_i18nJs","_reactNative","
|
|
1
|
+
{"version":3,"names":["_reactNativeToolkit","require","_i18nJs","_reactNative","en","zh","i18n","exports","I18n","enableFallback","translations","locale","language","SyncPrefData","getPrefString","console","log","NativeModules","RNLocalize","_locales$","locales","getLocales","systemLanguage","languageCode","__DEV__"],"sources":["i18n.ts"],"sourcesContent":["/**\n * 多语言配置文件\n */\n\nimport { SyncPrefData } from '@norcy/react-native-toolkit';\nimport { I18n } from 'i18n-js';\nimport { NativeModules } from 'react-native';\n\nconst en = require('../locales/en-US.json');\nconst zh = require('../locales/zh-CN.json');\n\nexport const i18n = new I18n();\n\ni18n.enableFallback = true;\n\n// 加载语言包\ni18n.translations = {\n zh,\n en,\n};\ni18n.locale = 'zh';\n\nconst language = SyncPrefData.getPrefString('language');\nconsole.log('i18n init', language);\nif (language === 'en') {\n i18n.locale = 'en';\n} else if (language === 'zh') {\n} else {\n // 空的 或 auto\n if (NativeModules.RNLocalize) {\n const RNLocalize = require('react-native-localize');\n const locales = RNLocalize.getLocales();\n const systemLanguage = locales[0]?.languageCode;\n if (systemLanguage === 'en') {\n i18n.locale = 'en';\n }\n }\n}\n\nif (__DEV__) {\n // i18n.locale = 'en';\n // i18n.locale = 'zh';\n}\n"],"mappings":";;;;;;AAIA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AANA;AACA;AACA;;AAMA,MAAMG,EAAE,GAAGH,OAAO,CAAC,uBAAuB,CAAC;AAC3C,MAAMI,EAAE,GAAGJ,OAAO,CAAC,uBAAuB,CAAC;AAEpC,MAAMK,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG,IAAIE,YAAI,CAAC,CAAC;AAE9BF,IAAI,CAACG,cAAc,GAAG,IAAI;;AAE1B;AACAH,IAAI,CAACI,YAAY,GAAG;EAClBL,EAAE;EACFD;AACF,CAAC;AACDE,IAAI,CAACK,MAAM,GAAG,IAAI;AAElB,MAAMC,QAAQ,GAAGC,gCAAY,CAACC,aAAa,CAAC,UAAU,CAAC;AACvDC,OAAO,CAACC,GAAG,CAAC,WAAW,EAAEJ,QAAQ,CAAC;AAClC,IAAIA,QAAQ,KAAK,IAAI,EAAE;EACrBN,IAAI,CAACK,MAAM,GAAG,IAAI;AACpB,CAAC,MAAM,IAAIC,QAAQ,KAAK,IAAI,EAAE,CAC9B,CAAC,MAAM;EACL;EACA,IAAIK,0BAAa,CAACC,UAAU,EAAE;IAAA,IAAAC,SAAA;IAC5B,MAAMD,UAAU,GAAGjB,OAAO,CAAC,uBAAuB,CAAC;IACnD,MAAMmB,OAAO,GAAGF,UAAU,CAACG,UAAU,CAAC,CAAC;IACvC,MAAMC,cAAc,IAAAH,SAAA,GAAGC,OAAO,CAAC,CAAC,CAAC,cAAAD,SAAA,uBAAVA,SAAA,CAAYI,YAAY;IAC/C,IAAID,cAAc,KAAK,IAAI,EAAE;MAC3BhB,IAAI,CAACK,MAAM,GAAG,IAAI;IACpB;EACF;AACF;AAEA,IAAIa,OAAO,EAAE;EACX;EACA;AAAA"}
|
|
@@ -9,8 +9,8 @@ export const WeChatLoginUtil = {
|
|
|
9
9
|
}).then(res => {
|
|
10
10
|
console.log('wechat get access code success: ', res.access_token);
|
|
11
11
|
let userInfoUrl = 'https://api.weixin.qq.com/sns/userinfo?access_token=' + res.access_token + '&openid=' + res.openid;
|
|
12
|
-
fetch(userInfoUrl).then(
|
|
13
|
-
return
|
|
12
|
+
fetch(userInfoUrl).then(res2 => {
|
|
13
|
+
return res2.json();
|
|
14
14
|
}).then(json => {
|
|
15
15
|
console.log('wechat get user info success: ', json);
|
|
16
16
|
callback({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WeChat","WeChatLoginUtil","doLogin","WeiXinId","WeiXinSecret","callback","sendAuthRequest","then","ret","console","log","accessTokenUrl","code","fetch","res","json","access_token","userInfoUrl","openid","nickname","headimgurl","unionid","catch","e","warn","error"],"sources":["WeChatLoginUtil.ts"],"sourcesContent":["import * as WeChat from 'react-native-wechat-lib';\n\nexport const WeChatLoginUtil = {\n doLogin: (WeiXinId: string, WeiXinSecret: string, callback: Function) => {\n WeChat.sendAuthRequest('snsapi_userinfo')\n .then((ret) => {\n console.log('wechat auth success ', ret);\n\n let accessTokenUrl =\n 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' +\n WeiXinId +\n '&secret=' +\n WeiXinSecret +\n '&code=' +\n ret.code +\n '&grant_type=authorization_code';\n fetch(accessTokenUrl)\n .then((res) => {\n return res.json();\n })\n .then((res) => {\n console.log('wechat get access code success: ', res.access_token);\n let userInfoUrl =\n 'https://api.weixin.qq.com/sns/userinfo?access_token=' +\n res.access_token +\n '&openid=' +\n res.openid;\n fetch(userInfoUrl)\n .then((
|
|
1
|
+
{"version":3,"names":["WeChat","WeChatLoginUtil","doLogin","WeiXinId","WeiXinSecret","callback","sendAuthRequest","then","ret","console","log","accessTokenUrl","code","fetch","res","json","access_token","userInfoUrl","openid","res2","nickname","headimgurl","unionid","catch","e","warn","error"],"sources":["WeChatLoginUtil.ts"],"sourcesContent":["import * as WeChat from 'react-native-wechat-lib';\n\nexport const WeChatLoginUtil = {\n doLogin: (WeiXinId: string, WeiXinSecret: string, callback: Function) => {\n WeChat.sendAuthRequest('snsapi_userinfo')\n .then((ret) => {\n console.log('wechat auth success ', ret);\n\n let accessTokenUrl =\n 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' +\n WeiXinId +\n '&secret=' +\n WeiXinSecret +\n '&code=' +\n ret.code +\n '&grant_type=authorization_code';\n fetch(accessTokenUrl)\n .then((res) => {\n return res.json();\n })\n .then((res) => {\n console.log('wechat get access code success: ', res.access_token);\n let userInfoUrl =\n 'https://api.weixin.qq.com/sns/userinfo?access_token=' +\n res.access_token +\n '&openid=' +\n res.openid;\n fetch(userInfoUrl)\n .then((res2) => {\n return res2.json();\n })\n .then((json) => {\n console.log('wechat get user info success: ', json);\n callback({\n nickname: json.nickname,\n headimgurl: json.headimgurl,\n openid: json.openid,\n unionid: json.unionid,\n });\n })\n .catch((e) => {\n console.warn('wechat get user info fail ', e);\n callback({ error: e });\n });\n })\n .catch((e) => {\n console.warn('wechat get access code fail ', e);\n callback({ error: e });\n });\n })\n .catch((e: any) => {\n console.warn('wechat auth fail ', e);\n callback({ error: e });\n });\n },\n};\n"],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,yBAAyB;AAEjD,OAAO,MAAMC,eAAe,GAAG;EAC7BC,OAAO,EAAEA,CAACC,QAAgB,EAAEC,YAAoB,EAAEC,QAAkB,KAAK;IACvEL,MAAM,CAACM,eAAe,CAAC,iBAAiB,CAAC,CACtCC,IAAI,CAAEC,GAAG,IAAK;MACbC,OAAO,CAACC,GAAG,CAAC,sBAAsB,EAAEF,GAAG,CAAC;MAExC,IAAIG,cAAc,GAChB,0DAA0D,GAC1DR,QAAQ,GACR,UAAU,GACVC,YAAY,GACZ,QAAQ,GACRI,GAAG,CAACI,IAAI,GACR,gCAAgC;MAClCC,KAAK,CAACF,cAAc,CAAC,CAClBJ,IAAI,CAAEO,GAAG,IAAK;QACb,OAAOA,GAAG,CAACC,IAAI,CAAC,CAAC;MACnB,CAAC,CAAC,CACDR,IAAI,CAAEO,GAAG,IAAK;QACbL,OAAO,CAACC,GAAG,CAAC,kCAAkC,EAAEI,GAAG,CAACE,YAAY,CAAC;QACjE,IAAIC,WAAW,GACb,sDAAsD,GACtDH,GAAG,CAACE,YAAY,GAChB,UAAU,GACVF,GAAG,CAACI,MAAM;QACZL,KAAK,CAACI,WAAW,CAAC,CACfV,IAAI,CAAEY,IAAI,IAAK;UACd,OAAOA,IAAI,CAACJ,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CACDR,IAAI,CAAEQ,IAAI,IAAK;UACdN,OAAO,CAACC,GAAG,CAAC,gCAAgC,EAAEK,IAAI,CAAC;UACnDV,QAAQ,CAAC;YACPe,QAAQ,EAAEL,IAAI,CAACK,QAAQ;YACvBC,UAAU,EAAEN,IAAI,CAACM,UAAU;YAC3BH,MAAM,EAAEH,IAAI,CAACG,MAAM;YACnBI,OAAO,EAAEP,IAAI,CAACO;UAChB,CAAC,CAAC;QACJ,CAAC,CAAC,CACDC,KAAK,CAAEC,CAAC,IAAK;UACZf,OAAO,CAACgB,IAAI,CAAC,4BAA4B,EAAED,CAAC,CAAC;UAC7CnB,QAAQ,CAAC;YAAEqB,KAAK,EAAEF;UAAE,CAAC,CAAC;QACxB,CAAC,CAAC;MACN,CAAC,CAAC,CACDD,KAAK,CAAEC,CAAC,IAAK;QACZf,OAAO,CAACgB,IAAI,CAAC,8BAA8B,EAAED,CAAC,CAAC;QAC/CnB,QAAQ,CAAC;UAAEqB,KAAK,EAAEF;QAAE,CAAC,CAAC;MACxB,CAAC,CAAC;IACN,CAAC,CAAC,CACDD,KAAK,CAAEC,CAAM,IAAK;MACjBf,OAAO,CAACgB,IAAI,CAAC,mBAAmB,EAAED,CAAC,CAAC;MACpCnB,QAAQ,CAAC;QAAEqB,KAAK,EAAEF;MAAE,CAAC,CAAC;IACxB,CAAC,CAAC;EACN;AACF,CAAC"}
|
package/lib/module/i18n.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { SyncPrefData } from '@norcy/react-native-toolkit';
|
|
6
6
|
import { I18n } from 'i18n-js';
|
|
7
7
|
import { NativeModules } from 'react-native';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const en = require('../locales/en-US.json');
|
|
9
|
+
const zh = require('../locales/zh-CN.json');
|
|
10
10
|
export const i18n = new I18n();
|
|
11
11
|
i18n.enableFallback = true;
|
|
12
12
|
|
|
@@ -18,16 +18,16 @@ i18n.translations = {
|
|
|
18
18
|
i18n.locale = 'zh';
|
|
19
19
|
const language = SyncPrefData.getPrefString('language');
|
|
20
20
|
console.log('i18n init', language);
|
|
21
|
-
if (language
|
|
21
|
+
if (language === 'en') {
|
|
22
22
|
i18n.locale = 'en';
|
|
23
|
-
} else if (language
|
|
23
|
+
} else if (language === 'zh') {} else {
|
|
24
24
|
// 空的 或 auto
|
|
25
25
|
if (NativeModules.RNLocalize) {
|
|
26
26
|
var _locales$;
|
|
27
27
|
const RNLocalize = require('react-native-localize');
|
|
28
28
|
const locales = RNLocalize.getLocales();
|
|
29
29
|
const systemLanguage = (_locales$ = locales[0]) === null || _locales$ === void 0 ? void 0 : _locales$.languageCode;
|
|
30
|
-
if (systemLanguage
|
|
30
|
+
if (systemLanguage === 'en') {
|
|
31
31
|
i18n.locale = 'en';
|
|
32
32
|
}
|
|
33
33
|
}
|
package/lib/module/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SyncPrefData","I18n","NativeModules","en","zh","i18n","enableFallback","translations","locale","language","getPrefString","console","log","RNLocalize","_locales$","
|
|
1
|
+
{"version":3,"names":["SyncPrefData","I18n","NativeModules","en","require","zh","i18n","enableFallback","translations","locale","language","getPrefString","console","log","RNLocalize","_locales$","locales","getLocales","systemLanguage","languageCode","__DEV__"],"sources":["i18n.ts"],"sourcesContent":["/**\n * 多语言配置文件\n */\n\nimport { SyncPrefData } from '@norcy/react-native-toolkit';\nimport { I18n } from 'i18n-js';\nimport { NativeModules } from 'react-native';\n\nconst en = require('../locales/en-US.json');\nconst zh = require('../locales/zh-CN.json');\n\nexport const i18n = new I18n();\n\ni18n.enableFallback = true;\n\n// 加载语言包\ni18n.translations = {\n zh,\n en,\n};\ni18n.locale = 'zh';\n\nconst language = SyncPrefData.getPrefString('language');\nconsole.log('i18n init', language);\nif (language === 'en') {\n i18n.locale = 'en';\n} else if (language === 'zh') {\n} else {\n // 空的 或 auto\n if (NativeModules.RNLocalize) {\n const RNLocalize = require('react-native-localize');\n const locales = RNLocalize.getLocales();\n const systemLanguage = locales[0]?.languageCode;\n if (systemLanguage === 'en') {\n i18n.locale = 'en';\n }\n }\n}\n\nif (__DEV__) {\n // i18n.locale = 'en';\n // i18n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import { SyncPrefData } from '@norcy/react-native-toolkit';
|
|
6
6
|
import { I18n } from 'i18n-js';
|
|
7
7
|
import { NativeModules } from 'react-native';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
const en = require('../locales/en-US.json');
|
|
10
|
+
const zh = require('../locales/zh-CN.json');
|
|
10
11
|
|
|
11
12
|
export const i18n = new I18n();
|
|
12
13
|
|
|
@@ -21,16 +22,16 @@ i18n.locale = 'zh';
|
|
|
21
22
|
|
|
22
23
|
const language = SyncPrefData.getPrefString('language');
|
|
23
24
|
console.log('i18n init', language);
|
|
24
|
-
if (language
|
|
25
|
+
if (language === 'en') {
|
|
25
26
|
i18n.locale = 'en';
|
|
26
|
-
} else if (language
|
|
27
|
+
} else if (language === 'zh') {
|
|
27
28
|
} else {
|
|
28
29
|
// 空的 或 auto
|
|
29
30
|
if (NativeModules.RNLocalize) {
|
|
30
31
|
const RNLocalize = require('react-native-localize');
|
|
31
32
|
const locales = RNLocalize.getLocales();
|
|
32
33
|
const systemLanguage = locales[0]?.languageCode;
|
|
33
|
-
if (systemLanguage
|
|
34
|
+
if (systemLanguage === 'en') {
|
|
34
35
|
i18n.locale = 'en';
|
|
35
36
|
}
|
|
36
37
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|