From 164d42e6b8644649e495a91e118ed941441b1dac Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 8 Mar 2026 01:23:43 -0800 Subject: [PATCH] fix(flutter): localize all hardcoded Chinese strings in home_page + restore iAgent brand name - home_page.dart: use l10n for greeting, default username, agent status, message count - app_en.arb: fix appTitle back to 'iAgent' (was incorrectly changed to 'My Agent') - Add defaultUserName and agentInConversation keys to en/zh/zh_TW ARBs Co-Authored-By: Claude Sonnet 4.6 --- .../home/presentation/pages/home_page.dart | 32 ++++++++++--------- it0_app/lib/l10n/app_en.arb | 12 +++++-- it0_app/lib/l10n/app_localizations.dart | 12 +++++++ it0_app/lib/l10n/app_localizations_en.dart | 10 +++++- it0_app/lib/l10n/app_localizations_zh.dart | 16 ++++++++++ it0_app/lib/l10n/app_zh.arb | 10 +++++- it0_app/lib/l10n/app_zh_TW.arb | 10 +++++- 7 files changed, 82 insertions(+), 20 deletions(-) diff --git a/it0_app/lib/features/home/presentation/pages/home_page.dart b/it0_app/lib/features/home/presentation/pages/home_page.dart index 4678383..63b4937 100644 --- a/it0_app/lib/features/home/presentation/pages/home_page.dart +++ b/it0_app/lib/features/home/presentation/pages/home_page.dart @@ -21,8 +21,9 @@ class HomePage extends ConsumerWidget { final chatState = ref.watch(chatProvider); final unreadCount = ref.watch(unreadNotificationCountProvider); - final greeting = _greeting(); - final name = profile.displayName.isNotEmpty ? profile.displayName : '用户'; + final l10n = AppLocalizations.of(context); + final greeting = _greeting(l10n); + final name = profile.displayName.isNotEmpty ? profile.displayName : l10n.defaultUserName; return Scaffold( backgroundColor: AppColors.background, @@ -40,7 +41,7 @@ class HomePage extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '$greeting,$name', + l10n.homeGreeting(greeting, name), style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold, @@ -125,13 +126,13 @@ class HomePage extends ConsumerWidget { ); } - String _greeting() { + String _greeting(AppLocalizations l10n) { final hour = DateTime.now().hour; - if (hour < 6) return '夜深了'; - if (hour < 12) return '早上好'; - if (hour < 14) return '中午好'; - if (hour < 18) return '下午好'; - return '晚上好'; + if (hour < 6) return l10n.greetingLateNight; + if (hour < 12) return l10n.greetingEarlyMorning; + if (hour < 14) return l10n.greetingNoon; + if (hour < 18) return l10n.greetingAfternoon; + return l10n.greetingEvening; } } @@ -147,12 +148,13 @@ class _AgentStatusCard extends StatelessWidget { @override Widget build(BuildContext context) { final isActive = chatState.isStreaming; + final l10n = AppLocalizations.of(context); final statusText = switch (chatState.agentStatus) { - AgentStatus.idle => '空闲中', - AgentStatus.thinking => '正在思考...', - AgentStatus.executing => '执行指令中...', - AgentStatus.awaitingApproval => '等待审批', - AgentStatus.error => '发生错误', + AgentStatus.idle => l10n.agentStatusIdle, + AgentStatus.thinking => l10n.agentStatusThinking, + AgentStatus.executing => l10n.agentStatusExecuting, + AgentStatus.awaitingApproval => l10n.agentStatusAwaitingApproval, + AgentStatus.error => l10n.agentStatusError, }; final robotState = switch (chatState.agentStatus) { AgentStatus.idle => RobotState.idle, @@ -225,7 +227,7 @@ class _AgentStatusCard extends StatelessWidget { if (chatState.messages.isNotEmpty) ...[ const SizedBox(height: 6), Text( - '对话中 · ${chatState.messages.length} 条消息', + l10n.agentInConversation(chatState.messages.length), style: const TextStyle( fontSize: 12, color: AppColors.textMuted, diff --git a/it0_app/lib/l10n/app_en.arb b/it0_app/lib/l10n/app_en.arb index 7748568..2299a79 100644 --- a/it0_app/lib/l10n/app_en.arb +++ b/it0_app/lib/l10n/app_en.arb @@ -1,7 +1,7 @@ { "@@locale": "en", - "appTitle": "My Agent", + "appTitle": "iAgent", "appSubtitle": "Server Cluster Operations AI Agent", "navHome": "Home", @@ -426,5 +426,13 @@ "errorConnectionClosed": "Connection closed, please retry", "errorSocketException": "Network error, check your connection", "errorTlsException": "Secure connection failed, check your network", - "errorNetworkRequestFailed": "Network request failed, check your connection" + "errorNetworkRequestFailed": "Network request failed, check your connection", + + "defaultUserName": "User", + "agentInConversation": "In conversation · {count} messages", + "@agentInConversation": { + "placeholders": { + "count": { "type": "int" } + } + } } diff --git a/it0_app/lib/l10n/app_localizations.dart b/it0_app/lib/l10n/app_localizations.dart index adb63c1..a31441c 100644 --- a/it0_app/lib/l10n/app_localizations.dart +++ b/it0_app/lib/l10n/app_localizations.dart @@ -2228,6 +2228,18 @@ abstract class AppLocalizations { /// In zh, this message translates to: /// **'网络请求失败,请检查网络后重试'** String get errorNetworkRequestFailed; + + /// No description provided for @defaultUserName. + /// + /// In zh, this message translates to: + /// **'用户'** + String get defaultUserName; + + /// No description provided for @agentInConversation. + /// + /// In zh, this message translates to: + /// **'对话中 · {count} 条消息'** + String agentInConversation(int count); } class _AppLocalizationsDelegate diff --git a/it0_app/lib/l10n/app_localizations_en.dart b/it0_app/lib/l10n/app_localizations_en.dart index 1a4d20f..54a3ad0 100644 --- a/it0_app/lib/l10n/app_localizations_en.dart +++ b/it0_app/lib/l10n/app_localizations_en.dart @@ -9,7 +9,7 @@ class AppLocalizationsEn extends AppLocalizations { AppLocalizationsEn([String locale = 'en']) : super(locale); @override - String get appTitle => 'My Agent'; + String get appTitle => 'iAgent'; @override String get appSubtitle => 'Server Cluster Operations AI Agent'; @@ -1133,4 +1133,12 @@ class AppLocalizationsEn extends AppLocalizations { @override String get errorNetworkRequestFailed => 'Network request failed, check your connection'; + + @override + String get defaultUserName => 'User'; + + @override + String agentInConversation(int count) { + return 'In conversation · $count messages'; + } } diff --git a/it0_app/lib/l10n/app_localizations_zh.dart b/it0_app/lib/l10n/app_localizations_zh.dart index 879abf3..20059fc 100644 --- a/it0_app/lib/l10n/app_localizations_zh.dart +++ b/it0_app/lib/l10n/app_localizations_zh.dart @@ -1100,6 +1100,14 @@ class AppLocalizationsZh extends AppLocalizations { @override String get errorNetworkRequestFailed => '网络请求失败,请检查网络后重试'; + + @override + String get defaultUserName => '用户'; + + @override + String agentInConversation(int count) { + return '对话中 · $count 条消息'; + } } /// The translations for Chinese, as used in Taiwan (`zh_TW`). @@ -1518,4 +1526,12 @@ class AppLocalizationsZhTw extends AppLocalizationsZh { @override String get profileViewMessagesLabel => '查看訊息'; + + @override + String get defaultUserName => '用戶'; + + @override + String agentInConversation(int count) { + return '對話中 · $count 則訊息'; + } } diff --git a/it0_app/lib/l10n/app_zh.arb b/it0_app/lib/l10n/app_zh.arb index 6c9a5c1..4c038e2 100644 --- a/it0_app/lib/l10n/app_zh.arb +++ b/it0_app/lib/l10n/app_zh.arb @@ -426,5 +426,13 @@ "errorConnectionClosed": "连接已关闭,请稍后重试", "errorSocketException": "网络连接异常,请检查网络设置", "errorTlsException": "安全连接失败,请检查网络环境", - "errorNetworkRequestFailed": "网络请求失败,请检查网络后重试" + "errorNetworkRequestFailed": "网络请求失败,请检查网络后重试", + + "defaultUserName": "用户", + "agentInConversation": "对话中 · {count} 条消息", + "@agentInConversation": { + "placeholders": { + "count": { "type": "int" } + } + } } diff --git a/it0_app/lib/l10n/app_zh_TW.arb b/it0_app/lib/l10n/app_zh_TW.arb index 61b4f64..cdb9579 100644 --- a/it0_app/lib/l10n/app_zh_TW.arb +++ b/it0_app/lib/l10n/app_zh_TW.arb @@ -162,5 +162,13 @@ "profileReferralLabel": "邀請有禮", "profileReferralHint": "推薦賺積分", "profileInSiteMessagesLabel": "站內訊息", - "profileViewMessagesLabel": "查看訊息" + "profileViewMessagesLabel": "查看訊息", + + "defaultUserName": "用戶", + "agentInConversation": "對話中 · {count} 則訊息", + "@agentInConversation": { + "placeholders": { + "count": { "type": "int" } + } + } }