Author: Paul_R
Date: 2008-08-29 09:17:01 +0200 (Fri, 29 Aug 2008)
New Revision: 1631

Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
Log:
* Removed references to I18N.cc_Locale and replace it with CC_SET_LANGUAGE.
* Cleanup

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
   2008-08-29 06:58:07 UTC (rev 1630)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
   2008-08-29 07:17:01 UTC (rev 1631)
@@ -29,7 +29,6 @@
 import net.karmaLab.xml.elements.Element;
 import net.karmaLab.xml.parser.XMLParser;
 
-import com.kysoh.tuxdroid.gadget.framework.container.I18N;
 import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadget;
 import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadgetConfiguration;
 import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadgetException;
@@ -80,19 +79,25 @@
 
        @Override
        public void start() throws SimpleGadgetException {
+               String lang;
         File outputFile; 
         File file;
         String inputLine;
         Writer streamOutput = null;
                XMLParser parser = new XMLParser();
-               System.out.println(Messages.getString("url")); //$NON-NLS-1$
                Element xmlReply;
-               try {
+               
+               /* I need to know the control center language to be able to 
convert
+                * the temperatures. */
+               if (System.getProperty("CC_SET_LANGUAGE") != null) {
+                       lang = System.getProperty("CC_SET_LANGUAGE");
+               }
+               else {
+                       lang = Locale.getDefault().getLanguage().toString();
+               }
                        
+               try {   
                        /* create a new URL object */
-                       /* BUG : I18N.cc_Locale don't works yet. */
-                       
-                       //URL xml = new 
URL(bundle.getString("URL"+configuration().getLocation()));
                        URL xml = new 
URL(String.format(Messages.getString("url"), configuration().getLocation())); 
//$NON-NLS-1$
                        /* Open the connection */
                        URLConnection yc = xml.openConnection();
@@ -141,10 +146,6 @@
                humidity = humidity.split(":")[1]; //$NON-NLS-1$
                humidity = (String) humidity.subSequence(0, 
humidity.length()-1);
                
-               // Icon icon = new ImageIcon(new URL("http://www.google.com"; +
-               // getData(current, "icon")));
-               // String wind = getData(current, "wind_condition");
-               // wind = humidity.split("\\s+:\\s+")[1];
                String message = String.format("Current weather at %s is \"%s\" 
with a temperature of %s degrees %s. Humidity level is %s percent.", 
configuration().getLocation(), weather, temperature, //$NON-NLS-1$
                                configuration().getUnit() == Unit.celsius ? 
"celsius" : "fahrenheit", humidity); //$NON-NLS-1$ //$NON-NLS-2$
                throwMessage(message);
@@ -161,11 +162,11 @@
                         * Depending of the control center language, the 
temperature must
                         * be converted to respect the CC configuration.
                         */
-                       if (I18N.cc_Locale.equals(Locale.ENGLISH) && 
configuration().getUnit() == Unit.celsius) {
+                       if (lang.equals("en") && configuration().getUnit() == 
Unit.celsius) {
                                temperature = 
fahrenheitToCelsius(getData(current, "low")); //$NON-NLS-1$
                                temperatureHigh = 
fahrenheitToCelsius(getData(current, "high")); //$NON-NLS-1$
                        }
-                       else if (!(I18N.cc_Locale.equals(Locale.ENGLISH)) && 
configuration().getUnit() == Unit.fahrenheit) {
+                       else if (!(lang.equals("en")) && 
configuration().getUnit() == Unit.fahrenheit) {
                                temperature = 
celsiusToFahrenheit(getData(current, "low")); //$NON-NLS-1$
                                temperatureHigh = 
celsiusToFahrenheit(getData(current, "high")); //$NON-NLS-1$
                        }


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to