diff --git a/app/(tabs)/rights.tsx b/app/(tabs)/rights.tsx index 8552a55..f175b94 100644 --- a/app/(tabs)/rights.tsx +++ b/app/(tabs)/rights.tsx @@ -9,12 +9,14 @@ import { ThemedText } from '@/components/ThemedText'; import { fetchApi } from '@/lib/server-api-util'; import { useLocalSearchParams, useRouter } from "expo-router"; import { useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; import { Image, ScrollView, StyleSheet, TouchableOpacity, View } from 'react-native'; import { useSafeAreaInsets } from "react-native-safe-area-context"; export default function Rights() { const insets = useSafeAreaInsets(); const router = useRouter(); + const { t } = useTranslation(); // 获取路由参数 const { credit } = useLocalSearchParams<{ credit: string; @@ -53,7 +55,7 @@ export default function Rights() { - Subscription + {t('rights.title', { ns: 'personal' })} 123 @@ -67,7 +69,7 @@ export default function Rights() { - Purchase + {t('rights.purchase', { ns: 'personal' })} @@ -85,13 +87,13 @@ export default function Rights() { onPress={() => { setUserType("normal") }} style={[styles.switchButtonItem, { backgroundColor: userType === 'normal' ? "#FFB645" : "#fff", borderColor: userType === 'normal' ? "#FFB645" : "#E2793F" }]} > - Free + {t('rights.free', { ns: 'personal' })} { setUserType("premium") }} style={[styles.switchButtonItem, { backgroundColor: userType === 'premium' ? "#E2793F" : "#fff", borderColor: userType === 'premium' ? "#E2793F" : "#E2793F" }]} > - Pro + {t('rights.premium', { ns: 'personal' })} {/* 普通权益 */} @@ -124,7 +126,7 @@ export default function Rights() { activeOpacity={0.8} > - Subscribe Yearly + {t('rights.subscribe', { ns: 'personal' })} - Terms • Privacy + {t('rights.terms', { ns: 'personal' })} diff --git a/app/(tabs)/setting.tsx b/app/(tabs)/setting.tsx index 9573118..cc9cdfb 100644 --- a/app/(tabs)/setting.tsx +++ b/app/(tabs)/setting.tsx @@ -16,7 +16,7 @@ import * as Location from 'expo-location'; import { useRouter } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Linking, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; +import { Linking, Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { useSafeAreaInsets } from "react-native-safe-area-context"; const Setting = (props: { modalVisible: boolean, setModalVisible: (visible: boolean) => void, userInfo: User }) => { @@ -98,11 +98,9 @@ const Setting = (props: { modalVisible: boolean, setModalVisible: (visible: bool try { // 1. 首先检查当前权限状态 -- 获取当前的位置权限 let currentStatus = await getLocationPermission(); - console.log('当前权限状态:', currentStatus); // 2. 如果没有权限,则跳过获取位置 if (!currentStatus) { - console.log('没有权限,跳过获取位置') return; // const newStatus = await requestLocationPermission(); // setLocationEnabled(newStatus); @@ -117,16 +115,14 @@ const Setting = (props: { modalVisible: boolean, setModalVisible: (visible: bool // 3. 确保位置服务已启用 const isEnabled = await Location.hasServicesEnabledAsync(); if (!isEnabled) { - alert('请先启用位置服务'); + alert(t('permission.locationPermissionRequired', { ns: 'common' })); return; } - console.log('位置服务已启用'); // 4. 获取当前位置 const location = await Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.High, // 使用高精度 timeInterval: 10000, // 可选:最大等待时间(毫秒) }); - console.log('位置:', location); // 地理位置逆编码 const address = await reverseGeocode(location.coords.latitude, location.coords.longitude); @@ -137,12 +133,10 @@ const Setting = (props: { modalVisible: boolean, setModalVisible: (visible: bool return location; } catch (error: any) { - if (error.code === 'PERMISSION_DENIED' || error.code === 'PERMISSION_DENIED_ERROR') { - alert('位置权限被拒绝,请在设置中启用位置服务'); - } else if (error.code === 'TIMEOUT') { - alert('获取位置超时,请检查网络和位置服务'); + if (error.code === 'TIMEOUT') { + alert(t('permission.timeout', { ns: 'common' })); } else { - alert(`无法获取您的位置: ${error.message || '未知错误'}`); + alert(t('permission.notLocation', { ns: 'common' }) + error.message || t('permission.notError', { ns: 'common' })); } throw error; // 重新抛出错误以便上层处理 } finally { @@ -173,17 +167,14 @@ const Setting = (props: { modalVisible: boolean, setModalVisible: (visible: bool if (modalVisible) { // 位置权限 getLocationPermission().then((res: boolean | ((prevState: boolean) => boolean)) => { - console.log('位置权限:', res); setLocationEnabled(res); }) // 媒体库权限 getPermissions().then((res: boolean | ((prevState: boolean) => boolean)) => { - console.log('媒体库权限:', res); setAlbumEnabled(res); }) // 通知权限 checkNotificationPermission().then((res: boolean | ((prevState: boolean) => boolean)) => { - console.log('通知权限:', res); setNotificationsEnabled(res); }) } @@ -344,8 +335,8 @@ const Setting = (props: { modalVisible: boolean, setModalVisible: (visible: bool - Linking.openURL("https://beian.miit.gov.cn/")} > - {t('lcenses.ICP', { ns: 'personal' })}沪ICP备2023032876号-4 + Linking.openURL("https://beian.miit.gov.cn/")} > + {t('lcenses.ICP', { ns: 'personal' })}沪ICP备2025133004号-2A diff --git a/components/owner/rights/normal.tsx b/components/owner/rights/normal.tsx index 8179dae..2fde55e 100644 --- a/components/owner/rights/normal.tsx +++ b/components/owner/rights/normal.tsx @@ -1,5 +1,6 @@ import GetSvg from "@/assets/icons/svg/get.svg"; import { ThemedText } from "@/components/ThemedText"; +import { useTranslation } from "react-i18next"; import { StyleProp, StyleSheet, TouchableOpacity, View, ViewStyle } from "react-native"; interface Props { @@ -9,6 +10,7 @@ interface Props { const Normal = (props: Props) => { const { setUserType } = props; + const { t } = useTranslation(); return ( @@ -16,16 +18,16 @@ const Normal = (props: Props) => { - Enjoy 100 Bonus Credits Every Month + {t('rights.100Bonus', { ns: 'personal' })} - Generate more memory pictures & videos and explore your past. + {t('rights.100BonusText', { ns: 'personal' })} - 10GB of Cloud Storage + {t('rights.10G', { ns: 'personal' })} - Safely store your cherished photos, videos, and generated memories. + {t('rights.10GText', { ns: 'personal' })} { activeOpacity={0.8} > - Go Premium + {t('rights.purchase', { ns: 'personal' })} diff --git a/components/owner/rights/premium.tsx b/components/owner/rights/premium.tsx index ea9cdf2..634f993 100644 --- a/components/owner/rights/premium.tsx +++ b/components/owner/rights/premium.tsx @@ -1,5 +1,6 @@ import BlackStarSvg from '@/assets/icons/svg/blackStar.svg'; import { ThemedText } from "@/components/ThemedText"; +import { useTranslation } from 'react-i18next'; import { ScrollView, StyleProp, StyleSheet, TouchableOpacity, View, ViewStyle } from "react-native"; import { maxDiscountProduct } from './utils'; @@ -31,6 +32,7 @@ export interface PayItem { const Premium = (props: Props) => { const { style, payType, setPayType, premiumPay, loading, setShowTerms } = props; const bestValue = maxDiscountProduct(premiumPay)?.product_code + const { t } = useTranslation(); return ( @@ -43,7 +45,7 @@ const Premium = (props: Props) => { {loading ? - Loading... + {t('loading', { ns: 'common' })} : premiumPay?.map((item: PayItem) => { @@ -57,7 +59,7 @@ const Premium = (props: Props) => { - Best Value + {t('rights.bestValue', { ns: 'personal' })} @@ -78,10 +80,10 @@ const Premium = (props: Props) => { - Cancel anytime before renewal. Learn more + {t('rights.cancelAnytimeBeforeRenewal', { ns: 'personal' })} setShowTerms(true)}> - Terms & Conditions + {t('rights.terms', { ns: 'personal' })} diff --git a/components/owner/rights/proRights.tsx b/components/owner/rights/proRights.tsx index 11a5210..d7b926f 100644 --- a/components/owner/rights/proRights.tsx +++ b/components/owner/rights/proRights.tsx @@ -1,33 +1,35 @@ import GetSvg from "@/assets/icons/svg/get.svg"; import { ThemedText } from "@/components/ThemedText"; +import { useTranslation } from "react-i18next"; import { StyleProp, StyleSheet, View, ViewStyle } from "react-native"; const ProRights = (props: { style?: StyleProp }) => { const { style } = props; + const { t } = useTranslation(); return ( - Enjoy MemoWake Pro Benefits + {t('rights.proTitle', { ns: 'personal' })} - no advertisement + {t('rights.noAd', { ns: 'personal' })} - There are no advertisements, so you can use the product with peace of mind. + {t('rights.noAdText', { ns: 'personal' })} - Enjoy 1000 Bonus Credits Every Month + {t('rights.bonus', { ns: 'personal' })} - Generate more memory pictures & videos and explore your past. + {t('rights.bonusText', { ns: 'personal' })} - 100GB of Cloud Storage + {t('rights.storage', { ns: 'personal' })} - Safely store your cherished photos, videos, and generated memories. + {t('rights.storageText', { ns: 'personal' })} ); diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index 8a8d96e..025beb5 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -111,5 +111,11 @@ "required": "You must agree to the Terms and Privacy Policy" } }, - "loading": "Loading..." + "loading": "Loading...", + "permission": { + "locationPermissionRequired": "Location permission is required, please enable location service in settings", + "timeout": "Location timeout, please check network and location service", + "notLocation": "Unable to get your location: ", + "notError": "Unknown error" + } } \ No newline at end of file diff --git a/i18n/locales/en/personal.json b/i18n/locales/en/personal.json index 0c5b742..d1f4bd4 100644 --- a/i18n/locales/en/personal.json +++ b/i18n/locales/en/personal.json @@ -88,5 +88,27 @@ "unlock": "Unlock more memory magic", "delete": "Are you sure you want to delete your account?", "cancel": "Cancel" + }, + "rights": { + "title": "Subscription", + "premium": "Pro", + "purchase": "Purchase", + "free": "Free", + "subscribe": "Subscribe", + "terms": "Terms", + "100Bonus": "Enjoy 100 Bonus Credits Every Month", + "100BonusText": "Generate more memory pictures & videos and explore your past.", + "10G": "10GB of Cloud Storage", + "10GText": "Safely store your cherished photos, videos, and generated memories.", + "goPremium": "Go Premium", + "bestValue": "Best Value", + "cancelAnytimeBeforeRenewal": "Cancel anytime before renewal. Learn more", + "proTitle": "Enjoy MemoWake Pro Benefits", + "noAd": "No advertisements", + "noAdText": "There are no advertisements, so you can use the product with peace of mind.", + "bonus": "Enjoy 100 Bonus Credits Every Month", + "bonusText": "Generate more memory pictures & videos and explore your past.", + "storage": "10GB of Cloud Storage", + "storageText": "Safely store your cherished photos, videos, and generated memories." } } \ No newline at end of file diff --git a/i18n/locales/zh/common.json b/i18n/locales/zh/common.json index 9f4c00f..17eb407 100644 --- a/i18n/locales/zh/common.json +++ b/i18n/locales/zh/common.json @@ -110,5 +110,11 @@ "required": "您必须同意服务条款和隐私政策" } }, - "loading": "加载中..." + "loading": "加载中...", + "permission": { + "locationPermissionRequired": "位置权限被拒绝,请在设置中启用位置服务", + "timeout": "获取位置超时,请检查网络和位置服务", + "notLocation": "无法获取您的位置: ", + "notError": "未知错误" + } } \ No newline at end of file diff --git a/i18n/locales/zh/personal.json b/i18n/locales/zh/personal.json index c1be2df..c2c740e 100644 --- a/i18n/locales/zh/personal.json +++ b/i18n/locales/zh/personal.json @@ -88,5 +88,27 @@ "unlock": "解锁更多记忆魔法", "delete": "确定要注销账号吗?", "cancel": "取消" + }, + "rights": { + "title": "权益", + "purchase": "购买", + "free": "免费用户", + "premium": "会员", + "subscribe": "订阅", + "terms": "用户协议", + "100Bonus": "每月享受100积分", + "100BonusText": "生成更多记忆照片和视频,探索你的过去。", + "10G": "10GB的云存储", + "10GText": "安全存储你的珍贵照片、视频和生成的记忆。", + "goPremium": "升级至会员", + "bestValue": "最佳值", + "cancelAnytimeBeforeRenewal": "在续订前随时取消。了解更多", + "proTitle": "享受MemoWake Pro权益", + "noAd": "无广告", + "noAdText": "没有广告,所以你可以安心使用产品。", + "bonus": "每月享受100积分", + "bonusText": "生成更多记忆照片和视频,探索你的过去。", + "storage": "10GB的云存储", + "storageText": "安全存储你的珍贵照片、视频和生成的记忆。" } } \ No newline at end of file