Update wording for languages & models

This commit is contained in:
Aleksandras Kostarevas 2024-06-06 22:25:17 +03:00
parent b39159e582
commit 54114c7cf0
4 changed files with 28 additions and 12 deletions

View File

@ -318,6 +318,10 @@ fun determineFileKind(context: Context, file: Uri): FileKindAndInfo {
} }
object ResourceHelper { object ResourceHelper {
val BuiltInVoiceInputFallbacks = mapOf(
"en" to BUILTIN_ENGLISH_MODEL
)
suspend fun findKeyForLocaleAndKind(context: Context, locale: Locale, kind: FileKind): String? { suspend fun findKeyForLocaleAndKind(context: Context, locale: Locale, kind: FileKind): String? {
val keysToTry = listOf( val keysToTry = listOf(
locale.language, locale.language,
@ -348,11 +352,7 @@ object ResourceHelper {
fun tryFindingVoiceInputModelForLocale(context: Context, locale: Locale): ModelLoader? { fun tryFindingVoiceInputModelForLocale(context: Context, locale: Locale): ModelLoader? {
val file = runBlocking { findFileForKind(context, locale, FileKind.VoiceInput) } val file = runBlocking { findFileForKind(context, locale, FileKind.VoiceInput) }
?: return if(locale.language == "en") { ?: return BuiltInVoiceInputFallbacks[locale.language]
BUILTIN_ENGLISH_MODEL
} else {
null
}
return ModelFileFile(R.string.externally_imported_model, file) return ModelFileFile(R.string.externally_imported_model, file)
} }

View File

@ -57,7 +57,7 @@ fun HomeScreen(navController: NavHostController = rememberNavController()) {
ConditionalUnpaidNoticeWithNav(navController) ConditionalUnpaidNoticeWithNav(navController)
NavigationItem( NavigationItem(
title = "Languages", title = "Languages & Models",
style = NavigationItemStyle.HomePrimary, style = NavigationItemStyle.HomePrimary,
navigate = { navController.navigate("languages") }, navigate = { navController.navigate("languages") },
icon = painterResource(id = R.drawable.globe) icon = painterResource(id = R.drawable.globe)

View File

@ -51,6 +51,7 @@ import org.futo.inputmethod.latin.uix.settings.pages.modelmanager.openModelImpor
import org.futo.inputmethod.latin.uix.settings.useDataStoreValueBlocking import org.futo.inputmethod.latin.uix.settings.useDataStoreValueBlocking
import org.futo.inputmethod.latin.uix.theme.Typography import org.futo.inputmethod.latin.uix.theme.Typography
import org.futo.inputmethod.latin.uix.youAreImporting import org.futo.inputmethod.latin.uix.youAreImporting
import org.futo.inputmethod.latin.utils.Dictionaries
import org.futo.inputmethod.latin.xlm.ModelPaths import org.futo.inputmethod.latin.xlm.ModelPaths
import org.futo.inputmethod.updates.openURI import org.futo.inputmethod.updates.openURI
import java.util.Locale import java.util.Locale
@ -73,6 +74,14 @@ fun ConfirmResourceActionDialog(
isCurrentlySet: Boolean, isCurrentlySet: Boolean,
locale: Locale locale: Locale
) { ) {
val hasBuiltInFallback = if(resourceKind == FileKind.VoiceInput) {
ResourceHelper.BuiltInVoiceInputFallbacks[locale.language] != null
} else if(resourceKind == FileKind.Dictionary) {
Dictionaries.getDictionaryId(locale) != 0
} else {
true
}
AlertDialog( AlertDialog(
icon = { icon = {
Icon(painterResource(id = resourceKind.icon()), contentDescription = "Action") Icon(painterResource(id = resourceKind.icon()), contentDescription = "Action")
@ -81,8 +90,10 @@ fun ConfirmResourceActionDialog(
Text(text = "${locale.displayLanguage} - ${resourceKind.kindTitle()}") Text(text = "${locale.displayLanguage} - ${resourceKind.kindTitle()}")
}, },
text = { text = {
if(isCurrentlySet) { if(isCurrentlySet && hasBuiltInFallback) {
Text(text = "Would you like to delete ${resourceKind.youAreImporting()} for ${locale.displayLanguage}, or replace it with another file?") Text(text = "Would you like to revert ${resourceKind.youAreImporting()} to default for ${locale.displayLanguage}, or replace it with another file?")
} else if(isCurrentlySet) {
Text(text = "Would you like to remove the ${resourceKind.youAreImporting()} for ${locale.displayLanguage}, or replace it with another file?\n\nNo built-in ${resourceKind.youAreImporting()} exists for this language, so if you remove it, it will stop working until you import a different one!")
} else { } else {
Text(text = "No ${resourceKind.youAreImporting()} override is set for ${locale.displayLanguage}. You can explore downloads online, or import an existing file.") Text(text = "No ${resourceKind.youAreImporting()} override is set for ${locale.displayLanguage}. You can explore downloads online, or import an existing file.")
} }
@ -106,7 +117,12 @@ fun ConfirmResourceActionDialog(
dismissButton = { dismissButton = {
if(isCurrentlySet) { if(isCurrentlySet) {
TextButton(onClick = { onDelete() }) { TextButton(onClick = { onDelete() }) {
Text("Delete") if(hasBuiltInFallback) {
Text("Revert to Default")
} else {
Text("Remove")
}
} }
} else { } else {
TextButton(onClick = { onExplore() }) { TextButton(onClick = { onExplore() }) {
@ -159,7 +175,7 @@ fun LanguagesScreen(navController: NavHostController = rememberNavController())
} }
LazyColumn { LazyColumn {
item { item {
ScreenTitle("Languages", showBack = true, navController) ScreenTitle("Languages & Models", showBack = true, navController)
} }
item { item {

View File

@ -79,8 +79,8 @@ fun VoiceInputScreen(navController: NavHostController = rememberNavController())
) )
NavigationItem( NavigationItem(
title = "Languages", title = "Models",
subtitle = "To change the model, visit Languages menu", subtitle = "To change the models, visit Languages & Models menu",
style = NavigationItemStyle.Misc, style = NavigationItemStyle.Misc,
navigate = { navController.navigate("languages") } navigate = { navController.navigate("languages") }
) )