From 6559d4dcd2327bd2eb7afbc3938d993ef8465329 Mon Sep 17 00:00:00 2001 From: particle-box Date: Fri, 6 Feb 2026 09:20:54 +0530 Subject: [PATCH] fix: add more translations --- .../ui/manager/pages/home/HomeRootSection.kt | 24 ++--- .../ui/manager/pages/home/HomeSettings.kt | 96 +++++++++---------- .../ui/manager/pages/home/RetroGameScreen.kt | 12 ++- common/src/main/assets/lang/en_US.json | 34 ++++++- 4 files changed, 99 insertions(+), 67 deletions(-) diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt index 0a3f6be8..7a2e207b 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt @@ -1177,17 +1177,18 @@ class HomeRootSection : Routes.Route() { if (showChangelogDialog && latestUpdate != null) { AestheticDialog( onDismissRequest = { showChangelogDialog = false }, - title = "Changelog", + title = translation["changelog_dialog_title"], text = "", icon = Icons.Filled.Info, - confirmButtonText = "Update", + confirmButtonText = translation["changelog_dialog_update_button"], onConfirm = { showChangelogDialog = false handleUpdateAction() }, - dismissButtonText = "Cancel", + dismissButtonText = translation["changelog_dialog_cancel_button"], onDismiss = { showChangelogDialog = false }, confirmEnabled = !changelogLoading, + showCloseButton = false, customContent = { Column( modifier = Modifier @@ -1210,7 +1211,7 @@ class HomeRootSection : Routes.Route() { ) Spacer(modifier = Modifier.width(10.dp)) Text( - text = "Loading changelog…", + text = translation["changelog_dialog_loading"], color = Color.White, fontWeight = FontWeight.SemiBold ) @@ -1219,7 +1220,7 @@ class HomeRootSection : Routes.Route() { changelogError != null -> { Text( - text = changelogError ?: "Failed to load changelog", + text = changelogError ?: translation["changelog_dialog_error"], color = MaterialTheme.colorScheme.error, fontWeight = FontWeight.SemiBold ) @@ -1227,7 +1228,7 @@ class HomeRootSection : Routes.Route() { else -> { Text( - text = changelogText ?: "Changelog not available", + text = changelogText ?: translation["changelog_dialog_empty"], color = PurrfectPalette.textPrimary, fontSize = 14.sp, lineHeight = 20.sp @@ -1242,12 +1243,13 @@ class HomeRootSection : Routes.Route() { if (showAnnouncementsDialog) { AestheticDialog( onDismissRequest = { showAnnouncementsDialog = false }, - title = "Announcements", + title = translation["announcements_dialog_title"], text = "", icon = Icons.Filled.Info, - confirmButtonText = "Close", + confirmButtonText = translation["announcements_dialog_close_button"], onConfirm = { showAnnouncementsDialog = false }, confirmEnabled = !announcementsLoading, + showCloseButton = false, customContent = { Column( modifier = Modifier @@ -1270,7 +1272,7 @@ class HomeRootSection : Routes.Route() { ) Spacer(modifier = Modifier.width(10.dp)) Text( - text = "Loading announcements...", + text = translation["announcements_dialog_loading"], color = Color.White, fontWeight = FontWeight.SemiBold ) @@ -1279,7 +1281,7 @@ class HomeRootSection : Routes.Route() { announcementsError != null -> { Text( - text = announcementsError ?: "Failed to load announcements", + text = announcementsError ?: translation["announcements_dialog_error"], color = MaterialTheme.colorScheme.error, fontWeight = FontWeight.SemiBold ) @@ -1287,7 +1289,7 @@ class HomeRootSection : Routes.Route() { else -> { Text( - text = announcementsText ?: "Announcements not available", + text = announcementsText ?: translation["announcements_dialog_empty"], color = PurrfectPalette.textPrimary, fontSize = 14.sp, lineHeight = 20.sp diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt index 6d35c72a..b5e12922 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt @@ -16,6 +16,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.OpenInNew import androidx.compose.material.icons.filled.DeleteSweep +import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Tune import androidx.compose.material.icons.filled.Warning import androidx.compose.material3.* @@ -314,6 +315,7 @@ class HomeSettings : Routes.Route() { val scrollState = rememberScrollState() val positiveLabel = context.translation["button.positive"] ?: "Yes" val negativeLabel = context.translation["button.negative"] ?: "No" + val importLabel = context.translation["button.import"] ?: "Import" val sharedButtonColors = ButtonDefaults.buttonColors( containerColor = Color.White.copy(alpha = 0.12f), contentColor = Color.White @@ -378,8 +380,8 @@ class HomeSettings : Routes.Route() { if (showResetSetupDialog) { AestheticDialog( onDismissRequest = { showResetSetupDialog = false }, - title = "Are you sure?", - text = "This will reset PurrfectSnap and restart setup.", + title = translation["reset_setup_dialog_title"], + text = translation["reset_setup_dialog_text"], icon = Icons.Filled.Warning, confirmButtonText = positiveLabel, dismissButtonText = negativeLabel, @@ -611,7 +613,7 @@ class HomeSettings : Routes.Route() { } GlassCard { - RowTitle(title = "Reset PurrfectSnap") + RowTitle(title = translation["reset_setup_title"]) ShiftedRow( modifier = Modifier .fillMaxWidth() @@ -623,14 +625,14 @@ class HomeSettings : Routes.Route() { verticalAlignment = Alignment.CenterVertically ) { Text( - text = "Reset and restart setup", + text = translation["reset_setup_action"], fontSize = 16.sp, fontWeight = FontWeight.Medium, lineHeight = 20.sp ) Icon( imageVector = Icons.AutoMirrored.Filled.OpenInNew, - contentDescription = "Reset", + contentDescription = translation["reset_setup_action"], modifier = Modifier.padding(end = 14.dp) ) } @@ -744,7 +746,7 @@ class HomeSettings : Routes.Route() { colors = sharedButtonColors, border = BorderStroke(1.dp, Color.White.copy(alpha = 0.12f)) ) { - Text(text = "Import") + Text(text = translation["import_button"]) } } } @@ -759,53 +761,49 @@ class HomeSettings : Routes.Route() { Text(translation["view_logger_history_button"]) } if (showImportDialog) { - AlertDialog( + AestheticDialog( onDismissRequest = { showImportDialog = false }, - title = { Text("Import message logger") }, - text = { Text("Importing will override your current message logger database. Continue?") }, - confirmButton = { - TextButton(onClick = { - showImportDialog = false - runCatching { - activityLauncherHelper.openFile("application/octet-stream") { uri -> - runCatching { - context.androidContext.contentResolver.openInputStream(uri.toUri())?.use { inputStream -> - context.messageLogger.databaseFile.outputStream().use { outputStream -> - inputStream.copyTo(outputStream) - } - } ?: throw IllegalStateException("Unable to open selected file") - storedMessagesCount = context.messageLogger.getStoredMessageCount() - storedStoriesCount = context.messageLogger.getStoredStoriesCount() - context.shortToast(translation["success_toast"]) - context.log.info("Imported message logger from $uri", "MessageLogger") - }.onFailure { - context.log.error("Failed to import message logger", it) - context.longToast( - translation.format( - "import_failed_toast", - "message" to (it.localizedMessage ?: it.message ?: "") - ) + title = translation["message_logger_import_title"], + text = translation["message_logger_import_text"], + icon = Icons.Filled.Info, + confirmButtonText = importLabel, + dismissButtonText = context.translation["button.cancel"], + onConfirm = { + showImportDialog = false + runCatching { + activityLauncherHelper.openFile("application/octet-stream") { uri -> + runCatching { + context.androidContext.contentResolver.openInputStream(uri.toUri())?.use { inputStream -> + context.messageLogger.databaseFile.outputStream().use { outputStream -> + inputStream.copyTo(outputStream) + } + } ?: throw IllegalStateException("Unable to open selected file") + storedMessagesCount = context.messageLogger.getStoredMessageCount() + storedStoriesCount = context.messageLogger.getStoredStoriesCount() + context.shortToast(translation["success_toast"]) + context.log.info("Imported message logger from $uri", "MessageLogger") + }.onFailure { + context.log.error("Failed to import message logger", it) + context.longToast( + translation.format( + "import_failed_toast", + "message" to (it.localizedMessage ?: it.message ?: "") ) - } - } - }.onFailure { - context.log.error("Failed to launch import picker", it) - context.longToast( - translation.format( - "import_failed_toast", - "message" to (it.localizedMessage ?: it.message ?: "") ) - ) + } } - }) { - Text(translation["button.import"] ?: "Import") + }.onFailure { + context.log.error("Failed to launch import picker", it) + context.longToast( + translation.format( + "import_failed_toast", + "message" to (it.localizedMessage ?: it.message ?: "") + ) + ) } }, - dismissButton = { - TextButton(onClick = { showImportDialog = false }) { - Text(translation["button.cancel"]) - } - } + onDismiss = { showImportDialog = false }, + showCloseButton = false ) } } @@ -949,8 +947,8 @@ class HomeSettings : Routes.Route() { key = "test_mode", text = translation["test_mode_label"], defaultValue = true, - confirmDisableTitle = "Are you sure?", - confirmDisableText = "Doing this will put your account at risk and cause bans!" + confirmDisableTitle = translation["purr_aura_disable_title"], + confirmDisableText = translation["purr_aura_disable_text"] ) PreferenceToggle(context.sharedPreferences, key = "disable_feature_loading", text = translation["disable_feature_loading_label"]) PreferenceToggle(context.sharedPreferences, key = "disable_mapper", text = translation["disable_auto_mapper_label"]) diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/RetroGameScreen.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/RetroGameScreen.kt index 4f86f0fe..c0fdbc56 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/RetroGameScreen.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/RetroGameScreen.kt @@ -58,6 +58,8 @@ import kotlin.math.roundToInt import kotlin.random.Random class RetroGameScreen : Routes.Route() { + override val translation by lazy { context.translation.getCategory("manager.sections.retro_flight") } + override val content: @Composable (NavBackStackEntry) -> Unit = { val gridWidth = 120 val gridHeight = 160 @@ -206,7 +208,7 @@ class RetroGameScreen : Routes.Route() { verticalArrangement = Arrangement.spacedBy(12.dp) ) { FloatingTopBar( - title = "Retro Flight", + title = translation["title"], onBack = { routes.navController.popBackStack() } ) Spacer(modifier = Modifier.height(6.dp)) @@ -243,7 +245,7 @@ class RetroGameScreen : Routes.Route() { modifier = Modifier.align(Alignment.Center) ) { Text( - text = "GAME OVER", + text = translation["game_over_label"], color = Color.White, fontSize = 14.sp, fontWeight = FontWeight.Bold, @@ -258,7 +260,7 @@ class RetroGameScreen : Routes.Route() { ), shape = RoundedCornerShape(6.dp) ) { - Text("RESTART", fontFamily = pixelFont, fontSize = 12.sp) + Text(translation["restart_button"], fontFamily = pixelFont, fontSize = 12.sp) } } } @@ -293,7 +295,7 @@ class RetroGameScreen : Routes.Route() { ) { Box(contentAlignment = Alignment.Center) { Text( - text = "LEFT", + text = translation["left_button"], color = Color.White, fontSize = 14.sp, fontFamily = pixelFont, @@ -324,7 +326,7 @@ class RetroGameScreen : Routes.Route() { ) { Box(contentAlignment = Alignment.Center) { Text( - text = "RIGHT", + text = translation["right_button"], color = Color.White, fontSize = 14.sp, fontFamily = pixelFont, diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json index 6c657a9f..94a4e643 100644 --- a/common/src/main/assets/lang/en_US.json +++ b/common/src/main/assets/lang/en_US.json @@ -226,7 +226,20 @@ "quick_actions_empty_subtitle": "Design your dream grid with the actions you use the most.", "quick_actions_add_tile_button": "Add tile", "quick_actions_manage_button": "Manage", - "quick_actions_count_label": "{count} curated shortcuts" + "quick_actions_count_label": "{count} curated shortcuts", + "enabled": "Enabled", + "disabled": "Disabled", + "changelog_dialog_title": "Changelog", + "changelog_dialog_update_button": "Update", + "changelog_dialog_cancel_button": "Cancel", + "changelog_dialog_loading": "Loading changelog...", + "changelog_dialog_error": "Failed to load changelog", + "changelog_dialog_empty": "Changelog not available", + "announcements_dialog_title": "Announcements", + "announcements_dialog_close_button": "Close", + "announcements_dialog_loading": "Loading announcements...", + "announcements_dialog_error": "Failed to load announcements", + "announcements_dialog_empty": "Announcements not available" }, "home_about": { "about_title": "PurrfectSnap", @@ -255,8 +268,11 @@ "success_toast": "Done!", "message_logger_summary": "{messageCount} messages\n{storyCount} stories", "export_button": "Export", + "import_button": "Import", "clear_button": "Clear", "view_logger_history_button": "View Logger History", + "message_logger_import_title": "Import message logger", + "message_logger_import_text": "Importing will override your current message logger database. Continue?", "ui_settings_title": "UI Settings", "haptic_feedback_label": "Haptic Feedback", "use_system_toasts_label": "Use System Toasts", @@ -287,16 +303,29 @@ "customize_bottom_bar_title": "Customize Bottom Bar", "customize_bottom_bar_subtitle": "Pick which tabs show on your home screen", "available_tabs_title": "Available Tabs", + "reset_setup_title": "Reset PurrfectSnap", + "reset_setup_action": "Reset and restart setup", + "reset_setup_dialog_title": "Are you sure?", + "reset_setup_dialog_text": "This will reset PurrfectSnap and restart setup.", "reset_button": "Reset", "done_button": "Done", "clear_friend_feed": "Clear Friend Feed", "test_mode_label": "Enable PurrAura", + "purr_aura_disable_title": "Are you sure?", + "purr_aura_disable_text": "Doing this will put your account at risk and cause bans!", "disable_feature_loading_label": "Disable Feature Loading", "disable_auto_mapper_label": "Disable Auto Mapper", "disable_bypass_indicator_label": "Disable Bypass Indicator", "open_file_failed_toast": "Failed to open file! {message}", "import_failed_toast": "Import failed: {message}" }, + "retro_flight": { + "title": "Retro Flight", + "game_over_label": "GAME OVER", + "restart_button": "RESTART", + "left_button": "LEFT", + "right_button": "RIGHT" + }, "tasks": { "no_tasks": "No tasks", "merge_button": "Merge", @@ -2920,6 +2949,7 @@ "save": "Save", "open": "Open", "download": "Download", + "import": "Import", "send": "Send", "restore_original": "Restore Original", "convert_external_media": "Convert External Media" @@ -3586,4 +3616,4 @@ "openai": "OpenAI", "openrouter": "OpenRouter" } -} \ No newline at end of file +}