Graphql I18下一步如何检测存储在数据库中的语言首选项?
我正在开发一个带有Graphql I18下一步如何检测存储在数据库中的语言首选项?,graphql,react-i18next,Graphql,React I18next,我正在开发一个带有react-i18next的react原生应用程序,我想实现以下两件事 检测存储在后端的用户语言首选项并使用它 检测设备的语言,并在后端没有语言首选项数据时使用它 我已经实现了2。如下所示,但不是1。。 我怎么做? 我使用的是Prisma,Graphql import i18n from 'i18next'; import { NativeModules, Platform } from 'react-native'; import { initReactI18next } f
react-i18next
的react原生应用程序,我想实现以下两件事
Prisma
,Graphql
import i18n from 'i18next';
import { NativeModules, Platform } from 'react-native';
import { initReactI18next } from 'react-i18next';
let locale;
if (Platform.OS === 'ios') {
locale = NativeModules.SettingsManager.settings.AppleLocale;
} else {
locale = NativeModules.I18nManager.localeIdentifier;
}
if (!locale) {
locale = 'en';
}
let language = 'en';
if (locale === 'ja_JP') {
language = 'ja';
} else if (locale.includes('zh')) {
language = 'cn';
} else {
language = 'en';
}
i18n
.use(initReactI18next)
.init({
resources,
fallbackLng: 'en',
lng: language,
keySeparator: true,
interpolation: {
escapeValue: false,
},
});