Allow localising units

Some language (e.g. Arabic) use localised units, so allow localising
them.
merge-requests/218/head
Khaled Hosny 9 years ago
parent 6e771b71f8
commit c5c79d1d0b
  1. 48
      data/weather-settings.ui
  2. 48
      src/extension.js

@ -782,14 +782,14 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<items>
<item>°C</item>
<item>°F</item>
<item>K</item>
<item>°Ra</item>
<item>°Ré</item>
<item>°Rø</item>
<item>°De</item>
<item>°N</item>
<item translatable="yes">°C</item>
<item translatable="yes">°F</item>
<item translatable="yes">K</item>
<item translatable="yes">°Ra</item>
<item translatable="yes">°Ré</item>
<item translatable="yes">°Rø</item>
<item translatable="yes">°De</item>
<item translatable="yes">°N</item>
</items>
</object>
<packing>
@ -802,12 +802,12 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<items>
<item>km/h</item>
<item>mph</item>
<item>m/s</item>
<item>kn</item>
<item>ft/s</item>
<item>Beaufort</item>
<item translatable="yes">km/h</item>
<item translatable="yes">mph</item>
<item translatable="yes">m/s</item>
<item translatable="yes">kn</item>
<item translatable="yes">ft/s</item>
<item translatable="yes">Beaufort</item>
</items>
</object>
<packing>
@ -820,16 +820,16 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<items>
<item>hPa</item>
<item>inHg</item>
<item>bar</item>
<item>Pa</item>
<item>kPa</item>
<item>atm</item>
<item>at</item>
<item>Torr</item>
<item>psi</item>
<item>mmHg</item>
<item translatable="yes">hPa</item>
<item translatable="yes">inHg</item>
<item translatable="yes">bar</item>
<item translatable="yes">Pa</item>
<item translatable="yes">kPa</item>
<item translatable="yes">atm</item>
<item translatable="yes">at</item>
<item translatable="yes">Torr</item>
<item translatable="yes">psi</item>
<item translatable="yes">mmHg</item>
</items>
</object>
<packing>

@ -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:

Loading…
Cancel
Save