[gnome-shell/wip/fmuellner/calendar-refresh: 6/15] weather: Provide non-capitalized condition strings



commit a5e620e2fb8a14cd2f32e141946caf55e073d64a
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Feb 25 18:25:07 2017 +0100

    weather: Provide non-capitalized condition strings
    
    The condition/sky strings provided by GWeather all use sentence
    capitalization, which is appropriate when displayed on its own,
    but results in odd mid-sentence capitals when concatenating
    several conditions in a sentence. Address this by providing our
    own non-capitalized versions of those strings and use them instead
    of the ones from GWeather where appropriate.
    
    This adds a fairly large pile of new strings obviously, but hopefully
    it doesn't impose too much work on translators when GWeather has
    translations for the capitalized version.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754031

 js/ui/dateMenu.js |   26 +++-
 js/ui/weather.js  |  391 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 409 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 6139c1f..9ec0a71 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -233,11 +233,17 @@ const WeatherSection = new Lang.Class({
         this._sync();
     },
 
-    _getSummary: function(info) {
-        let summary = info.get_conditions();
-        if (summary == '-')
+    _getSummary: function(info, capitalize=false) {
+        let [ok, phenom, qualifier] = info.get_value_conditions();
+        if (ok)
+            return capitalize ? info.get_conditions()
+                              : Weather.conditionsToString(phenom, qualifier);
+
+        if (capitalize)
             return info.get_sky();
-        return summary;
+
+        let [, sky] = info.get_value_sky();
+        return Weather.skyToString(sky);
     },
 
     _sameSummary: function(info1, info2) {
@@ -255,10 +261,10 @@ const WeatherSection = new Lang.Class({
         let info = this._weatherClient.info;
         let forecasts = info.get_forecast_list();
         if (forecasts.length == 0) // No forecasts, just current conditions
-            return '%s.'.format(this._getSummary(info));
+            return '%s.'.format(this._getSummary(info, true));
 
         let current = info;
-        let summaries = [this._getSummary(info)];
+        let infos = [info];
         for (let i = 0; i < forecasts.length; i++) {
             let [ok, timestamp] = forecasts[i].get_value_update();
             if (!_isToday(new Date(timestamp * 1000)))
@@ -268,12 +274,12 @@ const WeatherSection = new Lang.Class({
                 continue; // Ignore consecutive runs of equal summaries
 
             current = forecasts[i];
-            if (summaries.push(this._getSummary(current)) == 3)
+            if (infos.push(current) == 3)
                 break; // Use a maximum of three summaries
         }
 
         let fmt;
-        switch(summaries.length) {
+        switch(infos.length) {
             /* Translators: %s is a weather condition like "Clear sky"; see
                libgweather for the possible condition strings. If at all
                possible, the sentence should match the grammatical case etc. of
@@ -292,6 +298,10 @@ const WeatherSection = new Lang.Class({
                the inserted conditions. */
             case 3: fmt = _("%s, then %s, followed by %s later."); break;
         }
+        let summaries = infos.map((info, i) => {
+            let capitalize = i == 0 && fmt.startsWith('%s');
+            return this._getSummary(info, capitalize);
+        });
         return String.prototype.format.apply(fmt, summaries);
     },
 
diff --git a/js/ui/weather.js b/js/ui/weather.js
index 1e02eb4..9c38f51 100644
--- a/js/ui/weather.js
+++ b/js/ui/weather.js
@@ -12,6 +12,397 @@ const Util = imports.misc.util;
 // Minimum time between updates to show loading indication
 const UPDATE_THRESHOLD = 10 * GLib.TIME_SPAN_MINUTE;
 
+const _skyMap = new Map([
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+    [GWeather.Sky.CLEAR,     N_("clear sky")],
+
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+    [GWeather.Sky.BROKEN,    N_("broken clouds")],
+
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+    [GWeather.Sky.SCATTERED, N_("scattered clouds")],
+
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+    [GWeather.Sky.FEW,       N_("few clouds")],
+
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+    [GWeather.Sky.OVERCAST,  N_("overcast")]
+]);
+
+const _conditionsMap = new Map([
+    [100 * GWeather.ConditionPhenomenon.NONE + GWeather.ConditionQualifier.THUNDERSTORM,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("thunderstorm")],
+
+    [100 * GWeather.ConditionPhenomenon.DRIZZLE + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("drizzle")],
+    [100 * GWeather.ConditionPhenomenon.DRIZZLE + GWeather.ConditionQualifier.LIGHT,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("light drizzle")],
+    [100 * GWeather.ConditionPhenomenon.DRIZZLE + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("moderate drizzle")],
+    [100 * GWeather.ConditionPhenomenon.DRIZZLE + GWeather.ConditionQualifier.HEAVY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("heavy drizzle")],
+    [100 * GWeather.ConditionPhenomenon.DRIZZLE + GWeather.ConditionQualifier.FREEZING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("freezing drizzle")],
+
+    [100 * GWeather.ConditionPhenomenon.RAIN + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("rain")],
+    [100 * GWeather.ConditionPhenomenon.RAIN + GWeather.ConditionQualifier.LIGHT,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("light rain")],
+    [100 * GWeather.ConditionPhenomenon.RAIN + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("moderate rain")],
+    [100 * GWeather.ConditionPhenomenon.RAIN + GWeather.ConditionQualifier.HEAVY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("heavy rain")],
+    [100 * GWeather.ConditionPhenomenon.RAIN + GWeather.ConditionQualifier.THUNDERSTORM,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("thunderstorm")],
+    [100 * GWeather.ConditionPhenomenon.RAIN + GWeather.ConditionQualifier.SHOWERS,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("rain showers")],
+    [100 * GWeather.ConditionPhenomenon.RAIN + GWeather.ConditionQualifier.FREEZING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("freezing rain")],
+
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("snow")],
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.LIGHT,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("light snow")],
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("moderate snow")],
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.HEAVY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("heavy snow")],
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.THUNDERSTORM,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("snowstorm")],
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.BLOWING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("blowing snowfall")],
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.SHOWERS,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("snow showers")],
+    [100 * GWeather.ConditionPhenomenon.SNOW + GWeather.ConditionQualifier.DRIFTING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("drifting snow")],
+
+    [100 * GWeather.ConditionPhenomenon.SNOW_GRAINS + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("snow grains")],
+    [100 * GWeather.ConditionPhenomenon.SNOW_GRAINS + GWeather.ConditionQualifier.LIGHT,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("light snow grains")],
+    [100 * GWeather.ConditionPhenomenon.SNOW_GRAINS + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("moderate snow grains")],
+    [100 * GWeather.ConditionPhenomenon.SNOW_GRAINS + GWeather.ConditionQualifier.HEAVY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("heavy snow grains")],
+
+    [100 * GWeather.ConditionPhenomenon.ICE_CRYSTALS + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("ice crystals")],
+    [100 * GWeather.ConditionPhenomenon.ICE_CRYSTALS + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("ice crystals")],
+
+    [100 * GWeather.ConditionPhenomenon.ICE_PELLETS + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("sleet")],
+    [100 * GWeather.ConditionPhenomenon.ICE_PELLETS + GWeather.ConditionQualifier.LIGHT,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("little sleet")],
+    [100 * GWeather.ConditionPhenomenon.ICE_PELLETS + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("moderate sleet")],
+    [100 * GWeather.ConditionPhenomenon.ICE_PELLETS + GWeather.ConditionQualifier.HEAVY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("heavy sleet")],
+    [100 * GWeather.ConditionPhenomenon.ICE_PELLETS + GWeather.ConditionQualifier.THUNDERSTORM,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("sleet storm")],
+    [100 * GWeather.ConditionPhenomenon.ICE_PELLETS + GWeather.ConditionQualifier.SHOWERS,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("showers of sleet")],
+
+    [100 * GWeather.ConditionPhenomenon.HAIL + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("hail")],
+    [100 * GWeather.ConditionPhenomenon.HAIL + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("hail")],
+    [100 * GWeather.ConditionPhenomenon.HAIL + GWeather.ConditionQualifier.THUNDERSTORM,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("hailstorm")],
+    [100 * GWeather.ConditionPhenomenon.HAIL + GWeather.ConditionQualifier.SHOWERS,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("hail showers")],
+
+    [100 * GWeather.ConditionPhenomenon.SMALL_HAIL + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("small hail")],
+    [100 * GWeather.ConditionPhenomenon.SMALL_HAIL + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("small hail")],
+    [100 * GWeather.ConditionPhenomenon.SMALL_HAIL + GWeather.ConditionQualifier.THUNDERSTORM,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("small hailstorm")],
+    [100 * GWeather.ConditionPhenomenon.SMALL_HAIL + GWeather.ConditionQualifier.SHOWERS,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("showers of small hail")],
+
+    [100 * GWeather.ConditionPhenomenon.PRECIPITATION + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("unknown precipitation")],
+
+    [100 * GWeather.ConditionPhenomenon.MIST + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("mist")],
+    [100 * GWeather.ConditionPhenomenon.MIST + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("mist")],
+
+    [100 * GWeather.ConditionPhenomenon.FOG + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("fog")],
+    [100 * GWeather.ConditionPhenomenon.FOG + GWeather.ConditionQualifier.VICINITY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("fog in the vicinity")],
+    [100 * GWeather.ConditionPhenomenon.FOG + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("fog")],
+    [100 * GWeather.ConditionPhenomenon.FOG + GWeather.ConditionQualifier.SHALLOW,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("shallow fog")],
+    [100 * GWeather.ConditionPhenomenon.FOG + GWeather.ConditionQualifier.PATCHES,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("patches of fog")],
+    [100 * GWeather.ConditionPhenomenon.FOG + GWeather.ConditionQualifier.PARTIAL,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("partial fog")],
+    [100 * GWeather.ConditionPhenomenon.FOG + GWeather.ConditionQualifier.FREEZING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("freezing fog")],
+
+    [100 * GWeather.ConditionPhenomenon.SMOKE + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("smoke")],
+    [100 * GWeather.ConditionPhenomenon.SMOKE + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("smoke")],
+
+    [100 * GWeather.ConditionPhenomenon.VOLCANIC_ASH + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("volcanic ash")],
+    [100 * GWeather.ConditionPhenomenon.VOLCANIC_ASH + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("volcanic ash")],
+
+    [100 * GWeather.ConditionPhenomenon.SAND + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("sand")],
+    [100 * GWeather.ConditionPhenomenon.SAND + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("sand")],
+    [100 * GWeather.ConditionPhenomenon.SAND + GWeather.ConditionQualifier.BLOWING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("blowing sand")],
+    [100 * GWeather.ConditionPhenomenon.SAND + GWeather.ConditionQualifier.DRIFTING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("drifting sand")],
+
+    [100 * GWeather.ConditionPhenomenon.HAZE + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("haze")],
+    [100 * GWeather.ConditionPhenomenon.HAZE + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("haze")],
+
+    [100 * GWeather.ConditionPhenomenon.SPRAY + GWeather.ConditionQualifier.BLOWING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("blowing sprays")],
+
+    [100 * GWeather.ConditionPhenomenon.DUST + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("dust")],
+    [100 * GWeather.ConditionPhenomenon.DUST + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("dust")],
+    [100 * GWeather.ConditionPhenomenon.DUST + GWeather.ConditionQualifier.BLOWING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("blowing dust")],
+    [100 * GWeather.ConditionPhenomenon.DUST + GWeather.ConditionQualifier.DRIFTING,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("drifting dust")],
+
+    [100 * GWeather.ConditionPhenomenon.SQUALL + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("squall")],
+    [100 * GWeather.ConditionPhenomenon.SQUALL + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("squall")],
+
+    [100 * GWeather.ConditionPhenomenon.SANDSTORM + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("sandstorm")],
+    [100 * GWeather.ConditionPhenomenon.SANDSTORM + GWeather.ConditionQualifier.VICINITY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("sandstorm in the vicinity")],
+    [100 * GWeather.ConditionPhenomenon.SANDSTORM + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("sandstorm")],
+    [100 * GWeather.ConditionPhenomenon.SANDSTORM + GWeather.ConditionQualifier.HEAVY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("heavy sandstorm")],
+
+    [100 * GWeather.ConditionPhenomenon.DUSTSTORM + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("duststorm")],
+    [100 * GWeather.ConditionPhenomenon.DUSTSTORM + GWeather.ConditionQualifier.VICINITY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("duststorm in the vicinity")],
+    [100 * GWeather.ConditionPhenomenon.DUSTSTORM + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("duststorm")],
+    [100 * GWeather.ConditionPhenomenon.DUSTSTORM + GWeather.ConditionQualifier.HEAVY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("heavy duststorm")],
+
+    [100 * GWeather.ConditionPhenomenon.FUNNEL_CLOUD + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("funnel cloud")],
+
+    [100 * GWeather.ConditionPhenomenon.TORNADO + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("tornado")],
+
+    [100 * GWeather.ConditionPhenomenon.DUST_WHIRLS + GWeather.ConditionQualifier.NONE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("dust whirls")],
+    [100 * GWeather.ConditionPhenomenon.DUST_WHIRLS + GWeather.ConditionQualifier.VICINITY,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("dust whirls in the vicinity")],
+    [100 * GWeather.ConditionPhenomenon.DUST_WHIRLS + GWeather.ConditionQualifier.MODERATE,
+    /* Translators: libgweather uses the same string with sentence
+       capitalization, so make sure to check for translations there */
+     N_("dust whirls")]
+]);
+
+function skyToString(sky) {
+    if (_skyMap.has(sky))
+        return _(_skyMap.get(sky));
+    return '-';
+}
+
+function conditionsToString(phenom, qualifier) {
+    if (_conditionsMap.has(100 * phenom + qualifier))
+        return _(_conditionsMap.get(100 * phenom + qualifier));
+
+    // libgweather considers many combinations non-sensical; instead of
+    // returning '??', we try to fallback to the bare phenomenon
+    if (phenom != GWeather.ConditionPhenomenon.NONE &&
+        qualifier != GWeather.ConditionQualifier.NONE)
+        return conditionsToString(phenom, GWeather.ConditionQualifier.NONE);
+
+    return '-';
+}
+
 const WeatherClient = new Lang.Class({
     Name: 'WeatherClient',
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]