Skip to content
Open
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 @@ -31,7 +31,7 @@ class CurrentWeatherViewModel(val context: Context,
val today: Condition, val yesterday: Condition) {

fun weatherSummary(): SpannableStringBuilder {
val adjective = tempDifference().name.toLowerCase()
val adjective = context.getString(tempDifference().asAdjective())
val todayDescription = context.getString(timeOfDay().asPresentDayDescription())
val yesterdayDescription = context.getString(timeOfDay().asPreviousDayDescription())
val format = tempDifference().summaryFormat()
Expand Down Expand Up @@ -89,6 +89,14 @@ class CurrentWeatherViewModel(val context: Context,
}
}

private fun TemperatureDifference.asAdjective(): Int = when(this) {
SAME -> R.string.same
HOTTER -> R.string.hotter
WARMER -> R.string.warmer
COOLER -> R.string.cooler
COLDER -> R.string.colder
}

private fun TimeOfDay.asPresentDayDescription(): Int {
when (this) {
MORNING -> return string.present_morning
Expand Down
60 changes: 60 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
//directions
<string name="no_direction"></string>
<string name="north_abbrev">N</string>
<string name="north_east_abbrev">NO</string>
<string name="east_abbrev">O</string>
<string name="south_east_abbrev">SO</string>
<string name="south_abbrev">S</string>
<string name="south_west_abrrev">SW</string>
<string name="west_abbrev">W</string>
<string name="north_west_abbrev">NW</string>

//main
<string name="formatted_temperature_string">%1$d&#xb0; / %2$d&#xb0; / %3$d&#xb0;</string>
<string name="formatted_imperial_wind_string">%1$d mph %2$s</string>
<string name="formatted_metric_wind_string">%1$d km/h %2$s</string>
<string name="temperature">%d&#xb0;</string>
<string name="dark_sky_credit">Powered by Dark Sky</string>
<string name="thoughtbot">thoughtbot</string>
<string name="missing_location_permission_error">馃檯馃従 馃檯馃徏 馃檯馃徎\n\nStandortermittlung ist ausgeschaltet. \n\nSchalte die Standortermittlung in den Einstellungen an, damit wir dir eine pr盲zise Wettervorhersage geben k枚nnen.</string>
<string name="generic_error_message">馃檯馃従 馃檯馃徏 馃檯馃徎\n\n%s</string>

//toolbar
<string name="updated_at">Aktualisiert um %s</string>
<string name="checking_weather">Rufe Wetter ab&#8230;</string>
<string name="update_failed">Aktualisierung fehlgeschlagen</string>

//time of day
<string name="present_night">heute Abend</string>
<string name="present_morning">heute Morgen</string>
<string name="present_day">heute</string>
<string name="present_afternoon">heute Nachmittag</string>
<string name="previous_night">gestern Abend</string>
<string name="previous_morning">gestern Morgen</string>
<string name="previous_day">gestern</string>
<string name="previous_afternoon">gestern Nachmittag</string>

//temperature difference
<string name="colder">k盲lter</string>
<string name="cooler">k眉hler</string>
<string name="same">盲hnlich</string>
<string name="warmer">w盲rmer</string>
<string name="hotter">hei脽er</string>

//temperature formats
<string name="different_temperature_format" formatted="false">Es ist %2$s %1$s als %3$s.</string>
<string name="same_temperature_format" formatted="false">Es ist %2$s %1$s wie %3$s.</string>

//settings
<string name="metric">Metrisch</string>
<string name="imperial">Angels盲chsisch</string>
<string name="info">Info</string>
<string name="privacy_policy">Privatsph盲re</string>
<string name="settings_menu">Einstellungen</string>
<string name="settings_activity_title">Einstellungen</string>
<string name="handcrafted_with_love_by_thoughtbot">Mit 馃挏 handgefertigt von thoughtbot</string>
<string name="close">Schlie脽en</string>
<string name="unit_system">Einheitensystem</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
<string name="previous_day">yesterday</string>
<string name="previous_afternoon">yesterday afternoon</string>

//temperature difference
<string name="colder">colder</string>
<string name="cooler">cooler</string>
<string name="same">same</string>
<string name="warmer">warmer</string>
<string name="hotter">hotter</string>

//temperature formats
<string name="different_temperature_format" formatted="false">It\'s %s %s than %s.</string>
<string name="same_temperature_format" formatted="false">It\'s the %s %s as %s.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ class CurrentWeatherViewModelTest() {
assertTrue { expected.contentEquals(actual) }
}

@Config(qualifiers = "de")
@Test
fun testGermanWeatherSummary() {
val viewModel = CurrentWeatherViewModel(context, preferences, mockCondition, mockCondition)
val expected = "Es ist heute Nachmittag 盲hnlich wie gestern Nachmittag."
val actual = viewModel.weatherSummary()

assertTrue { expected.contentEquals(actual) }
}

@Test
fun testIcon() {
val viewModel = CurrentWeatherViewModel(context, preferences, mockCondition, mockCondition)
Expand Down