diff --git a/app/screens/productStatus/OrderDatails.tsx b/app/screens/productStatus/OrderDatails.tsx index 9c57342..2b29f8f 100644 --- a/app/screens/productStatus/OrderDatails.tsx +++ b/app/screens/productStatus/OrderDatails.tsx @@ -54,15 +54,7 @@ import { cartApi } from "../../services/api/cart"; import IconComponent from "../../components/IconComponent"; import AsyncStorage from "@react-native-async-storage/async-storage"; import { CountryList } from "../../constants/countries"; - -// 定义本地存储的国家数据类型 -interface LocalCountryData { - code: string; - flag: string; - name: string; - phoneCode: string; - userCount: number; -} +import { getOrderTransLanguage } from "../../utils/languageUtils"; // 定义选项类型 interface PaymentOption { @@ -78,6 +70,15 @@ interface TabType { options: PaymentOption[]; } +// 定义本地存储的国家数据类型 +interface LocalCountryData { + code: string; + flag: string; + name: string; + phoneCode: string; + userCount: number; +} + type Styles = { safeArea: ViewStyle; safeAreaContent: ViewStyle; @@ -970,7 +971,7 @@ export const OrderDetails = () => { - {item.product_name} + {getOrderTransLanguage(item) || item.product_name_fr} @@ -1042,7 +1043,7 @@ export const OrderDetails = () => { {t("order.platform_shipping")} - {orderDetails.domestic_shipping_fee} + {orderDetails.domestic_shipping_fee} {orderDetails.currency} @@ -1050,21 +1051,21 @@ export const OrderDetails = () => { {t("order.international_shipping")} - {orderDetails.shipping_fee} + {orderDetails.shipping_fee} {orderDetails.currency} {t("order.total")} - {orderDetails.total_amount} + {orderDetails.total_amount} {orderDetails.currency} - + ${orderDetails.shipping_fee}{" "} + + {orderDetails.shipping_fee}{" "} {t("order.estimated_shipping")} - (COD) + ({orderDetails.currency}) diff --git a/app/screens/productStatus/Status.tsx b/app/screens/productStatus/Status.tsx index 7431e7c..30b63ea 100644 --- a/app/screens/productStatus/Status.tsx +++ b/app/screens/productStatus/Status.tsx @@ -26,6 +26,7 @@ import { import { useNavigation } from "@react-navigation/native"; import { NativeStackNavigationProp } from "@react-navigation/native-stack"; import { useOrderListStore } from "../../store/orderList"; +import { getOrderTransLanguage } from "../../utils/languageUtils"; // import ImageView from "react-native-image-viewing"; type StatusScreenRouteProp = RouteProp< @@ -243,7 +244,7 @@ export function Status() { - {item.product_name} + {getOrderTransLanguage(item) || item.product_name_fr} {item.sku_attributes?.map((attr, index) => ( >(data: T): str export const getOrderTransLanguage = >(data: T): string => { + console.log(data); + // 获取当前i18n语言 const currentLang = getCurrentLanguage(); + // 特殊处理中文 if (currentLang === 'zh' && 'value' in data) { return data.value as string; @@ -72,14 +75,19 @@ export const getOrderTransLanguage = >(data: T): s key.startsWith('product_name') ); + + // 查找匹配的字段 const matchedField = translationFields.find(field => { // 从字段名中提取语言代码 - const langCode = field.replace('product_name', ''); + const langCode = field.replace('product_name_', ''); + // 如果没有后缀,则为法语 return langCode === '' ? currentLang === 'fr' : langCode === currentLang; }); + + // 返回匹配的翻译值,如果没有匹配则返回法语 - return (data[matchedField || 'product_name'] as string) || ''; + return (data[matchedField || 'product_name_fr'] as string) || ''; };