Skip to content

Commit 70065a0

Browse files
author
OpenClaw Chinese Localization
committed
i18n(android): add zh-CN localization with Chinese strings.xml and stringResource migration
- Created values-zh-rCN/strings.xml with 220+ Chinese translations for all Android UI screens - Migrated ConnectTabScreen.kt from hardcoded English strings to stringResource() calls - Provides a complete i18n blueprint for the Android app - Follows Android resource directory conventions (values-zh-rCN) - Enables future translations by separating strings from code This is the first step toward full zh-CN localization of the Android client, addressing the coverage gap noted in #88570 for the mobile app.
1 parent 4a503ed commit 70065a0

2 files changed

Lines changed: 358 additions & 26 deletions

File tree

‎apps/android/app/src/main/java/ai/openclaw/app/ui/ConnectTabScreen.kt‎

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ai.openclaw.app.ui
33
import ai.openclaw.app.GatewayConnectionProblem
44
import ai.openclaw.app.MainViewModel
55
import ai.openclaw.app.ui.mobileCardSurface
6+
import ai.openclaw.app.R
67
import androidx.compose.animation.AnimatedVisibility
78
import androidx.compose.foundation.BorderStroke
89
import androidx.compose.foundation.background
@@ -55,6 +56,7 @@ import androidx.compose.ui.text.font.FontFamily
5556
import androidx.compose.ui.text.font.FontWeight
5657
import androidx.compose.ui.text.input.KeyboardType
5758
import androidx.compose.ui.unit.dp
59+
import androidx.compose.ui.res.stringResource
5860

5961
private enum class ConnectInputMode {
6062
SetupCode,
@@ -100,7 +102,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
100102
AlertDialog(
101103
onDismissRequest = { viewModel.declineGatewayTrustPrompt() },
102104
containerColor = mobileCardSurface,
103-
title = { Text("Trust this gateway?", style = mobileHeadline, color = mobileText) },
105+
title = { Text(stringResource(R.string.trust_this_gateway), style = mobileHeadline, color = mobileText) },
104106
text = {
105107
val message =
106108
if (prompt.previousFingerprintSha256.isNullOrBlank()) {
@@ -119,15 +121,15 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
119121
onClick = { viewModel.acceptGatewayTrustPrompt() },
120122
colors = ButtonDefaults.textButtonColors(contentColor = mobileAccent),
121123
) {
122-
Text("Trust and continue")
124+
Text(stringResource(R.string.trust_and_continue))
123125
}
124126
},
125127
dismissButton = {
126128
TextButton(
127129
onClick = { viewModel.declineGatewayTrustPrompt() },
128130
colors = ButtonDefaults.textButtonColors(contentColor = mobileTextSecondary),
129131
) {
130-
Text("Cancel")
132+
Text(stringResource(R.string.cancel))
131133
}
132134
},
133135
)
@@ -158,9 +160,9 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
158160
verticalArrangement = Arrangement.spacedBy(14.dp),
159161
) {
160162
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
161-
Text("Gateway Connection", style = mobileTitle1, color = mobileText)
163+
Text(stringResource(R.string.gateway_connection), style = mobileTitle1, color = mobileText)
162164
Text(
163-
if (isConnected) "Your gateway is active and ready." else "Connect to your gateway to get started.",
165+
if (isConnected) stringResource(R.string.gateway_ready) else stringResource(R.string.connect_to_your_gateway),
164166
style = mobileCallout,
165167
color = mobileTextSecondary,
166168
)
@@ -191,7 +193,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
191193
)
192194
}
193195
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
194-
Text("Endpoint", style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
196+
Text(stringResource(R.string.endpoint), style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
195197
Text(activeEndpoint, style = mobileBody.copy(fontFamily = FontFamily.Monospace), color = mobileText)
196198
}
197199
}
@@ -213,7 +215,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
213215
)
214216
}
215217
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
216-
Text("Status", style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
218+
Text(stringResource(R.string.status), style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
217219
Text(statusText, style = mobileBody, color = if (isConnected) mobileSuccess else mobileText)
218220
}
219221
}
@@ -238,7 +240,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
238240
) {
239241
Icon(Icons.Default.PowerSettingsNew, contentDescription = null, modifier = Modifier.size(18.dp))
240242
Spacer(modifier = Modifier.width(8.dp))
241-
Text("Disconnect", style = mobileHeadline.copy(fontWeight = FontWeight.SemiBold))
243+
Text(stringResource(R.string.disconnect), style = mobileHeadline.copy(fontWeight = FontWeight.SemiBold))
242244
}
243245
} else {
244246
Button(
@@ -307,7 +309,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
307309
contentColor = Color.White,
308310
),
309311
) {
310-
Text("Connect Gateway", style = mobileHeadline.copy(fontWeight = FontWeight.Bold))
312+
Text(stringResource(R.string.connect_gateway), style = mobileHeadline.copy(fontWeight = FontWeight.Bold))
311313
}
312314
}
313315

@@ -322,7 +324,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
322324
modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 14.dp),
323325
verticalArrangement = Arrangement.spacedBy(10.dp),
324326
) {
325-
Text(if (pairingRequired) "Pairing required" else "Last gateway error", style = mobileHeadline, color = mobileWarning)
327+
Text(if (pairingRequired) stringResource(R.string.pairing_required) else stringResource(R.string.last_gateway_error), style = mobileHeadline, color = mobileWarning)
326328
Text(statusLabel, style = mobileBody.copy(fontFamily = FontFamily.Monospace), color = mobileText)
327329
if (pairingRequired) {
328330
Text(
@@ -354,7 +356,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
354356
) {
355357
Icon(Icons.Default.ContentCopy, contentDescription = null, modifier = Modifier.size(18.dp))
356358
Spacer(modifier = Modifier.width(8.dp))
357-
Text("Copy Report for Claw", style = mobileCallout.copy(fontWeight = FontWeight.Bold))
359+
Text(stringResource(R.string.copy_report_for_claw), style = mobileCallout.copy(fontWeight = FontWeight.Bold))
358360
}
359361
}
360362
}
@@ -373,8 +375,8 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
373375
horizontalArrangement = Arrangement.SpaceBetween,
374376
) {
375377
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
376-
Text("Advanced controls", style = mobileHeadline, color = mobileText)
377-
Text("Setup code, endpoint, TLS, token, password, onboarding.", style = mobileCaption1, color = mobileTextSecondary)
378+
Text(stringResource(R.string.advanced_controls), style = mobileHeadline, color = mobileText)
379+
Text(stringResource(R.string.advanced_controls_desc), style = mobileCaption1, color = mobileTextSecondary)
378380
}
379381
Icon(
380382
imageVector = if (advancedOpen) Icons.Default.ExpandLess else Icons.Default.ExpandMore,
@@ -395,25 +397,25 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
395397
modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 14.dp),
396398
verticalArrangement = Arrangement.spacedBy(12.dp),
397399
) {
398-
Text("Connection method", style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
400+
Text(stringResource(R.string.connection_method), style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
399401
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
400402
MethodChip(
401-
label = "Setup Code",
403+
label = stringResource(R.string.setup_code),
402404
active = inputMode == ConnectInputMode.SetupCode,
403405
onClick = { inputMode = ConnectInputMode.SetupCode },
404406
)
405407
MethodChip(
406-
label = "Manual",
408+
label = stringResource(R.string.manual),
407409
active = inputMode == ConnectInputMode.Manual,
408410
onClick = { inputMode = ConnectInputMode.Manual },
409411
)
410412
}
411413

412-
Text("Run these on the gateway host:", style = mobileCallout, color = mobileTextSecondary)
414+
Text(stringResource(R.string.run_these_on_gateway), style = mobileCallout, color = mobileTextSecondary)
413415
CommandBlock("openclaw qr --setup-code-only")
414416
CommandBlock("openclaw qr --json")
415417
Text(
416-
"For Tailscale or public hosts, use wss:// or Tailscale Serve. Private LAN ws:// remains supported.",
418+
stringResource(R.string.for_tailscale_or_public),
417419
style = mobileCaption1,
418420
color = mobileTextSecondary,
419421
)
@@ -426,7 +428,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
426428
setupCode = it
427429
validationText = null
428430
},
429-
placeholder = { Text("Paste setup code", style = mobileBody, color = mobileTextTertiary) },
431+
placeholder = { Text(stringResource(R.string.paste_setup_code), style = mobileBody, color = mobileTextTertiary) },
430432
modifier = Modifier.fillMaxWidth(),
431433
minLines = 3,
432434
maxLines = 5,
@@ -460,7 +462,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
460462
)
461463
}
462464

463-
Text("Host", style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
465+
Text(stringResource(R.string.host), style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
464466
OutlinedTextField(
465467
value = manualHostInput,
466468
onValueChange = {
@@ -502,9 +504,9 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
502504
horizontalArrangement = Arrangement.SpaceBetween,
503505
) {
504506
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
505-
Text("Use TLS", style = mobileHeadline, color = mobileText)
507+
Text(stringResource(R.string.use_tls), style = mobileHeadline, color = mobileText)
506508
Text(
507-
"Turn this on for Tailscale or public hosts. Private LAN ws:// remains supported.",
509+
stringResource(R.string.use_tls_desc),
508510
style = mobileCallout,
509511
color = mobileTextSecondary,
510512
)
@@ -525,7 +527,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
525527
)
526528
}
527529

528-
Text("Token (optional)", style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
530+
Text(stringResource(R.string.token_optional), style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
529531
OutlinedTextField(
530532
value = gatewayToken,
531533
onValueChange = { viewModel.setGatewayToken(it) },
@@ -539,7 +541,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
539541
)
540542

541543
Text(
542-
"Password (optional)",
544+
stringResource(R.string.password_optional),
543545
style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold),
544546
color = mobileTextSecondary,
545547
)
@@ -563,7 +565,7 @@ fun ConnectTabScreen(viewModel: MainViewModel) {
563565
HorizontalDivider(color = mobileBorder)
564566

565567
TextButton(onClick = { viewModel.setOnboardingCompleted(false) }) {
566-
Text("Run onboarding again", style = mobileCallout.copy(fontWeight = FontWeight.SemiBold), color = mobileAccent)
568+
Text(stringResource(R.string.run_onboarding_again), style = mobileCallout.copy(fontWeight = FontWeight.SemiBold), color = mobileAccent)
567569
}
568570
}
569571
}
@@ -648,7 +650,7 @@ private fun CommandBlock(command: String) {
648650
private fun EndpointPreview(endpoint: String) {
649651
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
650652
HorizontalDivider(color = mobileBorder)
651-
Text("Resolved endpoint", style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
653+
Text(stringResource(R.string.resolved_endpoint), style = mobileCaption1.copy(fontWeight = FontWeight.SemiBold), color = mobileTextSecondary)
652654
Text(endpoint, style = mobileCallout.copy(fontFamily = FontFamily.Monospace), color = mobileText)
653655
HorizontalDivider(color = mobileBorder)
654656
}

0 commit comments

Comments
 (0)