-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In {{tts-voices:}} we require a method which converts from a locale provided from the TTS Engine, and produce an Anki-compatible Two Letter ISO Code spa-MEX => es-MX This is not possible within `Locale` In Android 24+, this can be handled by the ULocale class In Android 23: We we have a list of system locales in the correct format Use the ISO-3 code to map to the system locales, and use their data Issue 14358
- Loading branch information
1 parent
90d9870
commit 9615918
Showing
4 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
AnkiDroid/src/androidTest/java/com/ichi2/anki/compat/CompatNormalizeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2023 David Allison <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 3 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.anki.compat | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.ichi2.anki.tests.InstrumentedTest | ||
import com.ichi2.compat.CompatHelper | ||
import org.hamcrest.CoreMatchers.equalTo | ||
import org.hamcrest.MatcherAssert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.util.Locale | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class CompatNormalizeTest : InstrumentedTest() { | ||
@Test | ||
fun normalize() { | ||
fun assertEqual(l: Locale, str: String) { | ||
val normalized = CompatHelper.compat.normalize(l) | ||
assertThat(normalized.toLanguageTag(), equalTo(str)) | ||
} | ||
|
||
assertEqual(Locale("en", "GB"), "en-GB") | ||
assertEqual(Locale("es", "MX"), "es-MX") | ||
assertEqual(Locale("spa", "MEX"), "es-MX") | ||
assertEqual(Locale("fil", "PH"), "fil-PH") | ||
// TBC | ||
assertEqual(Locale("ar", ""), "ar") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters