commit 6eb5ead35d322eacde869a02a964dd7842056088
parent 2b11dec050221ce6527f96f5cc96560294155462
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Sun, 6 Aug 2023 16:41:15 +0200
feat(ui/features): dialog translation
Diffstat:
5 files changed, 214 insertions(+), 205 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/sections/features/Dialogs.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/sections/features/Dialogs.kt
@@ -29,11 +29,14 @@ import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
+import me.rhunk.snapenhance.bridge.wrapper.LocaleWrapper
import me.rhunk.snapenhance.core.config.DataProcessors
import me.rhunk.snapenhance.core.config.PropertyPair
-class Dialogs {
+class Dialogs(
+ private val translation: LocaleWrapper,
+){
@Composable
fun DefaultDialogCard(content: @Composable ColumnScope.() -> Unit) {
Card(
@@ -50,9 +53,12 @@ class Dialogs {
}
@Composable
- fun DefaultEntryText(text: String, modifier: Modifier = Modifier) {
+ fun TranslatedText(property: PropertyPair<*>, key: String, modifier: Modifier = Modifier) {
Text(
- text = text,
+ text = when (key) {
+ "null" -> translation["manager.features.disabled"]
+ else -> if (property.key.params.shouldTranslate) translation["features.options.${property.key.name}.$key"] else key
+ },
modifier = Modifier
.padding(10.dp, 10.dp, 10.dp, 10.dp)
.then(modifier)
@@ -63,11 +69,11 @@ class Dialogs {
@Suppress("UNCHECKED_CAST")
fun UniqueSelectionDialog(property: PropertyPair<*>) {
val keys = (property.value.defaultValues as List<String>).toMutableList().apply {
- add(0, "disabled")
+ add(0, "null")
}
val selectedValue = remember {
- mutableStateOf(property.value.getNullable()?.toString() ?: "disabled")
+ mutableStateOf(property.value.getNullable()?.toString() ?: "null")
}
DefaultDialogCard {
@@ -85,8 +91,9 @@ class Dialogs {
modifier = Modifier.clickable { select() },
verticalAlignment = Alignment.CenterVertically
) {
- DefaultEntryText(
- text = item,
+ TranslatedText(
+ property = property,
+ key = item,
modifier = Modifier.weight(1f)
)
RadioButton(
@@ -189,8 +196,9 @@ class Dialogs {
modifier = Modifier.clickable { toggle() },
verticalAlignment = Alignment.CenterVertically
) {
- DefaultEntryText(
- text = key,
+ TranslatedText(
+ property = property,
+ key = key,
modifier = Modifier
.weight(1f)
)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/sections/features/FeaturesSection.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/sections/features/FeaturesSection.kt
@@ -57,7 +57,7 @@ import me.rhunk.snapenhance.ui.manager.Section
import me.rhunk.snapenhance.ui.util.ChooseFolderHelper
class FeaturesSection : Section() {
- private val dialogs by lazy { Dialogs() }
+ private val dialogs by lazy { Dialogs(context.translation) }
companion object {
const val MAIN_ROUTE = "feature_root"
@@ -183,7 +183,9 @@ class FeaturesSection : Section() {
overflow = TextOverflow.Ellipsis,
maxLines = 1,
modifier = Modifier.widthIn(0.dp, 120.dp),
- text = (propertyValue.getNullable() as? String) ?: context.translation["manager.features.disabled"],
+ text = (propertyValue.getNullable() as? String)?.let{
+ context.translation["features.options.${property.name}.$it"]
+ } ?: context.translation["manager.features.disabled"],
)
}
diff --git a/core/src/main/assets/lang/en_US.json b/core/src/main/assets/lang/en_US.json
@@ -39,106 +39,203 @@
},
"features": {
- "spoof": {
- "name": "Spoof",
- "description": "Spoof your information",
- "properties": {
- "location": {
- "name": "Location",
- "description": "Spoof your location"
- },
- "device": {
- "name": "Device",
- "description": "Spoof your device"
+ "properties": {
+ "spoof": {
+ "name": "Spoof",
+ "description": "Spoof your information",
+ "properties": {
+ "location": {
+ "name": "Location",
+ "description": "Spoof your location"
+ },
+ "device": {
+ "name": "Device",
+ "description": "Spoof your device"
+ }
}
- }
- },
- "downloader": {
- "name": "Downloader",
- "description": "Download Snaps and Stories",
- "properties": {
- "save_folder": {
- "name": "Save Folder",
- "description": "The directory where all media is saved"
- },
- "auto_download_options": {
- "name": "Auto Download Options",
- "description": "Select which medias to auto download"
+ },
+ "downloader": {
+ "name": "Downloader",
+ "description": "Download Snaps and Stories",
+ "properties": {
+ "save_folder": {
+ "name": "Save Folder",
+ "description": "The directory where all media is saved"
+ },
+ "auto_download_options": {
+ "name": "Auto Download Options",
+ "description": "Select which medias to auto download"
+ }
}
- }
- },
- "user_interface": {
- "name": "User Interface",
- "description": "Change the look and feel of Snapchat",
- "properties": {
- "enable_app_appearance": {
- "name": "Enable App Appearance Settings",
- "description": "Enables the hidden app appearance settings"
- },
- "amoled_dark_mode": {
- "name": "AMOLED Dark Mode",
- "description": "Enables AMOLED dark mode\nMake sure Snapchat's dark mode is enabled"
- },
- "map_friend_nametags": {
- "name": "Enhanced Friend Map Nametags",
- "description": "Enhances the nametags of friends on the map"
- },
- "streak_expiration_info": {
- "name": "Show Streak Expiration Info",
- "description": "Shows Streak expiration info next to streaks"
- },
- "hide_story_section": {
- "name": "Hide Story Section",
- "description": "Hide certain UI Elements shown in the story section"
- },
- "hide_ui_components": {
- "name": "Hide UI Components",
- "description": "Select which UI components to hide"
- },
- "disable_spotlight": {
- "name": "Disable Spotlight",
- "description": "Disables the Spotlight page"
- },
- "startup_tab": {
- "name": "Startup Tab",
- "description": "Change the tab that opens on startup"
- },
- "story_viewer_override": {
- "name": "Story Viewer Override",
- "description": "Turns on certain features which Snapchat hid"
- },
- "friend_feed_menu_buttons": {
- "name": "Friend Feed Menu Buttons",
- "description": "Select which buttons to show in the Friend Feed Menu Bar"
- },
- "friend_feed_menu_position": {
- "name": "Friend Feed Position Index",
- "description": "The position of the Friend Feed Menu component"
- },
- "enable_friend_feed_menu_bar": {
- "name": "Friend Feed Menu Bar",
- "description": "Enables the new Friend Feed Menu Bar"
+ },
+ "user_interface": {
+ "name": "User Interface",
+ "description": "Change the look and feel of Snapchat",
+ "properties": {
+ "enable_app_appearance": {
+ "name": "Enable App Appearance Settings",
+ "description": "Enables the hidden app appearance settings"
+ },
+ "amoled_dark_mode": {
+ "name": "AMOLED Dark Mode",
+ "description": "Enables AMOLED dark mode\nMake sure Snapchat's dark mode is enabled"
+ },
+ "map_friend_nametags": {
+ "name": "Enhanced Friend Map Nametags",
+ "description": "Enhances the nametags of friends on the map"
+ },
+ "streak_expiration_info": {
+ "name": "Show Streak Expiration Info",
+ "description": "Shows Streak expiration info next to streaks"
+ },
+ "hide_story_sections": {
+ "name": "Hide Story Section",
+ "description": "Hide certain UI Elements shown in the story section"
+ },
+ "hide_ui_components": {
+ "name": "Hide UI Components",
+ "description": "Select which UI components to hide"
+ },
+ "disable_spotlight": {
+ "name": "Disable Spotlight",
+ "description": "Disables the Spotlight page"
+ },
+ "startup_tab": {
+ "name": "Startup Tab",
+ "description": "Change the tab that opens on startup"
+ },
+ "story_viewer_override": {
+ "name": "Story Viewer Override",
+ "description": "Turns on certain features which Snapchat hid"
+ },
+ "friend_feed_menu_buttons": {
+ "name": "Friend Feed Menu Buttons",
+ "description": "Select which buttons to show in the Friend Feed Menu Bar"
+ },
+ "friend_feed_menu_position": {
+ "name": "Friend Feed Position Index",
+ "description": "The position of the Friend Feed Menu component"
+ },
+ "enable_friend_feed_menu_bar": {
+ "name": "Friend Feed Menu Bar",
+ "description": "Enables the new Friend Feed Menu Bar"
+ }
}
+ },
+ "messaging": {
+ "name": "Messaging",
+ "description": "Change how you interact with friends"
+ },
+ "global": {
+ "name": "Global",
+ "description": "Tweak Snapchat globally"
+ },
+ "camera": {
+ "name": "Camera",
+ "description": "Adjust the right settings for the perfect snap"
+ },
+ "experimental": {
+ "name": "Experimental",
+ "description": "Experimental features"
}
},
- "messaging": {
- "name": "Messaging",
- "description": "Change how you interact with friends"
- },
- "global": {
- "name": "Global",
- "description": "Tweak Snapchat globally"
- },
- "camera": {
- "name": "Camera",
- "description": "Adjust the right settings for the perfect snap"
- },
- "experimental": {
- "name": "Experimental",
- "description": "Experimental features"
+ "options": {
+ "better_notifications": {
+ "chat": "Show chat messages",
+ "snap": "Show medias",
+ "reply_button": "Add reply button",
+ "download_button": "Add download button"
+ },
+ "friend_feed_menu_buttons": {
+ "auto_download_blacklist": "\u2B07\uFE0F Auto Download Blacklist",
+ "anti_auto_save": "\uD83D\uDCAC Anti Auto Save Messages",
+ "stealth_mode": "\uD83D\uDC7B Stealth Mode",
+ "conversation_info": "\uD83D\uDC64 Conversation Info"
+ },
+ "download_options": {
+ "allow_duplicate": "Allow duplicate downloads",
+ "create_user_folder": "Create folder for each user",
+ "append_hash": "Add a unique hash to the file name",
+ "append_username": "Add the username to the file name",
+ "append_date_time": "Add the date and time to the file name",
+ "append_type": "Add the media type to the file name",
+ "merge_overlay": "Merge Snap Image Overlays"
+ },
+ "auto_download_options": {
+ "friend_snaps": "Friend Snaps",
+ "friend_stories": "Friend Stories",
+ "public_stories": "Public Stories",
+ "spotlight": "Spotlight"
+ },
+ "download_logging": {
+ "started": "Started",
+ "success": "Success",
+ "progress": "Progress",
+ "failure": "Failure"
+ },
+ "auto_save_messages": {
+ "NOTE": "Audio Note",
+ "CHAT": "Chat",
+ "EXTERNAL_MEDIA": "External Media",
+ "SNAP": "Snap",
+ "STICKER": "Sticker"
+ },
+ "notifications": {
+ "chat_screenshot": "Screenshot",
+ "chat_screen_record": "Screen Record",
+ "camera_roll_save": "Camera Roll Save",
+ "chat": "Chat",
+ "chat_reply": "Chat Reply",
+ "snap": "Snap",
+ "typing": "Typing",
+ "stories": "Stories",
+ "initiate_audio": "Incoming Audio Call",
+ "abandon_audio": "Missed Audio Call",
+ "initiate_video": "Incoming Video Call",
+ "abandon_video": "Missed Video Call"
+ },
+ "gallery_media_send_override": {
+ "ORIGINAL": "Original",
+ "NOTE": "Audio Note",
+ "SNAP": "Snap",
+ "LIVE_SNAP": "Snap with audio"
+ },
+ "hide_ui_components": {
+ "hide_call_buttons": "Remove Call Buttons",
+ "hide_cognac_button": "Remove Cognac Button",
+ "hide_live_location_share_button": "Remove Live Location Share Button",
+ "hide_stickers_button": "Remove Stickers Button",
+ "hide_voice_record_button": "Remove Voice Record Button"
+ },
+ "auto_updater": {
+ "DISABLED": "Disabled",
+ "EVERY_LAUNCH": "Every Launch",
+ "DAILY": "Daily",
+ "WEEKLY": "Weekly"
+ },
+ "story_viewer_override": {
+ "OFF": "Off",
+ "DISCOVER_PLAYBACK_SEEKBAR": "Enable Discover Playback Seekbar",
+ "VERTICAL_STORY_VIEWER": "Enable Vertical Story Viewer"
+ },
+ "hide_story_sections": {
+ "hide_friend_suggestions": "Hide friend suggestions",
+ "hide_friends": "Hide friends section",
+ "hide_following": "Hide following section",
+ "hide_for_you": "Hide For You section"
+ },
+ "startup_tab": {
+ "OFF": "Off",
+ "ngs_map_icon_container": "Map",
+ "ngs_chat_icon_container": "Chat",
+ "ngs_camera_icon_container": "Camera",
+ "ngs_community_icon_container": "Community / Stories",
+ "ngs_spotlight_icon_container": "Spotlight",
+ "ngs_search_icon_container": "Search"
+ }
},
- "properties": {
+ "temp": {
"message_logger": {
"name": "Message Logger",
"description": "Prevents messages from being deleted"
@@ -300,102 +397,6 @@
"name": "Android ID",
"description": "Spoofs the devices Android ID"
}
- },
- "option": {
- "better_notifications": {
- "chat": "Show chat messages",
- "snap": "Show medias",
- "reply_button": "Add reply button",
- "download_button": "Add download button"
- },
- "friend_feed_menu_buttons": {
- "auto_download_blacklist": "\u2B07\uFE0F Auto Download Blacklist",
- "anti_auto_save": "\uD83D\uDCAC Anti Auto Save Messages",
- "stealth_mode": "\uD83D\uDC7B Stealth Mode",
- "conversation_info": "\uD83D\uDC64 Conversation Info"
- },
- "download_options": {
- "allow_duplicate": "Allow duplicate downloads",
- "create_user_folder": "Create folder for each user",
- "append_hash": "Add a unique hash to the file name",
- "append_username": "Add the username to the file name",
- "append_date_time": "Add the date and time to the file name",
- "append_type": "Add the media type to the file name",
- "merge_overlay": "Merge Snap Image Overlays"
- },
- "auto_download_options": {
- "friend_snaps": "Friend Snaps",
- "friend_stories": "Friend Stories",
- "public_stories": "Public Stories",
- "spotlight": "Spotlight"
- },
- "download_logging": {
- "started": "Started",
- "success": "Success",
- "progress": "Progress",
- "failure": "Failure"
- },
- "auto_save_messages": {
- "NOTE": "Audio Note",
- "CHAT": "Chat",
- "EXTERNAL_MEDIA": "External Media",
- "SNAP": "Snap",
- "STICKER": "Sticker"
- },
- "notifications": {
- "chat_screenshot": "Screenshot",
- "chat_screen_record": "Screen Record",
- "camera_roll_save": "Camera Roll Save",
- "chat": "Chat",
- "chat_reply": "Chat Reply",
- "snap": "Snap",
- "typing": "Typing",
- "stories": "Stories",
- "initiate_audio": "Incoming Audio Call",
- "abandon_audio": "Missed Audio Call",
- "initiate_video": "Incoming Video Call",
- "abandon_video": "Missed Video Call"
- },
- "gallery_media_send_override": {
- "ORIGINAL": "Original",
- "NOTE": "Audio Note",
- "SNAP": "Snap",
- "LIVE_SNAP": "Snap with audio"
- },
- "hide_ui_elements": {
- "remove_call_buttons": "Remove Call Buttons",
- "remove_cognac_button": "Remove Cognac Button",
- "remove_live_location_share_button": "Remove Live Location Share Button",
- "remove_stickers_button": "Remove Stickers Button",
- "remove_voice_record_button": "Remove Voice Record Button",
- "remove_camera_borders": "Remove Camera Borders"
- },
- "auto_updater": {
- "DISABLED": "Disabled",
- "EVERY_LAUNCH": "Every Launch",
- "DAILY": "Daily",
- "WEEKLY": "Weekly"
- },
- "story_viewer_override": {
- "OFF": "Off",
- "DISCOVER_PLAYBACK_SEEKBAR": "Enable Discover Playback Seekbar",
- "VERTICAL_STORY_VIEWER": "Enable Vertical Story Viewer"
- },
- "hide_story_section": {
- "hide_friend_suggestions": "Hide friend suggestions",
- "hide_friends": "Hide friends section",
- "hide_following": "Hide following section",
- "hide_for_you": "Hide For You section"
- },
- "startup_page_override": {
- "OFF": "Off",
- "ngs_map_icon_container": "Map",
- "ngs_chat_icon_container": "Chat",
- "ngs_camera_icon_container": "Camera",
- "ngs_community_icon_container": "Community / Stories",
- "ngs_spotlight_icon_container": "Spotlight",
- "ngs_search_icon_container": "Search"
- }
}
},
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/bridge/wrapper/LocaleWrapper.kt b/core/src/main/kotlin/me/rhunk/snapenhance/bridge/wrapper/LocaleWrapper.kt
@@ -80,9 +80,7 @@ class LocaleWrapper {
loadFromContext(context)
}
- operator fun get(key: String): String {
- return translationMap[key] ?: key.also { Logger.debug("Missing translation for $key") }
- }
+ operator fun get(key: String) = translationMap[key] ?: key.also { Logger.debug("Missing translation for $key") }
fun format(key: String, vararg args: Pair<String, String>): String {
return args.fold(get(key)) { acc, pair ->
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/config/ConfigObjects.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/config/ConfigObjects.kt
@@ -11,7 +11,7 @@ data class PropertyPair<T>(
}
class ConfigParams(
- var shouldTranslate: Boolean = false,
+ var shouldTranslate: Boolean = true,
var isHidden: Boolean = false,
var isFolder: Boolean = false,
val disabledKey: String? = null
@@ -52,7 +52,7 @@ data class PropertyKey<T>(
return if (parentKey != null) {
"${parentKey!!.propertyTranslationPath()}.properties.$name"
} else {
- "features.$name"
+ "features.properties.$name"
}
}
}