feat(i18n): 实现应用国际化支持,添加中英文翻译

- 为所有UI组件添加国际化支持,替换硬编码文本
- 新增useI18n钩子函数统一管理翻译
- 完善中英文翻译资源,覆盖统计、用药、通知设置等模块
- 优化Tab布局使用翻译键值替代静态文本
- 更新药品管理、个人资料编辑等页面的多语言支持
This commit is contained in:
richarjiang
2025-11-13 11:09:55 +08:00
parent 416d144387
commit 2dca3253e6
21 changed files with 1669 additions and 366 deletions

View File

@@ -14,6 +14,7 @@ import { logger } from '@/utils/logger';
import dayjs from 'dayjs';
import { Image } from 'expo-image';
import { useRouter } from 'expo-router';
import { useTranslation } from 'react-i18next';
import { AnimatedNumber } from './AnimatedNumber';
// 使用原生View来替代SVG避免导入问题
// import Svg, { Rect } from 'react-native-svg';
@@ -28,6 +29,7 @@ const StepsCard: React.FC<StepsCardProps> = ({
curDate,
style,
}) => {
const { t } = useTranslation();
const router = useRouter();
const [stepCount, setStepCount] = useState(0)
@@ -36,7 +38,7 @@ const StepsCard: React.FC<StepsCardProps> = ({
const getStepData = useCallback(async (date: Date) => {
try {
logger.info('获取步数数据...');
logger.info('Getting step data...');
// 先获取步数立即更新UI
const [steps, hourly] = await Promise.all([
@@ -47,7 +49,7 @@ const StepsCard: React.FC<StepsCardProps> = ({
setHourSteps(hourly);
} catch (error) {
logger.error('获取步数数据失败:', error);
logger.error('Failed to get step data:', error);
}
}, []);
@@ -122,7 +124,7 @@ const StepsCard: React.FC<StepsCardProps> = ({
source={require('@/assets/images/icons/icon-step.png')}
style={styles.titleIcon}
/>
<Text style={styles.title}></Text>
<Text style={styles.title}>{t('statistics.components.steps.title')}</Text>
</View>
{/* 柱状图 */}
@@ -190,7 +192,7 @@ const StepsCard: React.FC<StepsCardProps> = ({
<AnimatedNumber
value={stepCount || 0}
style={styles.stepCount}
format={(v) => stepCount !== null ? `${Math.round(v)}` : '——'}
format={(v) => stepCount !== null ? `${Math.round(v)}` : '--'}
resetToken={stepCount}
/>
</View>