native获取语言环境,根据是否debug调试判断
This commit is contained in:
parent
ce835e72a1
commit
92af3839f9
|
|
@ -2,7 +2,8 @@ import { Platform } from 'react-native';
|
|||
import { getLocales } from 'react-native-localize';
|
||||
import { getDeviceId } from 'react-native-device-info';
|
||||
export async function getEnv() {
|
||||
const language = getLocales()[0].languageTag;
|
||||
const isDebuggingEnabled = typeof atob !== 'undefined';
|
||||
const language = !isDebuggingEnabled ? getLocales()[0].languageTag : navigator.language;
|
||||
const deviceId = getDeviceId();
|
||||
const fullEnv = {
|
||||
...Platform,
|
||||
|
|
@ -13,7 +14,9 @@ export async function getEnv() {
|
|||
const briefEnv = {
|
||||
brand: fullEnv.constants.Brand,
|
||||
model: fullEnv.constants.Model,
|
||||
system: `${fullEnv.OS}/${fullEnv.constants.Version || fullEnv.constants.osVersion}/${language}`,
|
||||
system: `${fullEnv.OS}/${
|
||||
fullEnv.constants.Version || fullEnv.constants.osVersion
|
||||
}/${language}`,
|
||||
};
|
||||
return {
|
||||
fullEnv,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ const react_native_1 = require("react-native");
|
|||
const react_native_localize_1 = require("react-native-localize");
|
||||
const react_native_device_info_1 = require("react-native-device-info");
|
||||
async function getEnv() {
|
||||
const language = (0, react_native_localize_1.getLocales)()[0].languageTag;
|
||||
const isDebuggingEnabled = typeof atob !== 'undefined';
|
||||
const language = !isDebuggingEnabled ? (0, react_native_localize_1.getLocales)()[0].languageTag : navigator.language;
|
||||
const deviceId = (0, react_native_device_info_1.getDeviceId)();
|
||||
const fullEnv = {
|
||||
...react_native_1.Platform,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ import { getLocales } from 'react-native-localize';
|
|||
import { getDeviceId } from 'react-native-device-info';
|
||||
|
||||
export async function getEnv() {
|
||||
const language = getLocales()[0].languageTag;
|
||||
const isDebuggingEnabled = typeof atob !== 'undefined';
|
||||
const language = !isDebuggingEnabled ? getLocales()[0].languageTag : navigator.language;
|
||||
const deviceId = getDeviceId();
|
||||
const fullEnv = {
|
||||
...Platform,
|
||||
|
|
|
|||
Loading…
Reference in New Issue