ソースを参照

perf: 补充没有英译的页面

kuns 5 日 前
コミット
37a0b50eaa

+ 4 - 3
app/(auth)/(tabs)/(home)/notificationDetailPage.tsx

@@ -20,7 +20,8 @@ import { formatToChineseDateTime } from '../../../../util/lib';
 import { useTranslation } from '../../../../util/hooks/useTranslation';
  
 const NotificationDetailPage = () => {
-    const { t } = useTranslation();
+    const { t, getCurrentLanguageConfig } = useTranslation(); // 使用翻译钩子
+    const isEn = getCurrentLanguageConfig()?.code === 'en';
     const screenHeight = Dimensions.get('window').height;
     const { promotion } = useLocalSearchParams();
     const promotionObj = JSON.parse(promotion as string);
@@ -124,14 +125,14 @@ const NotificationDetailPage = () => {
                             <Text style={{ fontSize: 45, marginVertical: 25 }}>{t('notifications.charging_detail.title')}</Text>
                         </View>
                         <View className="space-y-2 ">
-                            <Text className="text-base lg:text-lg">{promotionObj.title}</Text>
+                            <Text className="text-base lg:text-lg">{isEn?promotionObj.title_en:promotionObj.title}</Text>
                             {promotionImage && (
                                 <View className="w-full flex items-center justify-center">
                                     <AdaptiveImage source={promotionImage} />
                                 </View>
                             )}
 
-                            <Text className="text-sm">{promotionObj.text}</Text>
+                            <Text className="text-sm">{isEn?promotionObj.text_en:promotionObj.text}</Text>
                             <Text className="text-xs text-gray-500 pt-8 pb-4">
                                 {t('notifications.charging_detail.last_updated')}: {formatToChineseDateTime(promotionObj.updatedAt)}
                             </Text>

+ 0 - 1
app/(auth)/(tabs)/(home)/notificationPage.tsx

@@ -40,7 +40,6 @@ const NotificationPageComponent = () => {
             } else if (results[0].status === 'rejected') {
                 Alert.alert(t('notifications.error_fetching_reservations_title'), results[0].reason);
             }
-
             // Handle promotion data
             if (results[1].status === 'fulfilled') {
                 const passingThisPromotionToBell = results[1].value.filter((p: any) => p.is_show);

+ 0 - 3
component/accountPages/activityRecordPageComponent.tsx

@@ -2,9 +2,6 @@ import { View, Text, Pressable, Dimensions } from 'react-native';
 import { SafeAreaView } from 'react-native-safe-area-context';
 import { router } from 'expo-router';
 import { CrossLogoSvg } from '../global/SVG';
-import CouponTabViewComponent from '../global/couponTabView';
-import { useEffect, useState } from 'react';
-import { walletService } from '../../service/walletService';
 import BookingTabViewComponent from '../global/bookingTabViewComponent';
 import { useTranslation } from '../../util/hooks/useTranslation';
 

+ 8 - 7
component/global/couponTabView.tsx

@@ -45,7 +45,8 @@ const FirstRoute = ({
     loading: boolean;
     handleCouponClick: any;
 }) => {
-    const { t } = useTranslation();
+    const { t, getCurrentLanguageConfig } = useTranslation(); // 使用翻译钩子
+    const isEn = getCurrentLanguageConfig()?.code === 'en';
     
     return (
         <View className="flex-1">
@@ -87,9 +88,9 @@ const FirstRoute = ({
                                                 onCouponClick={handleCouponClick}
                                                 // key={coupon.redeem_code}
                                                 key={`${coupon.id}-${index}`}
-                                                title={coupon.coupon.name}
+                                                title={isEn? coupon.coupon.name_en:coupon.coupon.name}
                                                 price={coupon.coupon.amount}
-                                                detail={coupon.coupon.description}
+                                                detail={isEn?coupon.coupon.description_en:coupon.coupon.description}
                                                 date={formatCouponDate(coupon.expire_date)}
                                                 setOpacity={false}
                                                 redeem_code={coupon.id}
@@ -106,8 +107,8 @@ const FirstRoute = ({
 };
 
 const SecondRoute = ({ coupons }: { coupons: any }) => {
-    const { t } = useTranslation();
-    
+    const { t, getCurrentLanguageConfig } = useTranslation(); // 使用翻译钩子
+    const isEn = getCurrentLanguageConfig()?.code === 'en';
     return (
         <ScrollView style={{ flex: 1, backgroundColor: 'white', marginTop: 14 }}>
             <View className="flex-1 flex-col">
@@ -121,9 +122,9 @@ const SecondRoute = ({ coupons }: { coupons: any }) => {
                     .map((coupon: any, index: any) => (
                         <IndividualCouponComponent
                             key={`${coupon.id}-${index}`}
-                            title={coupon.coupon.name}
+                            title={isEn? coupon.coupon.name_en:coupon.coupon.name}
                             price={coupon.coupon.amount}
-                            detail={coupon.coupon.description}
+                            detail={isEn?coupon.coupon.description_en:coupon.coupon.description}
                             date={formatCouponDate(coupon.expire_date)}
                             setOpacity={true}
                             noCircle={true}

+ 4 - 2
component/global/notificationTabViewComponent.tsx

@@ -32,6 +32,8 @@ const NotificationRow = ({
     index: number;
     viewedNotifications: any;
 }) => {
+    const { t, getCurrentLanguageConfig } = useTranslation(); // 使用翻译钩子
+    const isEn = getCurrentLanguageConfig()?.code === 'en';
     const isViewed = viewedNotifications.some(
         (notification: any) => notification.id === promotionObj.id && notification.type === 'promotion'
     );
@@ -52,12 +54,12 @@ const NotificationRow = ({
             className={`flex flex-col w-full bg-white space-y-2 p-2 ${index % 2 === 0 ? 'bg-[#e7f2f8]' : 'bg-white'}`}
         >
             <View className="flex flex-row justify-between">
-                <Text className="font-[500] text-base">{promotionObj.title}</Text>
+                <Text className="font-[500] text-base">{isEn?promotionObj.title_en:promotionObj.title}</Text>
                 <Text>{formatToChineseDateTime(promotionObj.createdAt)}</Text>
             </View>
             <View>
                 <Text numberOfLines={2} ellipsizeMode="tail" className="text-sm">
-                    {promotionObj.text}
+                    {isEn?promotionObj.text_en:promotionObj.text}
                 </Text>
             </View>
         </Pressable>