From ff5ba355f5dbd95a00b5a8e99f3a5a97326990ef Mon Sep 17 00:00:00 2001 From: simon04 Date: Fri, 3 Jun 2011 21:46:41 +0200 Subject: [PATCH] Allow to disable translation of weather condition. --- src/extension.js | 6 +++++- src/org.gnome.shell.extensions.weather.gschema.xml.in | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/extension.js b/src/extension.js index 8a8266a..fe74e4d 100644 --- a/src/extension.js +++ b/src/extension.js @@ -50,6 +50,7 @@ const WEATHER_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.weather'; const WEATHER_UNIT_KEY = 'unit'; const WEATHER_CITY_KEY = 'city'; const WEATHER_WOEID_KEY = 'woeid'; +const WEATHER_TRANSLATE_CONDITION_KEY = 'translate-condition'; // Keep enums in sync with GSettings schemas const WeatherUnits = { @@ -76,6 +77,7 @@ WeatherMenuButton.prototype = { this._units = this._settings.get_enum(WEATHER_UNIT_KEY); this._city = this._settings.get_string(WEATHER_CITY_KEY); this._woeid = this._settings.get_string(WEATHER_WOEID_KEY); + this._translate_condition = this._settings.get_boolean(WEATHER_TRANSLATE_CONDITION_KEY); // Panel icon this._weatherIcon = new St.Icon({ @@ -407,7 +409,9 @@ WeatherMenuButton.prototype = { if(this._city!=null && this._city.length>0) { location = this._city; } - let comment = this.get_weather_condition(weather.get_object_member('condition').get_string_member('code')); + let comment = weather.get_object_member('condition').get_string_member('text'); + if (this._translate_condition) + comment = this.get_weather_condition(weather.get_object_member('condition').get_string_member('code')); let temperature = weather.get_object_member('condition').get_double_member('temperature'); let temperature_unit = '\u00b0' + weather.get_object_member('units').get_string_member('temperature'); let humidity = weather.get_object_member('atmosphere').get_string_member('humidity') + ' %'; diff --git a/src/org.gnome.shell.extensions.weather.gschema.xml.in b/src/org.gnome.shell.extensions.weather.gschema.xml.in index 9014094..5352cee 100644 --- a/src/org.gnome.shell.extensions.weather.gschema.xml.in +++ b/src/org.gnome.shell.extensions.weather.gschema.xml.in @@ -19,5 +19,10 @@ <_summary>City to be displayed <_description>Optional, you can override the displayed city provided by the woeid location + + true + <_summary>Whether to translate the weather condition + <_description>Whether to translate the weather condition. If enabled, the condition is translated based on the weather code. If disabled, the condition string from Yahoo is taken. Note: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string "PM Thunderstorms" cannot be expressed in terms of weather codes. +