feat(mobile): init i18n support (#3377)
* feat(mobile): init i18n support * get default from device setting * ios native support * inline * update * update
This commit is contained in:
@@ -49,6 +49,31 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
|
||||
ITSAppUsesNonExemptEncryption: false,
|
||||
UIBackgroundModes: ["audio"],
|
||||
LSApplicationQueriesSchemes: ["bilibili", "youtube"],
|
||||
CFBundleAllowMixedLocalizations: true,
|
||||
// apps/mobile/src/@types/constants.ts currentSupportedLanguages
|
||||
CFBundleLocalizations: [
|
||||
"ar-DZ",
|
||||
"ar-IQ",
|
||||
"ar-KW",
|
||||
"ar-MA",
|
||||
"ar-SA",
|
||||
"ar-TN",
|
||||
"de",
|
||||
"en",
|
||||
"es",
|
||||
"fi",
|
||||
"fr",
|
||||
"it",
|
||||
"ja",
|
||||
"ko",
|
||||
"pt",
|
||||
"ru",
|
||||
"tr",
|
||||
"zh-CN",
|
||||
"zh-HK",
|
||||
"zh-TW",
|
||||
],
|
||||
CFBundleDevelopmentRegion: "en",
|
||||
},
|
||||
googleServicesFile: "./build/GoogleService-Info.plist",
|
||||
},
|
||||
|
||||
@@ -18,6 +18,13 @@ config.resolver.nodeModulesPaths = [
|
||||
path.resolve(__dirname, "../../node_modules"),
|
||||
]
|
||||
|
||||
config.resolver.extraNodeModules = {
|
||||
...config.resolver.extraNodeModules,
|
||||
"@locales": path.resolve(__dirname, "../../locales"),
|
||||
}
|
||||
|
||||
config.watchFolders = [...config.watchFolders, path.resolve(__dirname, "../../locales")]
|
||||
|
||||
config.resolver.resolveRequest = (context, moduleName, platform) => {
|
||||
const result = context.resolveRequest(context, moduleName, platform)
|
||||
if (result.type === "sourceFile") {
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"expo-updates": "0.27.4",
|
||||
"expo-web-browser": "14.0.2",
|
||||
"hono": "4.7.5",
|
||||
"i18next": "24.2.3",
|
||||
"immer": "10.1.1",
|
||||
"jotai": "2.12.2",
|
||||
"lru-cache": "11.1.0",
|
||||
@@ -88,6 +89,7 @@
|
||||
"react-dom": "18.3.1",
|
||||
"react-error-boundary": "5.0.0",
|
||||
"react-hook-form": "7.55.0",
|
||||
"react-i18next": "15.4.1",
|
||||
"react-native": "0.77.2",
|
||||
"react-native-awesome-slider": "2.9.0",
|
||||
"react-native-bouncy-checkbox": "4.1.2",
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
export const currentSupportedLanguages = [
|
||||
"ar-DZ",
|
||||
"ar-IQ",
|
||||
"ar-KW",
|
||||
"ar-MA",
|
||||
"ar-SA",
|
||||
"ar-TN",
|
||||
"de",
|
||||
"en",
|
||||
"es",
|
||||
"fi",
|
||||
"fr",
|
||||
"it",
|
||||
"ja",
|
||||
"ko",
|
||||
"pt",
|
||||
"ru",
|
||||
"tr",
|
||||
"zh-CN",
|
||||
"zh-HK",
|
||||
"zh-TW",
|
||||
]
|
||||
|
||||
export const dayjsLocaleImportMap = {
|
||||
["ar-DZ"]: ["ar-dz", () => import("dayjs/locale/ar-dz")],
|
||||
["ar-IQ"]: ["ar-iq", () => import("dayjs/locale/ar-iq")],
|
||||
["ar-KW"]: ["ar-kw", () => import("dayjs/locale/ar-kw")],
|
||||
["ar-MA"]: ["ar-ma", () => import("dayjs/locale/ar-ma")],
|
||||
["ar-SA"]: ["ar-sa", () => import("dayjs/locale/ar-sa")],
|
||||
["ar-TN"]: ["ar-tn", () => import("dayjs/locale/ar-tn")],
|
||||
["de"]: ["de", () => import("dayjs/locale/de")],
|
||||
["es"]: ["es", () => import("dayjs/locale/es")],
|
||||
["fi"]: ["fi", () => import("dayjs/locale/fi")],
|
||||
["fr"]: ["fr", () => import("dayjs/locale/fr")],
|
||||
["it"]: ["it", () => import("dayjs/locale/it")],
|
||||
["ja"]: ["ja", () => import("dayjs/locale/ja")],
|
||||
["ko"]: ["ko", () => import("dayjs/locale/ko")],
|
||||
["pt"]: ["pt", () => import("dayjs/locale/pt")],
|
||||
["ru"]: ["ru", () => import("dayjs/locale/ru")],
|
||||
["tr"]: ["tr", () => import("dayjs/locale/tr")],
|
||||
["zh-CN"]: ["zh-cn", () => import("dayjs/locale/zh-cn")],
|
||||
["zh-HK"]: ["zh-hk", () => import("dayjs/locale/zh-hk")],
|
||||
["zh-TW"]: ["zh-tw", () => import("dayjs/locale/zh-tw")],
|
||||
en: ["en", () => import("dayjs/locale/en")],
|
||||
}
|
||||
|
||||
export const ns = ["app", "common", "lang", "settings", "shortcuts", "errors"] as const
|
||||
export const defaultNS = "app" as const
|
||||
@@ -0,0 +1,324 @@
|
||||
import arDZ from "@locales/app/ar-DZ.json"
|
||||
import arIQ from "@locales/app/ar-IQ.json"
|
||||
import arKW from "@locales/app/ar-KW.json"
|
||||
import arMA from "@locales/app/ar-MA.json"
|
||||
import arSA from "@locales/app/ar-SA.json"
|
||||
import arTN from "@locales/app/ar-TN.json"
|
||||
import de from "@locales/app/de.json"
|
||||
import en from "@locales/app/en.json"
|
||||
import es from "@locales/app/es.json"
|
||||
import fi from "@locales/app/fi.json"
|
||||
import fr from "@locales/app/fr.json"
|
||||
import it from "@locales/app/it.json"
|
||||
import ja from "@locales/app/ja.json"
|
||||
import ko from "@locales/app/ko.json"
|
||||
import pt from "@locales/app/pt.json"
|
||||
import ru from "@locales/app/ru.json"
|
||||
import tr from "@locales/app/tr.json"
|
||||
import zhCN from "@locales/app/zh-CN.json"
|
||||
import zhHK from "@locales/app/zh-HK.json"
|
||||
import zhTW from "@locales/app/zh-TW.json"
|
||||
import common_ardz from "@locales/common/ar-DZ.json"
|
||||
import common_ariq from "@locales/common/ar-IQ.json"
|
||||
import common_arkw from "@locales/common/ar-KW.json"
|
||||
import common_arma from "@locales/common/ar-MA.json"
|
||||
import common_arsa from "@locales/common/ar-SA.json"
|
||||
import common_artn from "@locales/common/ar-TN.json"
|
||||
import common_de from "@locales/common/de.json"
|
||||
import common_en from "@locales/common/en.json"
|
||||
import common_es from "@locales/common/es.json"
|
||||
import common_fi from "@locales/common/fi.json"
|
||||
import common_fr from "@locales/common/fr.json"
|
||||
import common_it from "@locales/common/it.json"
|
||||
import common_ja from "@locales/common/ja.json"
|
||||
import common_ko from "@locales/common/ko.json"
|
||||
import common_pt from "@locales/common/pt.json"
|
||||
import common_ru from "@locales/common/ru.json"
|
||||
import common_tr from "@locales/common/tr.json"
|
||||
import common_zhCN from "@locales/common/zh-CN.json"
|
||||
import common_zhHK from "@locales/common/zh-HK.json"
|
||||
import common_zhTW from "@locales/common/zh-TW.json"
|
||||
import errors_de from "@locales/errors/de.json"
|
||||
import errors_en from "@locales/errors/en.json"
|
||||
import errors_fr from "@locales/errors/fr.json"
|
||||
import errors_ja from "@locales/errors/ja.json"
|
||||
import errors_ko from "@locales/errors/ko.json"
|
||||
import errors_ru from "@locales/errors/ru.json"
|
||||
import errors_tr from "@locales/errors/tr.json"
|
||||
import errors_zhCN from "@locales/errors/zh-CN.json"
|
||||
import errors_zhHK from "@locales/errors/zh-HK.json"
|
||||
import errors_zhTW from "@locales/errors/zh-TW.json"
|
||||
import external_arDZ from "@locales/external/ar-DZ.json"
|
||||
import external_arIQ from "@locales/external/ar-IQ.json"
|
||||
import external_arKW from "@locales/external/ar-kw.json"
|
||||
import external_arMA from "@locales/external/ar-MA.json"
|
||||
import external_arSA from "@locales/external/ar-SA.json"
|
||||
import external_arTN from "@locales/external/ar-TN.json"
|
||||
import external_de from "@locales/external/de.json"
|
||||
import external_en from "@locales/external/en.json"
|
||||
import external_es from "@locales/external/es.json"
|
||||
import external_fi from "@locales/external/fi.json"
|
||||
import external_fr from "@locales/external/fr.json"
|
||||
import external_it from "@locales/external/it.json"
|
||||
import external_ja from "@locales/external/ja.json"
|
||||
import external_ko from "@locales/external/ko.json"
|
||||
import external_pt from "@locales/external/pt.json"
|
||||
import external_ru from "@locales/external/ru.json"
|
||||
import external_tr from "@locales/external/tr.json"
|
||||
import external_zhCN from "@locales/external/zh-CN.json"
|
||||
import external_zhHK from "@locales/external/zh-HK.json"
|
||||
import external_zhTW from "@locales/external/zh-TW.json"
|
||||
import lang_ardz from "@locales/lang/ar-DZ.json"
|
||||
import lang_ariq from "@locales/lang/ar-IQ.json"
|
||||
import lang_arkw from "@locales/lang/ar-KW.json"
|
||||
import lang_arma from "@locales/lang/ar-MA.json"
|
||||
import lang_arsa from "@locales/lang/ar-SA.json"
|
||||
import lang_artn from "@locales/lang/ar-TN.json"
|
||||
import lang_de from "@locales/lang/de.json"
|
||||
import lang_en from "@locales/lang/en.json"
|
||||
import lang_es from "@locales/lang/es.json"
|
||||
import lang_fi from "@locales/lang/fi.json"
|
||||
import lang_fr from "@locales/lang/fr.json"
|
||||
import lang_it from "@locales/lang/it.json"
|
||||
import lang_ja from "@locales/lang/ja.json"
|
||||
import lang_ko from "@locales/lang/ko.json"
|
||||
import lang_pt from "@locales/lang/pt.json"
|
||||
import lang_ru from "@locales/lang/ru.json"
|
||||
import lang_tr from "@locales/lang/tr.json"
|
||||
import lang_zhCN from "@locales/lang/zh-CN.json"
|
||||
import lang_zhHK from "@locales/lang/zh-HK.json"
|
||||
import lang_zhTW from "@locales/lang/zh-TW.json"
|
||||
import settings_arDZ from "@locales/settings/ar-DZ.json"
|
||||
import settings_arIQ from "@locales/settings/ar-IQ.json"
|
||||
import settings_arKW from "@locales/settings/ar-KW.json"
|
||||
import settings_arMA from "@locales/settings/ar-MA.json"
|
||||
import settings_arSA from "@locales/settings/ar-SA.json"
|
||||
import settings_arTN from "@locales/settings/ar-TN.json"
|
||||
import settings_de from "@locales/settings/de.json"
|
||||
import settings_en from "@locales/settings/en.json"
|
||||
import settings_es from "@locales/settings/es.json"
|
||||
import settings_fi from "@locales/settings/fi.json"
|
||||
import settings_fr from "@locales/settings/fr.json"
|
||||
import settings_it from "@locales/settings/it.json"
|
||||
import settings_ja from "@locales/settings/ja.json"
|
||||
import settings_ko from "@locales/settings/ko.json"
|
||||
import settings_pt from "@locales/settings/pt.json"
|
||||
import settings_ru from "@locales/settings/ru.json"
|
||||
import settings_tr from "@locales/settings/tr.json"
|
||||
import settings_zhCN from "@locales/settings/zh-CN.json"
|
||||
import settings_zhHK from "@locales/settings/zh-HK.json"
|
||||
import settings_zhTW from "@locales/settings/zh-TW.json"
|
||||
import shortcuts_arDZ from "@locales/shortcuts/ar-DZ.json"
|
||||
import shortcuts_arIQ from "@locales/shortcuts/ar-IQ.json"
|
||||
import shortcuts_arKW from "@locales/shortcuts/ar-KW.json"
|
||||
import shortcuts_arMA from "@locales/shortcuts/ar-MA.json"
|
||||
import shortcuts_arSA from "@locales/shortcuts/ar-SA.json"
|
||||
import shortcuts_arTN from "@locales/shortcuts/ar-TN.json"
|
||||
import shortcuts_de from "@locales/shortcuts/de.json"
|
||||
import shortcuts_en from "@locales/shortcuts/en.json"
|
||||
import shortcuts_es from "@locales/shortcuts/es.json"
|
||||
import shortcuts_fi from "@locales/shortcuts/fi.json"
|
||||
import shortcuts_fr from "@locales/shortcuts/fr.json"
|
||||
import shortcuts_it from "@locales/shortcuts/it.json"
|
||||
import shortcuts_ja from "@locales/shortcuts/ja.json"
|
||||
import shortcuts_ko from "@locales/shortcuts/ko.json"
|
||||
import shortcuts_pt from "@locales/shortcuts/pt.json"
|
||||
import shortcuts_ru from "@locales/shortcuts/ru.json"
|
||||
import shortcuts_tr from "@locales/shortcuts/tr.json"
|
||||
import shortcuts_zhCN from "@locales/shortcuts/zh-CN.json"
|
||||
import shortcuts_zhHK from "@locales/shortcuts/zh-HK.json"
|
||||
import shortcuts_zhTW from "@locales/shortcuts/zh-TW.json"
|
||||
|
||||
// @keep-sorted
|
||||
export const defaultResources = {
|
||||
// @keep-sorted
|
||||
"ar-DZ": {
|
||||
app: arDZ,
|
||||
common: common_ardz,
|
||||
external: external_arDZ,
|
||||
lang: lang_ardz,
|
||||
settings: settings_arDZ,
|
||||
shortcuts: shortcuts_arDZ,
|
||||
},
|
||||
// @keep-sorted
|
||||
"ar-IQ": {
|
||||
app: arIQ,
|
||||
common: common_ariq,
|
||||
external: external_arIQ,
|
||||
lang: lang_ariq,
|
||||
settings: settings_arIQ,
|
||||
shortcuts: shortcuts_arIQ,
|
||||
},
|
||||
// @keep-sorted
|
||||
"ar-KW": {
|
||||
app: arKW,
|
||||
common: common_arkw,
|
||||
external: external_arKW,
|
||||
lang: lang_arkw,
|
||||
settings: settings_arKW,
|
||||
shortcuts: shortcuts_arKW,
|
||||
},
|
||||
// @keep-sorted
|
||||
"ar-MA": {
|
||||
app: arMA,
|
||||
common: common_arma,
|
||||
external: external_arMA,
|
||||
lang: lang_arma,
|
||||
settings: settings_arMA,
|
||||
shortcuts: shortcuts_arMA,
|
||||
},
|
||||
// @keep-sorted
|
||||
"ar-SA": {
|
||||
app: arSA,
|
||||
common: common_arsa,
|
||||
external: external_arSA,
|
||||
lang: lang_arsa,
|
||||
settings: settings_arSA,
|
||||
shortcuts: shortcuts_arSA,
|
||||
},
|
||||
// @keep-sorted
|
||||
"ar-TN": {
|
||||
app: arTN,
|
||||
common: common_artn,
|
||||
external: external_arTN,
|
||||
lang: lang_artn,
|
||||
settings: settings_arTN,
|
||||
shortcuts: shortcuts_arTN,
|
||||
},
|
||||
// @keep-sorted
|
||||
"zh-CN": {
|
||||
app: zhCN,
|
||||
common: common_zhCN,
|
||||
errors: errors_zhCN,
|
||||
external: external_zhCN,
|
||||
lang: lang_zhCN,
|
||||
settings: settings_zhCN,
|
||||
shortcuts: shortcuts_zhCN,
|
||||
},
|
||||
// @keep-sorted
|
||||
"zh-HK": {
|
||||
app: zhHK,
|
||||
common: common_zhHK,
|
||||
errors: errors_zhHK,
|
||||
external: external_zhHK,
|
||||
lang: lang_zhHK,
|
||||
settings: settings_zhHK,
|
||||
shortcuts: shortcuts_zhHK,
|
||||
},
|
||||
// @keep-sorted
|
||||
"zh-TW": {
|
||||
app: zhTW,
|
||||
common: common_zhTW,
|
||||
errors: errors_zhTW,
|
||||
external: external_zhTW,
|
||||
lang: lang_zhTW,
|
||||
settings: settings_zhTW,
|
||||
shortcuts: shortcuts_zhTW,
|
||||
},
|
||||
// @keep-sorted
|
||||
de: {
|
||||
app: de,
|
||||
common: common_de,
|
||||
errors: errors_de,
|
||||
external: external_de,
|
||||
lang: lang_de,
|
||||
settings: settings_de,
|
||||
shortcuts: shortcuts_de,
|
||||
},
|
||||
// @keep-sorted
|
||||
en: {
|
||||
app: en,
|
||||
common: common_en,
|
||||
errors: errors_en,
|
||||
external: external_en,
|
||||
lang: lang_en,
|
||||
settings: settings_en,
|
||||
shortcuts: shortcuts_en,
|
||||
},
|
||||
// @keep-sorted
|
||||
es: {
|
||||
app: es,
|
||||
common: common_es,
|
||||
external: external_es,
|
||||
lang: lang_es,
|
||||
settings: settings_es,
|
||||
shortcuts: shortcuts_es,
|
||||
},
|
||||
// @keep-sorted
|
||||
fi: {
|
||||
app: fi,
|
||||
common: common_fi,
|
||||
external: external_fi,
|
||||
lang: lang_fi,
|
||||
settings: settings_fi,
|
||||
shortcuts: shortcuts_fi,
|
||||
},
|
||||
// @keep-sorted
|
||||
fr: {
|
||||
app: fr,
|
||||
common: common_fr,
|
||||
errors: errors_fr,
|
||||
external: external_fr,
|
||||
lang: lang_fr,
|
||||
settings: settings_fr,
|
||||
shortcuts: shortcuts_fr,
|
||||
},
|
||||
// @keep-sorted
|
||||
it: {
|
||||
app: it,
|
||||
common: common_it,
|
||||
external: external_it,
|
||||
lang: lang_it,
|
||||
settings: settings_it,
|
||||
shortcuts: shortcuts_it,
|
||||
},
|
||||
// @keep-sorted
|
||||
ja: {
|
||||
app: ja,
|
||||
common: common_ja,
|
||||
errors: errors_ja,
|
||||
external: external_ja,
|
||||
lang: lang_ja,
|
||||
settings: settings_ja,
|
||||
shortcuts: shortcuts_ja,
|
||||
},
|
||||
// @keep-sorted
|
||||
ko: {
|
||||
app: ko,
|
||||
common: common_ko,
|
||||
errors: errors_ko,
|
||||
external: external_ko,
|
||||
lang: lang_ko,
|
||||
settings: settings_ko,
|
||||
shortcuts: shortcuts_ko,
|
||||
},
|
||||
// @keep-sorted
|
||||
pt: {
|
||||
app: pt,
|
||||
common: common_pt,
|
||||
external: external_pt,
|
||||
lang: lang_pt,
|
||||
settings: settings_pt,
|
||||
shortcuts: shortcuts_pt,
|
||||
},
|
||||
// @keep-sorted
|
||||
ru: {
|
||||
app: ru,
|
||||
common: common_ru,
|
||||
errors: errors_ru,
|
||||
external: external_ru,
|
||||
lang: lang_ru,
|
||||
settings: settings_ru,
|
||||
shortcuts: shortcuts_ru,
|
||||
},
|
||||
// @keep-sorted
|
||||
tr: {
|
||||
app: tr,
|
||||
common: common_tr,
|
||||
errors: errors_tr,
|
||||
external: external_tr,
|
||||
lang: lang_tr,
|
||||
settings: settings_tr,
|
||||
shortcuts: shortcuts_tr,
|
||||
},
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import type { defaultNS, ns } from "./constants"
|
||||
import type { defaultResources as resources } from "./default-resource"
|
||||
|
||||
declare module "i18next" {
|
||||
interface CustomTypeOptions {
|
||||
// ns: ["app", "common", "external", "lang", "settings", "shortcuts"]
|
||||
ns: typeof ns
|
||||
resources: (typeof resources)["en"]
|
||||
defaultNS: typeof defaultNS
|
||||
// if you see an error like: "Argument of type 'DefaultTFuncReturn' is not assignable to parameter of type xyz"
|
||||
// set returnNull to false (and also in the i18next init options)
|
||||
// returnNull: false;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { GeneralSettings } from "@/src/interfaces/settings/general"
|
||||
import { getDeviceLanguage } from "@/src/lib/i18n"
|
||||
|
||||
import { createSettingAtom } from "./internal/helper"
|
||||
|
||||
const createDefaultSettings = (): GeneralSettings => ({
|
||||
// App
|
||||
|
||||
language: "en",
|
||||
language: getDeviceLanguage(),
|
||||
|
||||
// Action
|
||||
summary: false,
|
||||
translation: false,
|
||||
actionLanguage: "zh-CN",
|
||||
actionLanguage: getDeviceLanguage(),
|
||||
|
||||
// Data control
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ interface SelectProps<T> {
|
||||
|
||||
value: T
|
||||
onValueChange: (value: T) => void
|
||||
displayValue?: string
|
||||
|
||||
wrapperClassName?: string
|
||||
wrapperStyle?: StyleProp<ViewStyle>
|
||||
@@ -24,6 +25,7 @@ export function Select<T>({
|
||||
options,
|
||||
value,
|
||||
onValueChange,
|
||||
displayValue,
|
||||
wrapperClassName,
|
||||
wrapperStyle,
|
||||
label,
|
||||
@@ -62,7 +64,7 @@ export function Select<T>({
|
||||
ellipsizeMode="middle"
|
||||
numberOfLines={1}
|
||||
>
|
||||
{valueToLabelMap.get(currentValue) || "Select"}
|
||||
{displayValue || valueToLabelMap.get(currentValue) || "Select"}
|
||||
</Text>
|
||||
<View className="ml-auto shrink-0 pl-1">
|
||||
<MingcuteDownLineIcon color={accentColor} height={18} width={18} />
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { getLocales } from "expo-localization"
|
||||
import i18n from "i18next"
|
||||
import { initReactI18next } from "react-i18next"
|
||||
|
||||
import { currentSupportedLanguages, defaultNS, ns } from "@/src/@types/constants"
|
||||
import { defaultResources } from "@/src/@types/default-resource"
|
||||
|
||||
import { getGeneralSettings } from "../atoms/settings/general"
|
||||
|
||||
const fallbackLanguage = "en"
|
||||
|
||||
export async function initializeI18n() {
|
||||
return i18n.use(initReactI18next).init({
|
||||
ns,
|
||||
defaultNS,
|
||||
resources: defaultResources,
|
||||
|
||||
lng: getGeneralSettings().language,
|
||||
fallbackLng: fallbackLanguage,
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function getDeviceLanguage() {
|
||||
const locale = getLocales()[0]
|
||||
if (!locale) {
|
||||
return fallbackLanguage
|
||||
}
|
||||
|
||||
const { languageCode, languageRegionCode } = locale
|
||||
const possibleDeviceLanguage = [
|
||||
languageCode,
|
||||
languageRegionCode,
|
||||
languageCode && languageRegionCode ? `${languageCode}-${languageRegionCode}` : null,
|
||||
].filter((i) => i !== null)
|
||||
|
||||
return (
|
||||
possibleDeviceLanguage.find((lang) => currentSupportedLanguages.includes(lang)) ||
|
||||
fallbackLanguage
|
||||
)
|
||||
}
|
||||
+40
-31
@@ -3,12 +3,14 @@ import "./global.css"
|
||||
import { registerRootComponent } from "expo"
|
||||
import { Image } from "expo-image"
|
||||
import { cssInterop } from "nativewind"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { enableFreeze } from "react-native-screens"
|
||||
|
||||
import { App } from "./App"
|
||||
import { BottomTabProvider } from "./components/layouts/tabbar/BottomTabProvider"
|
||||
import { BottomTabs } from "./components/layouts/tabbar/BottomTabs"
|
||||
import { initializeApp } from "./initialize"
|
||||
import { initializeI18n } from "./lib/i18n"
|
||||
import { TabBarPortal } from "./lib/navigation/bottom-tab/TabBarPortal"
|
||||
import { TabRoot } from "./lib/navigation/bottom-tab/TabRoot"
|
||||
import { TabScreen } from "./lib/navigation/bottom-tab/TabScreen"
|
||||
@@ -26,37 +28,44 @@ cssInterop(Image, { className: "style" })
|
||||
initializeApp()
|
||||
|
||||
registerSitemap()
|
||||
registerRootComponent(() => (
|
||||
<RootProviders>
|
||||
<BottomTabProvider>
|
||||
<RootStackNavigation
|
||||
headerConfig={{
|
||||
hidden: true,
|
||||
}}
|
||||
>
|
||||
<App>
|
||||
<TabRoot>
|
||||
<TabScreen title="Home">
|
||||
<IndexTabScreen />
|
||||
</TabScreen>
|
||||
initializeI18n().then(() => {
|
||||
registerRootComponent(RootComponent)
|
||||
})
|
||||
|
||||
<TabScreen title="Subscriptions">
|
||||
<SubscriptionsTabScreen />
|
||||
</TabScreen>
|
||||
function RootComponent() {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<RootProviders>
|
||||
<BottomTabProvider>
|
||||
<RootStackNavigation
|
||||
headerConfig={{
|
||||
hidden: true,
|
||||
}}
|
||||
>
|
||||
<App>
|
||||
<TabRoot>
|
||||
<TabScreen title={t("tabs.home")}>
|
||||
<IndexTabScreen />
|
||||
</TabScreen>
|
||||
|
||||
<TabScreen title="Discover">
|
||||
<DiscoverTabScreen />
|
||||
</TabScreen>
|
||||
<TabScreen title="Settings">
|
||||
<SettingsTabScreen />
|
||||
</TabScreen>
|
||||
<TabScreen title={t("tabs.subscriptions")}>
|
||||
<SubscriptionsTabScreen />
|
||||
</TabScreen>
|
||||
|
||||
<TabBarPortal>
|
||||
<BottomTabs />
|
||||
</TabBarPortal>
|
||||
</TabRoot>
|
||||
</App>
|
||||
</RootStackNavigation>
|
||||
</BottomTabProvider>
|
||||
</RootProviders>
|
||||
))
|
||||
<TabScreen title={t("tabs.discover")}>
|
||||
<DiscoverTabScreen />
|
||||
</TabScreen>
|
||||
<TabScreen title={t("tabs.settings")}>
|
||||
<SettingsTabScreen />
|
||||
</TabScreen>
|
||||
|
||||
<TabBarPortal>
|
||||
<BottomTabs />
|
||||
</TabBarPortal>
|
||||
</TabRoot>
|
||||
</App>
|
||||
</RootStackNavigation>
|
||||
</BottomTabProvider>
|
||||
</RootProviders>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { LANGUAGE_MAP } from "@follow/shared"
|
||||
import { useLocales } from "expo-localization"
|
||||
import i18next from "i18next"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Text, View } from "react-native"
|
||||
|
||||
import { setGeneralSetting, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
@@ -17,11 +18,38 @@ import {
|
||||
import { Switch } from "@/src/components/ui/switch/Switch"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
|
||||
function LanguageSelect({ settingKey }: { settingKey: "language" | "actionLanguage" }) {
|
||||
const { t } = useTranslation("lang")
|
||||
const languageMapWithTranslation = Object.entries(LANGUAGE_MAP).map(([key, { label }]) => ({
|
||||
label: `${t(`langs.${key}` as any)} (${label})`,
|
||||
value: key,
|
||||
}))
|
||||
const language = useGeneralSettingKey(settingKey)
|
||||
|
||||
return (
|
||||
<GroupedInsetListBaseCell>
|
||||
<Text className="text-label">Language</Text>
|
||||
|
||||
<View className="w-[150px]">
|
||||
<Select
|
||||
value={language}
|
||||
onValueChange={(value) => {
|
||||
setGeneralSetting(settingKey, value)
|
||||
if (settingKey === "language") {
|
||||
i18next.changeLanguage(value)
|
||||
}
|
||||
}}
|
||||
displayValue={t(`langs.${language}` as any)}
|
||||
options={languageMapWithTranslation}
|
||||
/>
|
||||
</View>
|
||||
</GroupedInsetListBaseCell>
|
||||
)
|
||||
}
|
||||
|
||||
export const GeneralScreen: NavigationControllerView = () => {
|
||||
const locales = useLocales()
|
||||
const translation = useGeneralSettingKey("translation")
|
||||
const summary = useGeneralSettingKey("summary")
|
||||
const actionLanguage = useGeneralSettingKey("actionLanguage")
|
||||
const autoGroup = useGeneralSettingKey("autoGroup")
|
||||
const showUnreadOnLaunch = useGeneralSettingKey("unreadOnly")
|
||||
// const groupByDate = useGeneralSettingKey("groupByDate")
|
||||
@@ -37,11 +65,7 @@ export const GeneralScreen: NavigationControllerView = () => {
|
||||
|
||||
<GroupedInsetListSectionHeader label="Language" />
|
||||
<GroupedInsetListCard>
|
||||
<GroupedInsetListBaseCell>
|
||||
<Text className="text-label">Language</Text>
|
||||
|
||||
<Text className="text-label">{(locales[0]?.languageTag, "English")}</Text>
|
||||
</GroupedInsetListBaseCell>
|
||||
<LanguageSelect settingKey="language" />
|
||||
</GroupedInsetListCard>
|
||||
|
||||
{/* Content Behavior */}
|
||||
@@ -65,19 +89,7 @@ export const GeneralScreen: NavigationControllerView = () => {
|
||||
}}
|
||||
/>
|
||||
</GroupedInsetListCell>
|
||||
<GroupedInsetListBaseCell>
|
||||
<Text className="text-label">Language</Text>
|
||||
|
||||
<View className="w-[150px]">
|
||||
<Select
|
||||
value={actionLanguage}
|
||||
onValueChange={(value) => {
|
||||
setGeneralSetting("actionLanguage", value)
|
||||
}}
|
||||
options={Object.values(LANGUAGE_MAP)}
|
||||
/>
|
||||
</View>
|
||||
</GroupedInsetListBaseCell>
|
||||
<LanguageSelect settingKey="actionLanguage" />
|
||||
</GroupedInsetListCard>
|
||||
|
||||
{/* Subscriptions */}
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"module": "commonjs",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
"@/*": ["./*"],
|
||||
"@locales/*": ["../../locales/*"]
|
||||
},
|
||||
"jsx": "preserve"
|
||||
},
|
||||
|
||||
@@ -379,6 +379,10 @@
|
||||
"sync_indicator.disabled": "Due to security reasons, sync is disabled.",
|
||||
"sync_indicator.offline": "Offline",
|
||||
"sync_indicator.synced": "Synced with server",
|
||||
"tabs.discover": "Discover",
|
||||
"tabs.home": "Home",
|
||||
"tabs.settings": "Settings",
|
||||
"tabs.subscriptions": "Subscriptions",
|
||||
"tip_modal.amount": "Amount",
|
||||
"tip_modal.claim_feed": "Claim this feed",
|
||||
"tip_modal.create_wallet": "Create For Free",
|
||||
|
||||
@@ -379,6 +379,10 @@
|
||||
"sync_indicator.disabled": "出于安全原因,已禁用同步",
|
||||
"sync_indicator.offline": "离线",
|
||||
"sync_indicator.synced": "已同步至云端",
|
||||
"tabs.discover": "发现",
|
||||
"tabs.home": "首页",
|
||||
"tabs.settings": "设置",
|
||||
"tabs.subscriptions": "订阅",
|
||||
"tip_modal.amount": "数量",
|
||||
"tip_modal.claim_feed": "认证此订阅源",
|
||||
"tip_modal.create_wallet": "免费创建",
|
||||
|
||||
Generated
+11
-4
@@ -663,7 +663,7 @@ importers:
|
||||
version: 4.6.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
react-i18next:
|
||||
specifier: 15.4.1
|
||||
version: 15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
version: 15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@6.0.5))(react@18.3.1)
|
||||
react-intersection-observer:
|
||||
specifier: 9.16.0
|
||||
version: 9.16.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
@@ -932,6 +932,9 @@ importers:
|
||||
hono:
|
||||
specifier: 4.7.5
|
||||
version: 4.7.5(patch_hash=5c74c2d2afaa5880c13d75458dd26c84da568851691b1fb6de6d877c29936d05)
|
||||
i18next:
|
||||
specifier: 24.2.3
|
||||
version: 24.2.3(typescript@5.8.2)
|
||||
immer:
|
||||
specifier: 10.1.1
|
||||
version: 10.1.1(patch_hash=594c60b929bc0a3b56576f1a1787da1aec2a1fba51e3c21ec09c0ed38280af6c)
|
||||
@@ -965,6 +968,9 @@ importers:
|
||||
react-hook-form:
|
||||
specifier: 7.55.0
|
||||
version: 7.55.0(react@18.3.1)
|
||||
react-i18next:
|
||||
specifier: 15.4.1
|
||||
version: 15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@6.0.5))(react@18.3.1)
|
||||
react-native:
|
||||
specifier: 0.77.2
|
||||
version: 0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@6.0.5)
|
||||
@@ -1159,7 +1165,7 @@ importers:
|
||||
version: 4.6.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
react-i18next:
|
||||
specifier: 15.4.1
|
||||
version: 15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
version: 15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@6.0.5))(react@18.3.1)
|
||||
react-photo-view:
|
||||
specifier: 1.2.7
|
||||
version: 1.2.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
@@ -1400,7 +1406,7 @@ importers:
|
||||
version: 7.55.0(react@18.3.1)
|
||||
react-i18next:
|
||||
specifier: 15.4.1
|
||||
version: 15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
version: 15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@6.0.5))(react@18.3.1)
|
||||
rehype-infer-description-meta:
|
||||
specifier: 2.0.0
|
||||
version: 2.0.0
|
||||
@@ -29188,7 +29194,7 @@ snapshots:
|
||||
react: 18.3.1
|
||||
react-dom: 18.3.1(react@18.3.1)
|
||||
|
||||
react-i18next@15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||
react-i18next@15.4.1(i18next@24.2.3(typescript@5.8.2))(react-dom@18.3.1(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@6.0.5))(react@18.3.1):
|
||||
dependencies:
|
||||
'@babel/runtime': 7.27.0
|
||||
html-parse-stringify: 3.0.1
|
||||
@@ -29196,6 +29202,7 @@ snapshots:
|
||||
react: 18.3.1
|
||||
optionalDependencies:
|
||||
react-dom: 18.3.1(react@18.3.1)
|
||||
react-native: 0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@6.0.5)
|
||||
|
||||
react-intersection-observer@9.16.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user