diff --git a/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleViewHolders.kt b/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleViewHolders.kt index cd6e8df29..2f86cbc51 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleViewHolders.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleViewHolders.kt @@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView import mozilla.components.support.locale.LocaleManager import org.mozilla.fenix.R import org.mozilla.fenix.databinding.LocaleSettingsItemBinding +import org.mozilla.fenix.utils.LocaleUtils import java.util.Locale class LocaleViewHolder( @@ -29,7 +30,7 @@ class LocaleViewHolder( bindChineseLocale(locale) } else { // 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. binding.localeSubtitleText.text = locale.getProperDisplayName() } @@ -53,224 +54,6 @@ class LocaleViewHolder( 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 = 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 "DíɁztè", - ) - - val LOCALE_TO_DISPLAY_ENGLISH_NAME_MAP: Map = 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( @@ -330,7 +113,7 @@ private fun String.capitalize(locale: Locale): String { private fun Locale.getProperDisplayName(): String { val displayName = this.displayName.capitalize(Locale.getDefault()) 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 } diff --git a/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBinding.kt b/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBinding.kt index 8b106096c..26aa45191 100644 --- a/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBinding.kt +++ b/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBinding.kt @@ -15,6 +15,8 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.translate.initialFromLanguage import mozilla.components.concept.engine.translate.initialToLanguage 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] @@ -130,8 +132,17 @@ class TranslationsDialogBinding( // A session error may override a browser error if (sessionTranslationsState.translationError != null) { + var documentLangDisplayName: String? = null + sessionTranslationsState.translationEngineState?.detectedLanguages?.documentLangTag?.let { + val documentLanguage = Locale.forLanguageTag(it) + documentLangDisplayName = LocaleUtils.getDisplayName(documentLanguage) + } + translationsDialogStore.dispatch( - TranslationsDialogAction.UpdateTranslationError(sessionTranslationsState.translationError), + TranslationsDialogAction.UpdateTranslationError( + translationError = sessionTranslationsState.translationError, + documentLangDisplayName = documentLangDisplayName, + ), ) } diff --git a/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBottomSheet.kt b/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBottomSheet.kt index fd0be1f47..54f545b9e 100644 --- a/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBottomSheet.kt +++ b/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogBottomSheet.kt @@ -157,13 +157,9 @@ private fun DialogContentBaseOnTranslationState( ) { if (translationsDialogState.error != null) { DialogContentAnErrorOccurred( - error = translationsDialogState.error, + translationsDialogState = translationsDialogState, learnMoreUrl = learnMoreUrl, onLearnMoreClicked = onLearnMoreClicked, - fromLanguages = translationsDialogState.fromLanguages, - toLanguages = translationsDialogState.toLanguages, - initialFrom = translationsDialogState.initialFrom, - initialTo = translationsDialogState.initialTo, onFromDropdownSelected = onFromDropdownSelected, onToDropdownSelected = onToDropdownSelected, onPositiveButtonClicked = onPositiveButtonClicked, @@ -247,13 +243,9 @@ private fun DialogContentTranslated( /** * 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 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 onToDropdownSelected Invoked when the user selects an item on the to dropdown. * @param onPositiveButtonClicked Invoked when the user clicks on the positive button. @@ -262,62 +254,64 @@ private fun DialogContentTranslated( @Suppress("LongParameterList") @Composable private fun DialogContentAnErrorOccurred( - error: TranslationError, + translationsDialogState: TranslationsDialogState, learnMoreUrl: String, onLearnMoreClicked: () -> Unit, - fromLanguages: List?, - toLanguages: List?, - initialFrom: Language? = null, - initialTo: Language? = null, onFromDropdownSelected: (Language) -> Unit, onToDropdownSelected: (Language) -> Unit, onPositiveButtonClicked: () -> Unit, onNegativeButtonClicked: () -> Unit, ) { - TranslationErrorWarning( - error, - learnMoreUrl = learnMoreUrl, - onLearnMoreClicked = onLearnMoreClicked, - ) + translationsDialogState.error?.let { translationError -> + TranslationErrorWarning( + translationError = translationError, + documentLangDisplayName = translationsDialogState.documentLangDisplayName, + learnMoreUrl = learnMoreUrl, + onLearnMoreClicked = onLearnMoreClicked, + ) - Spacer(modifier = Modifier.height(14.dp)) + Spacer(modifier = Modifier.height(14.dp)) - if (error !is TranslationError.CouldNotLoadLanguagesError) { - TranslationsDialogContent( - translateFromLanguages = fromLanguages, - translateToLanguages = toLanguages, - initialFrom = initialFrom, - initialTo = initialTo, - onFromDropdownSelected = onFromDropdownSelected, - onToDropdownSelected = onToDropdownSelected, - ) - } + if (translationError !is TranslationError.CouldNotLoadLanguagesError) { + TranslationsDialogContent( + translateFromLanguages = translationsDialogState.fromLanguages, + translateToLanguages = translationsDialogState.toLanguages, + initialFrom = translationsDialogState.initialFrom, + initialTo = translationsDialogState.initialTo, + onFromDropdownSelected = onFromDropdownSelected, + onToDropdownSelected = onToDropdownSelected, + ) + } - val negativeButtonTitle = if (error is TranslationError.LanguageNotSupportedError) { - stringResource(id = R.string.translations_bottom_sheet_negative_button_error) - } else { - stringResource(id = R.string.translations_bottom_sheet_negative_button) - } + val negativeButtonTitle = + if (translationError is TranslationError.LanguageNotSupportedError) { + stringResource(id = R.string.translations_bottom_sheet_negative_button_error) + } else { + stringResource(id = R.string.translations_bottom_sheet_negative_button) + } - val positiveButtonTitle = if (error is TranslationError.CouldNotLoadLanguagesError) { - stringResource(id = R.string.translations_bottom_sheet_positive_button_error) - } else { - stringResource(id = R.string.translations_bottom_sheet_positive_button) - } + val positiveButtonTitle = + if (translationError is TranslationError.CouldNotLoadLanguagesError) { + stringResource(id = R.string.translations_bottom_sheet_positive_button_error) + } else { + stringResource(id = R.string.translations_bottom_sheet_positive_button) + } - val positiveButtonType = if (error is TranslationError.LanguageNotSupportedError) { - PositiveButtonType.Disabled - } else { - PositiveButtonType.Enabled - } + val positiveButtonType = + if (translationError is TranslationError.LanguageNotSupportedError) { + PositiveButtonType.Disabled + } else { + PositiveButtonType.Enabled + } - TranslationsDialogActionButtons( - positiveButtonText = positiveButtonTitle, - negativeButtonText = negativeButtonTitle, - positiveButtonType = positiveButtonType, - onNegativeButtonClicked = onNegativeButtonClicked, - onPositiveButtonClicked = onPositiveButtonClicked, - ) + TranslationsDialogActionButtons( + positiveButtonText = positiveButtonTitle, + negativeButtonText = negativeButtonTitle, + positiveButtonType = positiveButtonType, + onNegativeButtonClicked = onNegativeButtonClicked, + onPositiveButtonClicked = onPositiveButtonClicked, + ) + } } @Composable @@ -474,6 +468,7 @@ private fun TranslationsDialogHeader( @Composable private fun TranslationErrorWarning( translationError: TranslationError, + documentLangDisplayName: String? = null, learnMoreUrl: String, onLearnMoreClicked: () -> Unit, ) { @@ -502,21 +497,23 @@ private fun TranslationErrorWarning( val learnMoreText = stringResource(id = R.string.translation_error_language_not_supported_learn_more) - ReviewQualityCheckInfoCard( - title = stringResource( - id = R.string.translation_error_language_not_supported_warning_text, - "Uzbek", - ), - type = ReviewQualityCheckInfoType.Info, - modifier = modifier, - footer = stringResource( - id = R.string.translation_error_language_not_supported_learn_more, - ) to LinkTextState( - text = learnMoreText, - url = learnMoreUrl, - onClick = { onLearnMoreClicked() }, - ), - ) + documentLangDisplayName?.let { + ReviewQualityCheckInfoCard( + title = stringResource( + id = R.string.translation_error_language_not_supported_warning_text, + it, + ), + type = ReviewQualityCheckInfoType.Info, + modifier = modifier, + footer = stringResource( + id = R.string.translation_error_language_not_supported_learn_more, + ) to LinkTextState( + text = learnMoreText, + url = learnMoreUrl, + onClick = { onLearnMoreClicked() }, + ), + ) + } } else -> {} diff --git a/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogStore.kt b/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogStore.kt index ac190e31b..5599d6041 100644 --- a/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogStore.kt +++ b/app/src/main/java/org/mozilla/fenix/translations/TranslationsDialogStore.kt @@ -41,6 +41,8 @@ class TranslationsDialogStore( * @property translationDownloadSize A data class to contain information * 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 documentLangDisplayName Language name to display in + * case [TranslationError.LanguageNotSupportedError] appears. * @property dismissDialogState Whether the dialog bottom sheet should be dismissed. * @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. @@ -54,6 +56,7 @@ data class TranslationsDialogState( val positiveButtonType: PositiveButtonType? = null, val translationDownloadSize: TranslationDownloadSize? = null, val error: TranslationError? = null, + val documentLangDisplayName: String? = null, val dismissDialogState: DismissDialogState? = null, val initialFrom: Language? = null, val initialTo: Language? = null, @@ -101,6 +104,7 @@ sealed class TranslationsDialogAction : Action { */ data class UpdateTranslationError( val translationError: TranslationError? = null, + val documentLangDisplayName: String? = null, ) : TranslationsDialogAction() /** @@ -285,6 +289,7 @@ internal object TranslationsDialogReducer { is TranslationsDialogAction.UpdateTranslationError -> { state.copy( error = action.translationError, + documentLangDisplayName = action.documentLangDisplayName, positiveButtonType = if (action.translationError is TranslationError.LanguageNotSupportedError) { PositiveButtonType.Disabled } else { diff --git a/app/src/main/java/org/mozilla/fenix/utils/LocaleUtils.kt b/app/src/main/java/org/mozilla/fenix/utils/LocaleUtils.kt new file mode 100644 index 000000000..ab30a6a75 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/utils/LocaleUtils.kt @@ -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 = 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 "DíɁztè", + ) + + val LOCALE_TO_DISPLAY_ENGLISH_NAME_MAP: Map = 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", + ) +} diff --git a/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogReducerTest.kt b/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogReducerTest.kt index a70b33548..0fffa0a89 100644 --- a/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogReducerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogReducerTest.kt @@ -163,14 +163,16 @@ class TranslationsDialogReducerTest { val updatedState = TranslationsDialogReducer.reduce( translationsDialogState, TranslationsDialogAction.UpdateTranslationError( - TranslationError.LanguageNotSupportedError( + translationError = TranslationError.LanguageNotSupportedError( null, ), + documentLangDisplayName = "Deutsch", ), ) assertTrue(updatedState.error is TranslationError.LanguageNotSupportedError) assertEquals(PositiveButtonType.Disabled, updatedState.positiveButtonType) + assertEquals(updatedState.documentLangDisplayName, "Deutsch") val updatedStateTwo = TranslationsDialogReducer.reduce( translationsDialogState,