Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4305: Add support for Swahili translations (app strings and content) #4307

Merged
merged 4 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.oppia.android.app.model.OppiaLanguage.HINDI
import org.oppia.android.app.model.OppiaLanguage.HINGLISH
import org.oppia.android.app.model.OppiaLanguage.LANGUAGE_UNSPECIFIED
import org.oppia.android.app.model.OppiaLanguage.PORTUGUESE
import org.oppia.android.app.model.OppiaLanguage.SWAHILI
import org.oppia.android.app.model.OppiaLanguage.UNRECOGNIZED
import org.oppia.android.app.model.Real.RealTypeCase.INTEGER
import org.oppia.android.app.model.Real.RealTypeCase.IRRATIONAL
Expand Down Expand Up @@ -71,7 +72,7 @@ class MathExpressionAccessibilityUtil @Inject constructor(
): String? {
return when (language) {
ENGLISH -> expression.toHumanReadableEnglishString(divAsFraction)
ARABIC, HINDI, HINGLISH, PORTUGUESE, BRAZILIAN_PORTUGUESE, LANGUAGE_UNSPECIFIED,
ARABIC, HINDI, HINGLISH, PORTUGUESE, BRAZILIAN_PORTUGUESE, SWAHILI, LANGUAGE_UNSPECIFIED,
UNRECOGNIZED -> null
}
}
Expand All @@ -90,7 +91,7 @@ class MathExpressionAccessibilityUtil @Inject constructor(
): String? {
return when (language) {
ENGLISH -> equation.toHumanReadableEnglishString(divAsFraction)
ARABIC, HINDI, HINGLISH, PORTUGUESE, BRAZILIAN_PORTUGUESE, LANGUAGE_UNSPECIFIED,
ARABIC, HINDI, HINGLISH, PORTUGUESE, BRAZILIAN_PORTUGUESE, SWAHILI, LANGUAGE_UNSPECIFIED,
UNRECOGNIZED -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.oppia.android.app.model.OppiaLanguage.HINDI
import org.oppia.android.app.model.OppiaLanguage.HINGLISH
import org.oppia.android.app.model.OppiaLanguage.LANGUAGE_UNSPECIFIED
import org.oppia.android.app.model.OppiaLanguage.PORTUGUESE
import org.oppia.android.app.model.OppiaLanguage.SWAHILI
import org.oppia.android.app.model.OppiaLanguage.UNRECOGNIZED
import org.oppia.android.app.model.Real
import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule
Expand Down Expand Up @@ -169,6 +170,7 @@ class MathExpressionAccessibilityUtilTest {
Iteration("HINGLISH", "language=HINGLISH"),
Iteration("PORTUGUESE", "language=PORTUGUESE"),
Iteration("BRAZILIAN_PORTUGUESE", "language=BRAZILIAN_PORTUGUESE"),
Iteration("SWAHILI", "language=SWAHILI"),
Iteration("UNRECOGNIZED", "language=UNRECOGNIZED")
)
fun testConvertToString_constExp_unsupportedLanguage_returnsNull() {
Expand All @@ -186,6 +188,7 @@ class MathExpressionAccessibilityUtilTest {
Iteration("HINGLISH", "language=HINGLISH"),
Iteration("PORTUGUESE", "language=PORTUGUESE"),
Iteration("BRAZILIAN_PORTUGUESE", "language=BRAZILIAN_PORTUGUESE"),
Iteration("SWAHILI", "language=SWAHILI"),
Iteration("UNRECOGNIZED", "language=UNRECOGNIZED")
)
fun testConvertToString_constEq_unsupportedLanguage_returnsNull() {
Expand All @@ -204,7 +207,7 @@ class MathExpressionAccessibilityUtilTest {
.asList()
.containsExactly(
LANGUAGE_UNSPECIFIED, ENGLISH, ARABIC, HINDI, HINGLISH, PORTUGUESE, BRAZILIAN_PORTUGUESE,
UNRECOGNIZED
SWAHILI, UNRECOGNIZED
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,25 @@ language_definitions {
}
}
}
language_definitions {
language: SWAHILI
min_android_sdk_version: 1
app_string_id {
ietf_bcp47_id {
ietf_language_tag: "sw"
}
android_resources_language_id {
language_code: "sw"
}
}
content_string_id {
ietf_bcp47_id {
ietf_language_tag: "sw"
}
}
audio_translation_id {
ietf_bcp47_id {
ietf_language_tag: "sw"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ region_definitions {
}
languages: ENGLISH
}
region_definitions {
region: KENYA
region_id {
ietf_region_tag: "KE"
}
languages: ENGLISH
languages: SWAHILI
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ class LanguageConfigRetrieverTest {
}

@Test
fun testOppiaLanguage_hasSupportForSixLanguages() {
fun testOppiaLanguage_hasSupportForSevenLanguages() {
// While it's a bit strange to test a proto, and particularly in this file, this suite is
// generally responsible for verifying language & region configuration sanity. Part of that
// requires verifying that all languages are tested below. Note that '8' is because the base
// 6 languages are supported + LANGUAGE_UNSPECIFIED and UNRECOGNIZED (auto-generated by
// requires verifying that all languages are tested below. Note that '9' is because the base
// 7 languages are supported + LANGUAGE_UNSPECIFIED and UNRECOGNIZED (auto-generated by
// Protobuf). Finally, note that the values themselves are not checked since it doesn't provide
// any benefit (being able to reference an enum constant without a compiler error is sufficient
// proof that constant is available).
assertThat(OppiaLanguage.values()).hasLength(8)
assertThat(OppiaLanguage.values()).hasLength(9)
}

@Test
fun testOppiaRegion_hasSupportForSixLanguages() {
fun testOppiaRegion_hasSupportForFourRegions() {
// See above test for context on why this test is here & for why the number is correct.
assertThat(OppiaRegion.values()).hasLength(5)
assertThat(OppiaRegion.values()).hasLength(6)
}

@Test
Expand All @@ -71,13 +71,13 @@ class LanguageConfigRetrieverTest {
}

@Test
fun testLoadSupportedLanguages_hasSixSupportedLanguages() {
fun testLoadSupportedLanguages_hasSevenSupportedLanguages() {
val supportedLanguages = languageConfigRetriever.loadSupportedLanguages()

// Change detector test to ensure changes to the configuration are reflected in tests since
// changes to the configuration can have a major impact on the app (and may require additional
// work to be done to support the changes).
assertThat(supportedLanguages.languageDefinitionsCount).isEqualTo(6)
assertThat(supportedLanguages.languageDefinitionsCount).isEqualTo(7)
}

@Test
Expand Down Expand Up @@ -176,13 +176,13 @@ class LanguageConfigRetrieverTest {
}

@Test
fun testLoadSupportedRegions_hasThreeSupportedRegions() {
fun testLoadSupportedRegions_hasFourSupportedRegions() {
val supportedRegions = languageConfigRetriever.loadSupportedRegions()

// Change detector test to ensure changes to the configuration are reflected in tests since
// changes to the configuration can have a major impact on the app (and may require additional
// work to be done to support the changes).
assertThat(supportedRegions.regionDefinitionsCount).isEqualTo(3)
assertThat(supportedRegions.regionDefinitionsCount).isEqualTo(4)
}

@Test
Expand Down
6 changes: 6 additions & 0 deletions model/src/main/proto/languages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ enum OppiaLanguage {

// Corresponds to the Brazilian variant of Portuguese. IETF BCP 47 language tag: pt-BR.
BRAZILIAN_PORTUGUESE = 6;

// Corresponds to the Swahili (Kiswahili) macro language. IETF BCP 47 language tag: sw.
SWAHILI = 7;
}

// The list of regions explicitly supported natively by the Android app. Note that the app is not
Expand All @@ -51,6 +54,9 @@ enum OppiaRegion {

// Corresponds to United State of America (U.S.A.). IETF BCP 47 region tag: US.
UNITED_STATES = 3;

// Corresponds to Kenya (Jamhuri ya Kenya). IETF BCP 47 region tag: KE.
KENYA = 4;
}

// Defines the list of supported languages in the app.
Expand Down