From e5e4fd653e5f7a352fefb0508536ac832494de09 Mon Sep 17 00:00:00 2001 From: benya Date: Wed, 11 Mar 2026 21:03:55 +0300 Subject: [PATCH] Localize ProfileScreen labels and actions --- .../messenger/ui/profile/ProfileScreen.kt | 54 +++++++++++-------- .../app/src/main/res/values-ru/strings.xml | 13 +++++ android/app/src/main/res/values/strings.xml | 13 +++++ 3 files changed, 58 insertions(+), 22 deletions(-) diff --git a/android/app/src/main/java/ru/daemonlord/messenger/ui/profile/ProfileScreen.kt b/android/app/src/main/java/ru/daemonlord/messenger/ui/profile/ProfileScreen.kt index 4cc576c..38910a0 100644 --- a/android/app/src/main/java/ru/daemonlord/messenger/ui/profile/ProfileScreen.kt +++ b/android/app/src/main/java/ru/daemonlord/messenger/ui/profile/ProfileScreen.kt @@ -72,9 +72,11 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import coil.compose.AsyncImage import kotlinx.coroutines.flow.collectLatest +import ru.daemonlord.messenger.R import ru.daemonlord.messenger.ui.account.AccountViewModel import java.io.ByteArrayOutputStream import kotlin.math.max +import androidx.compose.ui.res.stringResource @Composable fun ProfileRoute( @@ -167,7 +169,7 @@ fun ProfileScreen( if (avatarUrl.isNotBlank()) { AsyncImage( model = avatarUrl, - contentDescription = "Avatar", + contentDescription = stringResource(id = R.string.profile_avatar_content_description), modifier = Modifier .size(108.dp) .clip(CircleShape) @@ -190,28 +192,32 @@ fun ProfileScreen( } Text( - text = if (name.isBlank()) "User" else name, + text = if (name.isBlank()) stringResource(id = R.string.profile_user_fallback) else name, style = MaterialTheme.typography.headlineSmall, color = MaterialTheme.colorScheme.onPrimaryContainer, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis, ) - Text("online", color = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.8f), style = MaterialTheme.typography.bodyLarge) + Text( + stringResource(id = R.string.chat_status_online), + color = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.8f), + style = MaterialTheme.typography.bodyLarge, + ) Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp), ) { HeroActionButton( - label = "Choose photo", + label = stringResource(id = R.string.profile_choose_photo), icon = Icons.Filled.AddAPhoto, modifier = Modifier.weight(1f), ) { pickAvatarLauncher.launch("image/*") } HeroActionButton( - label = "Edit", + label = stringResource(id = R.string.profile_edit), icon = Icons.Filled.Edit, modifier = Modifier.weight(1f), ) { @@ -240,10 +246,14 @@ fun ProfileScreen( .padding(16.dp), verticalArrangement = Arrangement.spacedBy(14.dp), ) { - ProfileInfoRow("Email", profile?.email.orEmpty()) - ProfileInfoRow("Bio", bio.ifBlank { "Not set" }) - ProfileInfoRow("Username", if (username.isBlank()) "Not set" else "@$username") - ProfileInfoRow("Name", name.ifBlank { "Not set" }) + val notSet = stringResource(id = R.string.profile_not_set) + ProfileInfoRow(stringResource(id = R.string.auth_label_email), profile?.email.orEmpty()) + ProfileInfoRow(stringResource(id = R.string.profile_bio), bio.ifBlank { notSet }) + ProfileInfoRow( + stringResource(id = R.string.auth_label_username), + if (username.isBlank()) notSet else "@$username", + ) + ProfileInfoRow(stringResource(id = R.string.auth_label_name), name.ifBlank { notSet }) } } } @@ -262,9 +272,9 @@ fun ProfileScreen( .padding(16.dp), verticalArrangement = Arrangement.spacedBy(10.dp), ) { - Text("Edit profile", style = MaterialTheme.typography.titleMedium) + Text(stringResource(id = R.string.profile_edit_profile), style = MaterialTheme.typography.titleMedium) HeroActionButton( - label = "Choose photo", + label = stringResource(id = R.string.profile_choose_photo), icon = Icons.Filled.AddAPhoto, modifier = Modifier.fillMaxWidth(), ) { @@ -273,30 +283,30 @@ fun ProfileScreen( OutlinedTextField( value = name, onValueChange = { name = it }, - label = { Text("Name") }, + label = { Text(stringResource(id = R.string.auth_label_name)) }, modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( value = username, onValueChange = { username = it }, - label = { Text("Username") }, + label = { Text(stringResource(id = R.string.auth_label_username)) }, modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( value = bio, onValueChange = { bio = it }, - label = { Text("Bio") }, + label = { Text(stringResource(id = R.string.profile_bio)) }, modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( value = avatarUrl, onValueChange = { avatarUrl = it }, - label = { Text("Avatar URL") }, + label = { Text(stringResource(id = R.string.profile_avatar_url)) }, modifier = Modifier.fillMaxWidth(), ) Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { TextButton(onClick = { editMode = false }, modifier = Modifier.weight(1f)) { - Text("Cancel") + Text(stringResource(id = R.string.common_cancel)) } Button( onClick = { @@ -311,7 +321,7 @@ fun ProfileScreen( enabled = !state.isSaving && name.isNotBlank() && username.isNotBlank(), modifier = Modifier.weight(1f), ) { - Text("Save") + Text(stringResource(id = R.string.common_save)) } } if (state.isSaving) { @@ -421,7 +431,7 @@ private fun AvatarCropDialog( .padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp), ) { - Text("Crop avatar", style = MaterialTheme.typography.titleMedium) + Text(stringResource(id = R.string.profile_crop_avatar), style = MaterialTheme.typography.titleMedium) Box( modifier = Modifier .fillMaxWidth() @@ -441,7 +451,7 @@ private fun AvatarCropDialog( ) { androidx.compose.foundation.Image( bitmap = bitmap.asImageBitmap(), - contentDescription = "Avatar crop preview", + contentDescription = stringResource(id = R.string.profile_avatar_crop_preview), contentScale = ContentScale.Crop, modifier = Modifier .fillMaxSize() @@ -458,7 +468,7 @@ private fun AvatarCropDialog( onClick = onDismiss, modifier = Modifier.weight(1f), ) { - Text("Cancel") + Text(stringResource(id = R.string.common_cancel)) } Button( onClick = { @@ -487,11 +497,11 @@ private fun AvatarCropDialog( }, modifier = Modifier.weight(1f), ) { - Text("Use") + Text(stringResource(id = R.string.profile_use_crop)) } } Text( - text = "Use two fingers to zoom and move.", + text = stringResource(id = R.string.profile_crop_hint), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) diff --git a/android/app/src/main/res/values-ru/strings.xml b/android/app/src/main/res/values-ru/strings.xml index 8610689..a740944 100644 --- a/android/app/src/main/res/values-ru/strings.xml +++ b/android/app/src/main/res/values-ru/strings.xml @@ -75,7 +75,20 @@ Удалить Создать Отправить + Сохранить Неизвестный пользователь + Аватар + Пользователь + Выбрать фото + Редактировать + О себе + Не указано + Редактировать профиль + URL аватара + Обрезать аватар + Предпросмотр обрезки аватара + Использовать + Используйте два пальца для масштабирования и перемещения. Уведомления Поиск diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index ec6a274..438d294 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -75,7 +75,20 @@ Delete Create Send + Save Unknown user + Avatar + User + Choose photo + Edit + Bio + Not set + Edit profile + Avatar URL + Crop avatar + Avatar crop preview + Use + Use two fingers to zoom and move. Notifications Search