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 <noreply@anthropic.com>
This commit is contained in:
parent
3f47a7b149
commit
164d42e6b8
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 則訊息';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -426,5 +426,13 @@
|
|||
"errorConnectionClosed": "连接已关闭,请稍后重试",
|
||||
"errorSocketException": "网络连接异常,请检查网络设置",
|
||||
"errorTlsException": "安全连接失败,请检查网络环境",
|
||||
"errorNetworkRequestFailed": "网络请求失败,请检查网络后重试"
|
||||
"errorNetworkRequestFailed": "网络请求失败,请检查网络后重试",
|
||||
|
||||
"defaultUserName": "用户",
|
||||
"agentInConversation": "对话中 · {count} 条消息",
|
||||
"@agentInConversation": {
|
||||
"placeholders": {
|
||||
"count": { "type": "int" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,5 +162,13 @@
|
|||
"profileReferralLabel": "邀請有禮",
|
||||
"profileReferralHint": "推薦賺積分",
|
||||
"profileInSiteMessagesLabel": "站內訊息",
|
||||
"profileViewMessagesLabel": "查看訊息"
|
||||
"profileViewMessagesLabel": "查看訊息",
|
||||
|
||||
"defaultUserName": "用戶",
|
||||
"agentInConversation": "對話中 · {count} 則訊息",
|
||||
"@agentInConversation": {
|
||||
"placeholders": {
|
||||
"count": { "type": "int" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue