tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9a8f2f85655ff0c26e7ef05a906f1fb5c9e79f89
parent b534b9bfcbdf821b0faea865db5ab04e71aebe11
Author: t-p-white <towhite@mozilla.com>
Date:   Thu,  6 Nov 2025 15:15:24 +0000

Bug 1998389 - Part 2: Refactor locale to an enum r=android-reviewers,rebecatudor273

Differential Revision: https://phabricator.services.mozilla.com/D271413

Diffstat:
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt | 150++++++++++++++++++++++---------------------------------------------------------
Amobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Locale.kt | 114+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt | 150++++++++++++++++++++++---------------------------------------------------------
3 files changed, 198 insertions(+), 216 deletions(-)

diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt @@ -4,120 +4,54 @@ package org.mozilla.fenix.termsofuse.experimentation.utils +import org.mozilla.fenix.utils.Locale + /** * List of supported locales (language/region) for sponsored shortcuts/tiles (Top Sites). */ internal val supportedSponsoredShortcutsLocales = listOf( - // Austria - "de-AT", - - // Belgium - "de-BE", - "fr-BE", - - // Bulgaria - "bg-BG", - - // Canada - "en-CA", - - // Croatia - "hr-HR", - - // Cyprus - "el-CY", - "tr-CY", - - // Czechia - "cs-CZ", - - // Denmark - "da-DK", - - // Estonia - "et-EE", - - // Finland - "fi-FI", - "sv-FI", - - // France - "fr-FR", - - // Germany - "de-DE", - - // Greece - "el-GR", - - // Hungary - "hu-HU", - - // Iceland - "is-IS", - - // Ireland - "en-IE", - - // Latvia - "lv-LV", - - // Lithuania - "lt-LT", - - // Japan - "ja-JP", - - // Malta - "mt-MT", - - // Netherlands - "nl-NL", - - // New Zealand - "en-NZ", - - // Norway - "nb-NO", - - // Poland - "pl-PL", - - // Portugal - "pt-PT", - - // Romania - "ro-RO", - - // Singapore - "en-SG", - - // Slovakia - "sk-SK", - - // Spain - "es-ES", - - // Sweden - "sv-SE", - - // Switzerland - "de-CH", - - // UK - "en-GB", - - // US - "en-US", -) + Locale.Austria, + Locale.BelgiumGerman, + Locale.BelgiumFrench, + Locale.Bulgaria, + Locale.Canada, + Locale.Croatia, + Locale.CyprusGreek, + Locale.CyprusTurkish, + Locale.Czechia, + Locale.Denmark, + Locale.Estonia, + Locale.FinlandFinnish, + Locale.FinlandSwedish, + Locale.France, + Locale.Germany, + Locale.Greece, + Locale.Hungary, + Locale.Iceland, + Locale.Ireland, + Locale.Latvia, + Locale.Lithuania, + Locale.Japan, + Locale.Malta, + Locale.Netherlands, + Locale.NewZealand, + Locale.Norway, + Locale.Poland, + Locale.Portugal, + Locale.Romania, + Locale.Singapore, + Locale.Slovakia, + Locale.Spain, + Locale.Sweden, + Locale.Switzerland, + Locale.UnitedKingdom, + Locale.UnitedStates, +).map { it.localeCode } /** * List of supported locales (language/region) for sponsored stories. */ internal val supportedSponsoredStoriesLocales = listOf( - // US - "en-US", - - // Canada - "en-CA", -) + Locale.UnitedStates, + Locale.Canada, +).map { it.localeCode } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Locale.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Locale.kt @@ -0,0 +1,114 @@ +/* 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 + +/** + * Enum representing various locales (language–region). + * Country-only names are used when there is a single locale per country in this list. + * For countries with multiple locales, the language is appended to the country name. + */ +internal enum class Locale(val localeCode: String) { + // Austria + Austria("de-AT"), + + // Belgium (multiple) + BelgiumGerman("de-BE"), + BelgiumFrench("fr-BE"), + + // Bulgaria + Bulgaria("bg-BG"), + + // Canada + Canada("en-CA"), + + // Croatia + Croatia("hr-HR"), + + // Cyprus (multiple) + CyprusGreek("el-CY"), + CyprusTurkish("tr-CY"), + + // Czechia + Czechia("cs-CZ"), + + // Denmark + Denmark("da-DK"), + + // Estonia + Estonia("et-EE"), + + // Finland (multiple) + FinlandFinnish("fi-FI"), + FinlandSwedish("sv-FI"), + + // France + France("fr-FR"), + + // Germany + Germany("de-DE"), + + // Greece + Greece("el-GR"), + + // Hungary + Hungary("hu-HU"), + + // Iceland + Iceland("is-IS"), + + // Ireland + Ireland("en-IE"), + + // Latvia + Latvia("lv-LV"), + + // Lithuania + Lithuania("lt-LT"), + + // Japan + Japan("ja-JP"), + + // Malta + Malta("mt-MT"), + + // Netherlands + Netherlands("nl-NL"), + + // New Zealand + NewZealand("en-NZ"), + + // Norway + Norway("nb-NO"), + + // Poland + Poland("pl-PL"), + + // Portugal + Portugal("pt-PT"), + + // Romania + Romania("ro-RO"), + + // Singapore + Singapore("en-SG"), + + // Slovakia + Slovakia("sk-SK"), + + // Spain + Spain("es-ES"), + + // Sweden + Sweden("sv-SE"), + + // Switzerland + Switzerland("de-CH"), + + // United Kingdom + UnitedKingdom("en-GB"), + + // United States + UnitedStates("en-US"), +} diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt @@ -4,120 +4,54 @@ package org.mozilla.fenix.termsofuse.experimentation.utils +import org.mozilla.fenix.utils.Locale + /** * Test duplicate of [supportedSponsoredShortcutsLocales], these should be the same locales. */ internal val supportedSponsoredShortcutsLocales = listOf( - // Austria - "de-AT", - - // Belgium - "de-BE", - "fr-BE", - - // Bulgaria - "bg-BG", - - // Canada - "en-CA", - - // Croatia - "hr-HR", - - // Cyprus - "el-CY", - "tr-CY", - - // Czechia - "cs-CZ", - - // Denmark - "da-DK", - - // Estonia - "et-EE", - - // Finland - "fi-FI", - "sv-FI", - - // France - "fr-FR", - - // Germany - "de-DE", - - // Greece - "el-GR", - - // Hungary - "hu-HU", - - // Iceland - "is-IS", - - // Ireland - "en-IE", - - // Latvia - "lv-LV", - - // Lithuania - "lt-LT", - - // Japan - "ja-JP", - - // Malta - "mt-MT", - - // Netherlands - "nl-NL", - - // New Zealand - "en-NZ", - - // Norway - "nb-NO", - - // Poland - "pl-PL", - - // Portugal - "pt-PT", - - // Romania - "ro-RO", - - // Singapore - "en-SG", - - // Slovakia - "sk-SK", - - // Spain - "es-ES", - - // Sweden - "sv-SE", - - // Switzerland - "de-CH", - - // UK - "en-GB", - - // US - "en-US", -) + Locale.Austria, + Locale.BelgiumGerman, + Locale.BelgiumFrench, + Locale.Bulgaria, + Locale.Canada, + Locale.Croatia, + Locale.CyprusGreek, + Locale.CyprusTurkish, + Locale.Czechia, + Locale.Denmark, + Locale.Estonia, + Locale.FinlandFinnish, + Locale.FinlandSwedish, + Locale.France, + Locale.Germany, + Locale.Greece, + Locale.Hungary, + Locale.Iceland, + Locale.Ireland, + Locale.Latvia, + Locale.Lithuania, + Locale.Japan, + Locale.Malta, + Locale.Netherlands, + Locale.NewZealand, + Locale.Norway, + Locale.Poland, + Locale.Portugal, + Locale.Romania, + Locale.Singapore, + Locale.Slovakia, + Locale.Spain, + Locale.Sweden, + Locale.Switzerland, + Locale.UnitedKingdom, + Locale.UnitedStates, +).map { it.localeCode } /** * Test duplicate of [supportedSponsoredStoriesLocales], these should be the same locales. */ internal val supportedSponsoredStoriesLocales = listOf( - // US - "en-US", - - // Canada - "en-CA", -) + Locale.UnitedStates, + Locale.Canada, +).map { it.localeCode }