Bug 1862295 - Translations UI Integration Integrate Error States

fenix/125.0
rahulsainani 3 months ago committed by mergify[bot]
parent 06a48206e6
commit 0b15973796

@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView
import mozilla.components.support.locale.LocaleManager import mozilla.components.support.locale.LocaleManager
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.LocaleSettingsItemBinding import org.mozilla.fenix.databinding.LocaleSettingsItemBinding
import org.mozilla.fenix.utils.LocaleUtils
import java.util.Locale import java.util.Locale
class LocaleViewHolder( class LocaleViewHolder(
@ -29,7 +30,7 @@ class LocaleViewHolder(
bindChineseLocale(locale) bindChineseLocale(locale)
} else { } else {
// Capitalisation is done using the rules of the appropriate locale (endonym and exonym). // Capitalisation is done using the rules of the appropriate locale (endonym and exonym).
binding.localeTitleText.text = getDisplayName(locale) binding.localeTitleText.text = LocaleUtils.getDisplayName(locale)
// Show the given locale using the device locale for the subtitle. // Show the given locale using the device locale for the subtitle.
binding.localeSubtitleText.text = locale.getProperDisplayName() binding.localeSubtitleText.text = locale.getProperDisplayName()
} }
@ -53,224 +54,6 @@ class LocaleViewHolder(
Locale.forLanguageTag("zh-Hant").displayName.capitalize(Locale.getDefault()) Locale.forLanguageTag("zh-Hant").displayName.capitalize(Locale.getDefault())
} }
} }
private fun getDisplayName(locale: Locale): String {
val displayName = locale.getDisplayName(locale).capitalize(locale)
if (displayName.equals(locale.toString(), ignoreCase = true)) {
return LOCALE_TO_DISPLAY_NATIVE_NAME_MAP[locale.toString()] ?: displayName
}
return displayName
}
@SuppressWarnings("LargeClass")
companion object {
val LOCALE_TO_DISPLAY_NATIVE_NAME_MAP: Map<String, String> = mapOf(
"an" to "Aragonés",
"anp" to "अंगिका",
"ar" to "العربية",
"ast" to "Asturianu",
"ay" to "Aimara",
"az" to "Azərbaycan dili",
"be" to "беларуская мова",
"bg" to "български език",
"bn" to "বাংলা",
"br" to "Brezhoneg",
"bs" to "Bosanski jezik",
"ca" to "Català",
"cak" to "Kaqchikel",
"ceb" to "Cebuano",
"co" to "Corsu",
"cs" to "čeština",
"cy" to "Cymraeg",
"da" to "dansk",
"de" to "Deutsch",
"dsb" to "dolnoserbski",
"el" to "ελληνικά",
"eo" to "Esperanto",
"es" to "Español",
"et" to "Eesti",
"eu" to "Euskara",
"fa" to "فارسی",
"ff" to "Fulfulde",
"fi" to "Suomi",
"fr" to "Français",
"fy-NL" to "Frisian",
"ga-IE" to "Gaeilge",
"gd" to "Gàidhlig",
"gl" to "Galego",
"gn" to "Avañe'ẽ",
"gu-IN" to "ગુજરાતી",
"he" to "עברית",
"hi-IN" to "हिन्दी",
"hil" to "Ilonggo",
"hr" to "hrvatski jezik",
"hsb" to "Hornjoserbsce",
"hu" to "Magyar",
"hus" to "Tének",
"hy-AM" to "հայերեն",
"ia" to "Interlingua",
"id" to "Bahasa Indonesia",
"is" to "Íslenska",
"it" to "Italiano",
"ixl" to "Ixil",
"ja" to "日本語 (にほんご)",
"jv" to "Basa Jawa",
"ka" to "ქართული",
"kaa" to "Karakalpak",
"kab" to "Taqbaylit",
"kk" to "қазақ тілі",
"kmr" to "Kurmancî",
"kn" to "ಕನ್ನಡ",
"ko" to "한국어",
"lij" to "Ligure",
"lo" to "ພາສາລາວ",
"lt" to "lietuvių kalba",
"mix" to "Tu'un savi",
"ml" to "മലയാളം",
"mr" to "मराठी",
"ms" to "Bahasa Melayu ملايو‎",
"my" to "ဗမာစာ",
"meh" to "Tu´un savi ñuu Yasi'í Yuku Iti",
"nb-NO" to "Bokmål",
"ne-NP" to "नेपाली",
"nl" to "Nederlands",
"nn-NO" to "Nynorsk",
"nv" to "Diné bizaad",
"oc" to "Occitan",
"pa-IN" to "Panjābī",
"pl" to "Polszczyzna",
"pt" to "Português",
"pai" to "Paa ipai",
"ppl" to "Náhuat Pipil",
"quy" to "Chanka Qhichwa",
"quc" to "K'iche'",
"rm" to "Rumantsch Grischun",
"ro" to "Română",
"ru" to "русский",
"sat" to "ᱥᱟᱱᱛᱟᱲᱤ",
"sk" to "Slovak",
"skr" to "سرائیکی",
"sl" to "Slovenian",
"sn" to "ChiShona",
"sq" to "Shqip",
"sr" to "српски језик",
"su" to "Basa Sunda",
"sv-SE" to "Svenska",
"ta" to "தமிழ்",
"te" to "తెలుగు",
"tg" to "тоҷикӣ, toçikī, تاجیکی‎",
"th" to "ไทย",
"tl" to "Wikang Tagalog",
"tok" to "Toki Pona",
"tr" to "Türkçe",
"trs" to "Triqui",
"tt" to "татарча",
"tsz" to "P'urhepecha",
"uk" to "Українська",
"ur" to "اردو",
"uz" to "Oʻzbek",
"vec" to "Vèneto",
"vi" to "Tiếng Việt",
"wo" to "Wolof",
"zam" to "Ɂztè",
)
val LOCALE_TO_DISPLAY_ENGLISH_NAME_MAP: Map<String, String> = mapOf(
"an" to "Aragonese",
"ar" to "Arabic",
"ast" to "Asturianu",
"az" to "Azerbaijani",
"be" to "Belarusian",
"bg" to "Bulgarian",
"bn" to "Bengali",
"br" to "Breton",
"bs" to "Bosnian",
"ca" to "Catalan",
"cak" to "Kaqchikel",
"ceb" to "Cebuano",
"co" to "Corsican",
"cs" to "Czech",
"cy" to "Welsh",
"da" to "Danish",
"de" to "German",
"dsb" to "Sorbian, Lower",
"el" to "Greek",
"eo" to "Esperanto",
"es" to "Spanish",
"et" to "Estonian",
"eu" to "Basque",
"fa" to "Persian",
"ff" to "Fulah",
"fi" to "Finnish",
"fr" to "French",
"fy-NL" to "Frisian",
"ga-IE" to "Irish",
"gd" to "Gaelic",
"gl" to "Galician",
"gn" to "Guarani",
"gu-IN" to "Gujarati",
"he" to "Hebrew",
"hi-IN" to "Hindi",
"hil" to "Hiligaynon",
"hr" to "Croatian",
"hsb" to "Sorbian, Upper",
"hu" to "Hungarian",
"hy-AM" to "Armenian",
"id" to "Indonesian",
"is" to "Icelandic",
"it" to "Italian",
"ja" to "Japanese",
"ka" to "Georgian",
"kaa" to "Karakalpak",
"kab" to "Kabyle",
"kk" to "Kazakh",
"kmr" to "Kurmanji Kurdish",
"kn" to "Kannada",
"ko" to "Korean",
"lij" to "Ligurian",
"lo" to "Lao",
"lt" to "Lithuanian",
"mix" to "Mixtepec Mixtec",
"ml" to "Malayalam",
"mr" to "Marathi",
"ms" to "Malay",
"my" to "Burmese",
"nb-NO" to "Norwegian Bokmål",
"ne-NP" to "Nepali",
"nl" to "Dutch, Flemish",
"nn-NO" to "Norwegian Nynorsk",
"nv" to "Navajo, Navaho",
"oc" to "Occitan",
"pa-IN" to "Punjabi",
"pl" to "Polish",
"pt-BR" to "",
"pt-PT" to "",
"rm" to "Romansh",
"ro" to "Română",
"ru" to "Russian",
"sat" to "Santali",
"sk" to "Slovak",
"skr" to "Saraiki",
"sl" to "Slovenian",
"sq" to "Albanian",
"sr" to "Serbian",
"su" to "Sundanese",
"sv-SE" to "Swedish",
"ta" to "Tamil",
"te" to "Telugu",
"tg" to "Tajik",
"th" to "Thai",
"tl" to "Tagalog",
"tok" to "Toki Pona",
"tr" to "Turkish",
"trs" to "Triqui",
"uk" to "Ukrainian",
"ur" to "Urdu",
"uz" to "Uzbek",
"vec" to "Venitian",
"vi" to "Vietnamese",
)
}
} }
class SystemLocaleViewHolder( class SystemLocaleViewHolder(
@ -330,7 +113,7 @@ private fun String.capitalize(locale: Locale): String {
private fun Locale.getProperDisplayName(): String { private fun Locale.getProperDisplayName(): String {
val displayName = this.displayName.capitalize(Locale.getDefault()) val displayName = this.displayName.capitalize(Locale.getDefault())
if (displayName.equals(this.toString(), ignoreCase = true)) { if (displayName.equals(this.toString(), ignoreCase = true)) {
return LocaleViewHolder.LOCALE_TO_DISPLAY_ENGLISH_NAME_MAP[this.toString()] ?: displayName return LocaleUtils.LOCALE_TO_DISPLAY_ENGLISH_NAME_MAP[this.toString()] ?: displayName
} }
return displayName return displayName
} }

@ -15,6 +15,8 @@ import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.translate.initialFromLanguage import mozilla.components.concept.engine.translate.initialFromLanguage
import mozilla.components.concept.engine.translate.initialToLanguage import mozilla.components.concept.engine.translate.initialToLanguage
import mozilla.components.lib.state.helpers.AbstractBinding import mozilla.components.lib.state.helpers.AbstractBinding
import org.mozilla.fenix.utils.LocaleUtils
import java.util.Locale
/** /**
* Helper for observing Translation state from both [BrowserState.translationEngine] * Helper for observing Translation state from both [BrowserState.translationEngine]
@ -130,8 +132,17 @@ class TranslationsDialogBinding(
// A session error may override a browser error // A session error may override a browser error
if (sessionTranslationsState.translationError != null) { if (sessionTranslationsState.translationError != null) {
var documentLangDisplayName: String? = null
sessionTranslationsState.translationEngineState?.detectedLanguages?.documentLangTag?.let {
val documentLanguage = Locale.forLanguageTag(it)
documentLangDisplayName = LocaleUtils.getDisplayName(documentLanguage)
}
translationsDialogStore.dispatch( translationsDialogStore.dispatch(
TranslationsDialogAction.UpdateTranslationError(sessionTranslationsState.translationError), TranslationsDialogAction.UpdateTranslationError(
translationError = sessionTranslationsState.translationError,
documentLangDisplayName = documentLangDisplayName,
),
) )
} }

@ -157,13 +157,9 @@ private fun DialogContentBaseOnTranslationState(
) { ) {
if (translationsDialogState.error != null) { if (translationsDialogState.error != null) {
DialogContentAnErrorOccurred( DialogContentAnErrorOccurred(
error = translationsDialogState.error, translationsDialogState = translationsDialogState,
learnMoreUrl = learnMoreUrl, learnMoreUrl = learnMoreUrl,
onLearnMoreClicked = onLearnMoreClicked, onLearnMoreClicked = onLearnMoreClicked,
fromLanguages = translationsDialogState.fromLanguages,
toLanguages = translationsDialogState.toLanguages,
initialFrom = translationsDialogState.initialFrom,
initialTo = translationsDialogState.initialTo,
onFromDropdownSelected = onFromDropdownSelected, onFromDropdownSelected = onFromDropdownSelected,
onToDropdownSelected = onToDropdownSelected, onToDropdownSelected = onToDropdownSelected,
onPositiveButtonClicked = onPositiveButtonClicked, onPositiveButtonClicked = onPositiveButtonClicked,
@ -247,13 +243,9 @@ private fun DialogContentTranslated(
/** /**
* Dialog content if an [TranslationError] appears during the translation process. * Dialog content if an [TranslationError] appears during the translation process.
* *
* @param error An error that can occur during the translation process. * @param translationsDialogState The current state of the Translations bottom sheet dialog.
* @param learnMoreUrl The learn more link for translations website. * @param learnMoreUrl The learn more link for translations website.
* @param onLearnMoreClicked Invoked when the user clicks on the learn more button. * @param onLearnMoreClicked Invoked when the user clicks on the learn more button.
* @param fromLanguages Translation menu items to be shown in the translate from dropdown.
* @param toLanguages Translation menu items to be shown in the translate to dropdown.
* @param initialFrom Initial "from" language, based on the translation state and page state.
* @param initialTo Initial "to" language, based on the translation state and page state.
* @param onFromDropdownSelected Invoked when the user selects an item on the from dropdown. * @param onFromDropdownSelected Invoked when the user selects an item on the from dropdown.
* @param onToDropdownSelected Invoked when the user selects an item on the to dropdown. * @param onToDropdownSelected Invoked when the user selects an item on the to dropdown.
* @param onPositiveButtonClicked Invoked when the user clicks on the positive button. * @param onPositiveButtonClicked Invoked when the user clicks on the positive button.
@ -262,62 +254,64 @@ private fun DialogContentTranslated(
@Suppress("LongParameterList") @Suppress("LongParameterList")
@Composable @Composable
private fun DialogContentAnErrorOccurred( private fun DialogContentAnErrorOccurred(
error: TranslationError, translationsDialogState: TranslationsDialogState,
learnMoreUrl: String, learnMoreUrl: String,
onLearnMoreClicked: () -> Unit, onLearnMoreClicked: () -> Unit,
fromLanguages: List<Language>?,
toLanguages: List<Language>?,
initialFrom: Language? = null,
initialTo: Language? = null,
onFromDropdownSelected: (Language) -> Unit, onFromDropdownSelected: (Language) -> Unit,
onToDropdownSelected: (Language) -> Unit, onToDropdownSelected: (Language) -> Unit,
onPositiveButtonClicked: () -> Unit, onPositiveButtonClicked: () -> Unit,
onNegativeButtonClicked: () -> Unit, onNegativeButtonClicked: () -> Unit,
) { ) {
TranslationErrorWarning( translationsDialogState.error?.let { translationError ->
error, TranslationErrorWarning(
learnMoreUrl = learnMoreUrl, translationError = translationError,
onLearnMoreClicked = onLearnMoreClicked, documentLangDisplayName = translationsDialogState.documentLangDisplayName,
) learnMoreUrl = learnMoreUrl,
onLearnMoreClicked = onLearnMoreClicked,
)
Spacer(modifier = Modifier.height(14.dp)) Spacer(modifier = Modifier.height(14.dp))
if (error !is TranslationError.CouldNotLoadLanguagesError) { if (translationError !is TranslationError.CouldNotLoadLanguagesError) {
TranslationsDialogContent( TranslationsDialogContent(
translateFromLanguages = fromLanguages, translateFromLanguages = translationsDialogState.fromLanguages,
translateToLanguages = toLanguages, translateToLanguages = translationsDialogState.toLanguages,
initialFrom = initialFrom, initialFrom = translationsDialogState.initialFrom,
initialTo = initialTo, initialTo = translationsDialogState.initialTo,
onFromDropdownSelected = onFromDropdownSelected, onFromDropdownSelected = onFromDropdownSelected,
onToDropdownSelected = onToDropdownSelected, onToDropdownSelected = onToDropdownSelected,
) )
} }
val negativeButtonTitle = if (error is TranslationError.LanguageNotSupportedError) { val negativeButtonTitle =
stringResource(id = R.string.translations_bottom_sheet_negative_button_error) if (translationError is TranslationError.LanguageNotSupportedError) {
} else { stringResource(id = R.string.translations_bottom_sheet_negative_button_error)
stringResource(id = R.string.translations_bottom_sheet_negative_button) } else {
} stringResource(id = R.string.translations_bottom_sheet_negative_button)
}
val positiveButtonTitle = if (error is TranslationError.CouldNotLoadLanguagesError) { val positiveButtonTitle =
stringResource(id = R.string.translations_bottom_sheet_positive_button_error) if (translationError is TranslationError.CouldNotLoadLanguagesError) {
} else { stringResource(id = R.string.translations_bottom_sheet_positive_button_error)
stringResource(id = R.string.translations_bottom_sheet_positive_button) } else {
} stringResource(id = R.string.translations_bottom_sheet_positive_button)
}
val positiveButtonType = if (error is TranslationError.LanguageNotSupportedError) { val positiveButtonType =
PositiveButtonType.Disabled if (translationError is TranslationError.LanguageNotSupportedError) {
} else { PositiveButtonType.Disabled
PositiveButtonType.Enabled } else {
} PositiveButtonType.Enabled
}
TranslationsDialogActionButtons( TranslationsDialogActionButtons(
positiveButtonText = positiveButtonTitle, positiveButtonText = positiveButtonTitle,
negativeButtonText = negativeButtonTitle, negativeButtonText = negativeButtonTitle,
positiveButtonType = positiveButtonType, positiveButtonType = positiveButtonType,
onNegativeButtonClicked = onNegativeButtonClicked, onNegativeButtonClicked = onNegativeButtonClicked,
onPositiveButtonClicked = onPositiveButtonClicked, onPositiveButtonClicked = onPositiveButtonClicked,
) )
}
} }
@Composable @Composable
@ -474,6 +468,7 @@ private fun TranslationsDialogHeader(
@Composable @Composable
private fun TranslationErrorWarning( private fun TranslationErrorWarning(
translationError: TranslationError, translationError: TranslationError,
documentLangDisplayName: String? = null,
learnMoreUrl: String, learnMoreUrl: String,
onLearnMoreClicked: () -> Unit, onLearnMoreClicked: () -> Unit,
) { ) {
@ -502,21 +497,23 @@ private fun TranslationErrorWarning(
val learnMoreText = val learnMoreText =
stringResource(id = R.string.translation_error_language_not_supported_learn_more) stringResource(id = R.string.translation_error_language_not_supported_learn_more)
ReviewQualityCheckInfoCard( documentLangDisplayName?.let {
title = stringResource( ReviewQualityCheckInfoCard(
id = R.string.translation_error_language_not_supported_warning_text, title = stringResource(
"Uzbek", id = R.string.translation_error_language_not_supported_warning_text,
), it,
type = ReviewQualityCheckInfoType.Info, ),
modifier = modifier, type = ReviewQualityCheckInfoType.Info,
footer = stringResource( modifier = modifier,
id = R.string.translation_error_language_not_supported_learn_more, footer = stringResource(
) to LinkTextState( id = R.string.translation_error_language_not_supported_learn_more,
text = learnMoreText, ) to LinkTextState(
url = learnMoreUrl, text = learnMoreText,
onClick = { onLearnMoreClicked() }, url = learnMoreUrl,
), onClick = { onLearnMoreClicked() },
) ),
)
}
} }
else -> {} else -> {}

@ -41,6 +41,8 @@ class TranslationsDialogStore(
* @property translationDownloadSize A data class to contain information * @property translationDownloadSize A data class to contain information
* related to the download size required for a given translation to/from pair. * related to the download size required for a given translation to/from pair.
* @property error An error that can occur during the translation process. * @property error An error that can occur during the translation process.
* @property documentLangDisplayName Language name to display in
* case [TranslationError.LanguageNotSupportedError] appears.
* @property dismissDialogState Whether the dialog bottom sheet should be dismissed. * @property dismissDialogState Whether the dialog bottom sheet should be dismissed.
* @property initialFrom Initial "from" language, based on the translation state and page state. * @property initialFrom Initial "from" language, based on the translation state and page state.
* @property initialTo Initial "to" language, based on the translation state and page state. * @property initialTo Initial "to" language, based on the translation state and page state.
@ -54,6 +56,7 @@ data class TranslationsDialogState(
val positiveButtonType: PositiveButtonType? = null, val positiveButtonType: PositiveButtonType? = null,
val translationDownloadSize: TranslationDownloadSize? = null, val translationDownloadSize: TranslationDownloadSize? = null,
val error: TranslationError? = null, val error: TranslationError? = null,
val documentLangDisplayName: String? = null,
val dismissDialogState: DismissDialogState? = null, val dismissDialogState: DismissDialogState? = null,
val initialFrom: Language? = null, val initialFrom: Language? = null,
val initialTo: Language? = null, val initialTo: Language? = null,
@ -101,6 +104,7 @@ sealed class TranslationsDialogAction : Action {
*/ */
data class UpdateTranslationError( data class UpdateTranslationError(
val translationError: TranslationError? = null, val translationError: TranslationError? = null,
val documentLangDisplayName: String? = null,
) : TranslationsDialogAction() ) : TranslationsDialogAction()
/** /**
@ -285,6 +289,7 @@ internal object TranslationsDialogReducer {
is TranslationsDialogAction.UpdateTranslationError -> { is TranslationsDialogAction.UpdateTranslationError -> {
state.copy( state.copy(
error = action.translationError, error = action.translationError,
documentLangDisplayName = action.documentLangDisplayName,
positiveButtonType = if (action.translationError is TranslationError.LanguageNotSupportedError) { positiveButtonType = if (action.translationError is TranslationError.LanguageNotSupportedError) {
PositiveButtonType.Disabled PositiveButtonType.Disabled
} else { } else {

@ -0,0 +1,232 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.utils
import java.util.Locale
/**
* Helper class for displaying Locale name.
*/
object LocaleUtils {
/**
* Returns a name for the locale that is appropriate for display to the user.
*/
fun getDisplayName(locale: Locale): String {
val displayName = locale.getDisplayName(locale)
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }
if (displayName.equals(locale.toString(), ignoreCase = true)) {
return LOCALE_TO_DISPLAY_NATIVE_NAME_MAP[locale.toString()] ?: displayName
}
return displayName
}
private val LOCALE_TO_DISPLAY_NATIVE_NAME_MAP: Map<String, String> = mapOf(
"an" to "Aragonés",
"anp" to "अंगिका",
"ar" to "العربية",
"ast" to "Asturianu",
"ay" to "Aimara",
"az" to "Azərbaycan dili",
"be" to "беларуская мова",
"bg" to "български език",
"bn" to "বাংলা",
"br" to "Brezhoneg",
"bs" to "Bosanski jezik",
"ca" to "Català",
"cak" to "Kaqchikel",
"ceb" to "Cebuano",
"co" to "Corsu",
"cs" to "čeština",
"cy" to "Cymraeg",
"da" to "dansk",
"de" to "Deutsch",
"dsb" to "dolnoserbski",
"el" to "ελληνικά",
"eo" to "Esperanto",
"es" to "Español",
"et" to "Eesti",
"eu" to "Euskara",
"fa" to "فارسی",
"ff" to "Fulfulde",
"fi" to "Suomi",
"fr" to "Français",
"fy-NL" to "Frisian",
"ga-IE" to "Gaeilge",
"gd" to "Gàidhlig",
"gl" to "Galego",
"gn" to "Avañe'ẽ",
"gu-IN" to "ગુજરાતી",
"he" to "עברית",
"hi-IN" to "हिन्दी",
"hil" to "Ilonggo",
"hr" to "hrvatski jezik",
"hsb" to "Hornjoserbsce",
"hu" to "Magyar",
"hus" to "Tének",
"hy-AM" to "հայերեն",
"ia" to "Interlingua",
"id" to "Bahasa Indonesia",
"is" to "Íslenska",
"it" to "Italiano",
"ixl" to "Ixil",
"ja" to "日本語 (にほんご)",
"jv" to "Basa Jawa",
"ka" to "ქართული",
"kaa" to "Karakalpak",
"kab" to "Taqbaylit",
"kk" to "қазақ тілі",
"kmr" to "Kurmancî",
"kn" to "ಕನ್ನಡ",
"ko" to "한국어",
"lij" to "Ligure",
"lo" to "ພາສາລາວ",
"lt" to "lietuvių kalba",
"mix" to "Tu'un savi",
"ml" to "മലയാളം",
"mr" to "मराठी",
"ms" to "Bahasa Melayu ملايو‎",
"my" to "ဗမာစာ",
"meh" to "Tu´un savi ñuu Yasi'í Yuku Iti",
"nb-NO" to "Bokmål",
"ne-NP" to "नेपाली",
"nl" to "Nederlands",
"nn-NO" to "Nynorsk",
"nv" to "Diné bizaad",
"oc" to "Occitan",
"pa-IN" to "Panjābī",
"pl" to "Polszczyzna",
"pt" to "Português",
"pai" to "Paa ipai",
"ppl" to "Náhuat Pipil",
"quy" to "Chanka Qhichwa",
"quc" to "K'iche'",
"rm" to "Rumantsch Grischun",
"ro" to "Română",
"ru" to "русский",
"sat" to "ᱥᱟᱱᱛᱟᱲᱤ",
"sk" to "Slovak",
"skr" to "سرائیکی",
"sl" to "Slovenian",
"sn" to "ChiShona",
"sq" to "Shqip",
"sr" to "српски језик",
"su" to "Basa Sunda",
"sv-SE" to "Svenska",
"ta" to "தமிழ்",
"te" to "తెలుగు",
"tg" to "тоҷикӣ, toçikī, تاجیکی‎",
"th" to "ไทย",
"tl" to "Wikang Tagalog",
"tok" to "Toki Pona",
"tr" to "Türkçe",
"trs" to "Triqui",
"tt" to "татарча",
"tsz" to "P'urhepecha",
"uk" to "Українська",
"ur" to "اردو",
"uz" to "Oʻzbek",
"vec" to "Vèneto",
"vi" to "Tiếng Việt",
"wo" to "Wolof",
"zam" to "Ɂztè",
)
val LOCALE_TO_DISPLAY_ENGLISH_NAME_MAP: Map<String, String> = mapOf(
"an" to "Aragonese",
"ar" to "Arabic",
"ast" to "Asturianu",
"az" to "Azerbaijani",
"be" to "Belarusian",
"bg" to "Bulgarian",
"bn" to "Bengali",
"br" to "Breton",
"bs" to "Bosnian",
"ca" to "Catalan",
"cak" to "Kaqchikel",
"ceb" to "Cebuano",
"co" to "Corsican",
"cs" to "Czech",
"cy" to "Welsh",
"da" to "Danish",
"de" to "German",
"dsb" to "Sorbian, Lower",
"el" to "Greek",
"eo" to "Esperanto",
"es" to "Spanish",
"et" to "Estonian",
"eu" to "Basque",
"fa" to "Persian",
"ff" to "Fulah",
"fi" to "Finnish",
"fr" to "French",
"fy-NL" to "Frisian",
"ga-IE" to "Irish",
"gd" to "Gaelic",
"gl" to "Galician",
"gn" to "Guarani",
"gu-IN" to "Gujarati",
"he" to "Hebrew",
"hi-IN" to "Hindi",
"hil" to "Hiligaynon",
"hr" to "Croatian",
"hsb" to "Sorbian, Upper",
"hu" to "Hungarian",
"hy-AM" to "Armenian",
"id" to "Indonesian",
"is" to "Icelandic",
"it" to "Italian",
"ja" to "Japanese",
"ka" to "Georgian",
"kaa" to "Karakalpak",
"kab" to "Kabyle",
"kk" to "Kazakh",
"kmr" to "Kurmanji Kurdish",
"kn" to "Kannada",
"ko" to "Korean",
"lij" to "Ligurian",
"lo" to "Lao",
"lt" to "Lithuanian",
"mix" to "Mixtepec Mixtec",
"ml" to "Malayalam",
"mr" to "Marathi",
"ms" to "Malay",
"my" to "Burmese",
"nb-NO" to "Norwegian Bokmål",
"ne-NP" to "Nepali",
"nl" to "Dutch, Flemish",
"nn-NO" to "Norwegian Nynorsk",
"nv" to "Navajo, Navaho",
"oc" to "Occitan",
"pa-IN" to "Punjabi",
"pl" to "Polish",
"pt-BR" to "",
"pt-PT" to "",
"rm" to "Romansh",
"ro" to "Română",
"ru" to "Russian",
"sat" to "Santali",
"sk" to "Slovak",
"skr" to "Saraiki",
"sl" to "Slovenian",
"sq" to "Albanian",
"sr" to "Serbian",
"su" to "Sundanese",
"sv-SE" to "Swedish",
"ta" to "Tamil",
"te" to "Telugu",
"tg" to "Tajik",
"th" to "Thai",
"tl" to "Tagalog",
"tok" to "Toki Pona",
"tr" to "Turkish",
"trs" to "Triqui",
"uk" to "Ukrainian",
"ur" to "Urdu",
"uz" to "Uzbek",
"vec" to "Venitian",
"vi" to "Vietnamese",
)
}

@ -163,14 +163,16 @@ class TranslationsDialogReducerTest {
val updatedState = TranslationsDialogReducer.reduce( val updatedState = TranslationsDialogReducer.reduce(
translationsDialogState, translationsDialogState,
TranslationsDialogAction.UpdateTranslationError( TranslationsDialogAction.UpdateTranslationError(
TranslationError.LanguageNotSupportedError( translationError = TranslationError.LanguageNotSupportedError(
null, null,
), ),
documentLangDisplayName = "Deutsch",
), ),
) )
assertTrue(updatedState.error is TranslationError.LanguageNotSupportedError) assertTrue(updatedState.error is TranslationError.LanguageNotSupportedError)
assertEquals(PositiveButtonType.Disabled, updatedState.positiveButtonType) assertEquals(PositiveButtonType.Disabled, updatedState.positiveButtonType)
assertEquals(updatedState.documentLangDisplayName, "Deutsch")
val updatedStateTwo = TranslationsDialogReducer.reduce( val updatedStateTwo = TranslationsDialogReducer.reduce(
translationsDialogState, translationsDialogState,

Loading…
Cancel
Save