From c5c79d1d0b6f6e8b94a7f4c4e2ea86d375ae5c4b Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 5 Feb 2016 13:31:59 +0400 Subject: [PATCH] Allow localising units Some language (e.g. Arabic) use localised units, so allow localising them. --- data/weather-settings.ui | 48 ++++++++++++++++++++-------------------- src/extension.js | 48 ++++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/data/weather-settings.ui b/data/weather-settings.ui index 64cf74c..19aba84 100644 --- a/data/weather-settings.ui +++ b/data/weather-settings.ui @@ -782,14 +782,14 @@ True False - °C - °F - K - °Ra - °Ré - °Rø - °De - °N + °C + °F + K + °Ra + °Ré + °Rø + °De + °N @@ -802,12 +802,12 @@ True False - km/h - mph - m/s - kn - ft/s - Beaufort + km/h + mph + m/s + kn + ft/s + Beaufort @@ -820,16 +820,16 @@ True False - hPa - inHg - bar - Pa - kPa - atm - at - Torr - psi - mmHg + hPa + inHg + bar + Pa + kPa + atm + at + Torr + psi + mmHg diff --git a/src/extension.js b/src/extension.js index 634c901..4bb12e2 100644 --- a/src/extension.js +++ b/src/extension.js @@ -1017,21 +1017,21 @@ const OpenweatherMenuButton = new Lang.Class({ unit_to_unicode: function() { if (this._units == WeatherUnits.FAHRENHEIT) - return '\u00B0F'; + return _('\u00B0F'); else if (this._units == WeatherUnits.KELVIN) - return 'K'; + return _('K'); else if (this._units == WeatherUnits.RANKINE) - return '\u00B0Ra'; + return _('\u00B0Ra'); else if (this._units == WeatherUnits.REAUMUR) - return '\u00B0R\u00E9'; + return _('\u00B0R\u00E9'); else if (this._units == WeatherUnits.ROEMER) - return '\u00B0R\u00F8'; + return _('\u00B0R\u00F8'); else if (this._units == WeatherUnits.DELISLE) - return '\u00B0De'; + return _('\u00B0De'); else if (this._units == WeatherUnits.NEWTON) - return '\u00B0N'; + return _('\u00B0N'); else - return '\u00B0C'; + return _('\u00B0C'); }, hasIcon: function(icon) { @@ -1204,56 +1204,56 @@ const OpenweatherMenuButton = new Lang.Class({ }, formatPressure: function(pressure) { - let pressure_unit = 'hPa'; + let pressure_unit = _('hPa'); switch (this._pressure_units) { case WeatherPressureUnits.INHG: pressure = this.toInHg(pressure); - pressure_unit = "inHg"; + pressure_unit = _("inHg"); break; case WeatherPressureUnits.HPA: pressure = pressure.toFixed(this._decimal_places); - pressure_unit = "hPa"; + pressure_unit = _("hPa"); break; case WeatherPressureUnits.BAR: pressure = (pressure / 1000).toFixed(this._decimal_places); - pressure_unit = "bar"; + pressure_unit = _("bar"); break; case WeatherPressureUnits.PA: pressure = (pressure * 100).toFixed(this._decimal_places); - pressure_unit = "Pa"; + pressure_unit = _("Pa"); break; case WeatherPressureUnits.KPA: pressure = (pressure / 10).toFixed(this._decimal_places); - pressure_unit = "kPa"; + pressure_unit = _("kPa"); break; case WeatherPressureUnits.ATM: pressure = (pressure * 0.000986923267).toFixed(this._decimal_places); - pressure_unit = "atm"; + pressure_unit = _("atm"); break; case WeatherPressureUnits.AT: pressure = (pressure * 0.00101971621298).toFixed(this._decimal_places); - pressure_unit = "at"; + pressure_unit = _("at"); break; case WeatherPressureUnits.TORR: pressure = (pressure * 0.750061683).toFixed(this._decimal_places); - pressure_unit = "Torr"; + pressure_unit = _("Torr"); break; case WeatherPressureUnits.PSI: pressure = (pressure * 0.0145037738).toFixed(this._decimal_places); - pressure_unit = "psi"; + pressure_unit = _("psi"); break; case WeatherPressureUnits.MMHG: pressure = (pressure * 0.750061683).toFixed(this._decimal_places); - pressure_unit = "mmHg"; + pressure_unit = _("mmHg"); break; } return parseFloat(pressure).toLocaleString() + ' ' + pressure_unit; @@ -1297,16 +1297,16 @@ const OpenweatherMenuButton = new Lang.Class({ }, formatWind: function(speed, direction) { - let unit = 'm/s'; + let unit = _('m/s'); switch (this._wind_speed_units) { case WeatherWindSpeedUnits.MPH: speed = (speed * OPENWEATHER_CONV_MPS_IN_MPH).toFixed(this._decimal_places); - unit = 'mph'; + unit = _('mph'); break; case WeatherWindSpeedUnits.KPH: speed = (speed * OPENWEATHER_CONV_MPS_IN_KPH).toFixed(this._decimal_places); - unit = 'km/h'; + unit = _('km/h'); break; case WeatherWindSpeedUnits.MPS: @@ -1315,12 +1315,12 @@ const OpenweatherMenuButton = new Lang.Class({ case WeatherWindSpeedUnits.KNOTS: speed = (speed * OPENWEATHER_CONV_MPS_IN_KNOTS).toFixed(this._decimal_places); - unit = 'kn'; + unit = _('kn'); break; case WeatherWindSpeedUnits.FPS: speed = (speed * OPENWEATHER_CONV_MPS_IN_FPS).toFixed(this._decimal_places); - unit = 'ft/s'; + unit = _('ft/s'); break; case WeatherWindSpeedUnits.BEAUFORT: