summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Davis <brainblasted@disroot.org>2020-11-25 19:14:40 -0800
committerChristopher Davis <brainblasted@disroot.org>2020-12-21 14:11:12 -0800
commit09ab710c294a6a8b6c432f101e8569b68d2d2aa1 (patch)
treead7ab76a062575297062dda59fa645c31c7b3b1a
parent7cf2f2970c7fdff033975014a195e3a3a5ea0f31 (diff)
downloadlibgweather-wip/cdavis/windspeed-string.tar.gz
gweather-weather: Add function to turn a speed unit to stringwip/cdavis/windspeed-string
-rw-r--r--libgweather/gweather-weather.c37
-rw-r--r--libgweather/gweather-weather.h3
2 files changed, 40 insertions, 0 deletions
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c
index 5f9230c..499ea31 100644
--- a/libgweather/gweather-weather.c
+++ b/libgweather/gweather-weather.c
@@ -1159,6 +1159,43 @@ gweather_info_get_wind (GWeatherInfo *info)
}
}
+/**
+ * gweather_speed_unit_to_string:
+ * @unit: a speed unit, or %GWEATHER_SPEED_UNIT_DEFAULT
+ *
+ * Resolve @unit into a localized string.
+ */
+const gchar *
+gweather_speed_unit_to_string (GWeatherSpeedUnit unit)
+{
+ unit = speed_unit_to_real (unit);
+
+ switch (unit) {
+ case GWEATHER_SPEED_UNIT_KNOTS:
+ /* TRANSLATOR: This is the wind speed in knots */
+ return _("knots");
+ case GWEATHER_SPEED_UNIT_MPH:
+ /* TRANSLATOR: This is the wind speed in miles per hour */
+ return _("mph");
+ case GWEATHER_SPEED_UNIT_KPH:
+ /* TRANSLATOR: This is the wind speed in kilometers per hour */
+ return _("km/h");
+ case GWEATHER_SPEED_UNIT_MS:
+ /* TRANSLATOR: This is the wind speed in meters per second */
+ return _("m/s");
+ case GWEATHER_SPEED_UNIT_BFT:
+ /* TRANSLATOR: This is the wind speed as a Beaufort force factor
+ * (commonly used in nautical wind estimation).
+ */
+ return _("Beaufort force");
+ case GWEATHER_SPEED_UNIT_INVALID:
+ case GWEATHER_SPEED_UNIT_DEFAULT:
+ g_assert_not_reached ();
+ }
+
+ return NULL;
+}
+
static GWeatherPressureUnit
pressure_unit_to_real (GWeatherPressureUnit unit)
{
diff --git a/libgweather/gweather-weather.h b/libgweather/gweather-weather.h
index 1a800d0..b397c69 100644
--- a/libgweather/gweather-weather.h
+++ b/libgweather/gweather-weather.h
@@ -418,6 +418,9 @@ const gchar * gweather_conditions_to_string_full (GWeatherConditions *conditions
GWEATHER_EXTERN
GWeatherTemperatureUnit gweather_temperature_unit_to_real (GWeatherTemperatureUnit unit);
+GWEATHER_EXTERN
+const gchar * gweather_speed_unit_to_string (GWeatherSpeedUnit unit);
+
G_END_DECLS
#endif /* __WEATHER_H_ */