From: <dou...@us...> - 2012-01-11 20:31:07
|
Revision: 4402 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4402&view=rev Author: dougmckeen Date: 2012-01-11 20:30:59 +0000 (Wed, 11 Jan 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/CanadianWeather/ConfigurationForm.Designer.cs trunk/plugins/CanadianWeather/ConfigurationForm.cs trunk/plugins/CanadianWeather/GUICanadianWeather.cs Modified: trunk/plugins/CanadianWeather/ConfigurationForm.Designer.cs =================================================================== --- trunk/plugins/CanadianWeather/ConfigurationForm.Designer.cs 2012-01-10 22:45:33 UTC (rev 4401) +++ trunk/plugins/CanadianWeather/ConfigurationForm.Designer.cs 2012-01-11 20:30:59 UTC (rev 4402) @@ -29,9 +29,6 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.RadioButtonEnglish = new System.Windows.Forms.RadioButton(); - this.RadioButtonFrench = new System.Windows.Forms.RadioButton(); - this.LanguageChoice = new System.Windows.Forms.GroupBox(); this.label1 = new System.Windows.Forms.Label(); this.RefreshIntervalTxtBx = new System.Windows.Forms.TextBox(); this.PluginNameTextBox = new System.Windows.Forms.Label(); @@ -62,47 +59,10 @@ this.ImageURL4 = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); this.configurationFormBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.LanguageChoice.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.configurationFormBindingSource)).BeginInit(); this.SuspendLayout(); // - // RadioButtonEnglish - // - this.RadioButtonEnglish.AutoSize = true; - this.RadioButtonEnglish.Checked = true; - this.RadioButtonEnglish.Enabled = false; - this.RadioButtonEnglish.Location = new System.Drawing.Point(6, 19); - this.RadioButtonEnglish.Name = "RadioButtonEnglish"; - this.RadioButtonEnglish.Size = new System.Drawing.Size(59, 17); - this.RadioButtonEnglish.TabIndex = 5; - this.RadioButtonEnglish.TabStop = true; - this.RadioButtonEnglish.Text = "English"; - this.RadioButtonEnglish.UseVisualStyleBackColor = true; - // - // RadioButtonFrench - // - this.RadioButtonFrench.AutoSize = true; - this.RadioButtonFrench.Enabled = false; - this.RadioButtonFrench.Location = new System.Drawing.Point(6, 40); - this.RadioButtonFrench.Name = "RadioButtonFrench"; - this.RadioButtonFrench.Size = new System.Drawing.Size(58, 17); - this.RadioButtonFrench.TabIndex = 6; - this.RadioButtonFrench.Text = "French"; - this.RadioButtonFrench.UseVisualStyleBackColor = true; - // - // LanguageChoice - // - this.LanguageChoice.Controls.Add(this.RadioButtonEnglish); - this.LanguageChoice.Controls.Add(this.RadioButtonFrench); - this.LanguageChoice.Enabled = false; - this.LanguageChoice.Location = new System.Drawing.Point(341, 1); - this.LanguageChoice.Name = "LanguageChoice"; - this.LanguageChoice.Size = new System.Drawing.Size(79, 66); - this.LanguageChoice.TabIndex = 8; - this.LanguageChoice.TabStop = false; - this.LanguageChoice.Text = "Language"; - // // label1 // this.label1.AutoSize = true; @@ -398,12 +358,9 @@ this.Controls.Add(this.RefreshIntervalTxtBx); this.Controls.Add(this.PluginNameTextBox); this.Controls.Add(this.label1); - this.Controls.Add(this.LanguageChoice); this.Name = "ConfigurationForm"; this.Text = "Canadian Weather Configuration"; this.Load += new System.EventHandler(this.ConfigurationForm_Load); - this.LanguageChoice.ResumeLayout(false); - this.LanguageChoice.PerformLayout(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.configurationFormBindingSource)).EndInit(); @@ -414,9 +371,6 @@ #endregion - private System.Windows.Forms.RadioButton RadioButtonEnglish; - private System.Windows.Forms.RadioButton RadioButtonFrench; - private System.Windows.Forms.GroupBox LanguageChoice; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox RefreshIntervalTxtBx; private System.Windows.Forms.Label PluginNameTextBox; Modified: trunk/plugins/CanadianWeather/ConfigurationForm.cs =================================================================== --- trunk/plugins/CanadianWeather/ConfigurationForm.cs 2012-01-10 22:45:33 UTC (rev 4401) +++ trunk/plugins/CanadianWeather/ConfigurationForm.cs 2012-01-11 20:30:59 UTC (rev 4402) @@ -18,7 +18,6 @@ List<string> _items = new List<string>(); string PluginName; int RefreshTime; - string Language; string[,] Sites; bool SiteLookupFailed; int NumberofSites; @@ -42,7 +41,6 @@ { PluginName = reader.GetValueAsString("BasicSettings", "PluginName", "Canadian Weather"); RefreshTime = reader.GetValueAsInt("BasicSettings", "RefreshTime", 60); - Language = reader.GetValueAsString("BasicSettings", "Language", "English"); //create 2D array of sites (20 sites, 4 attributes) Sites = new string[20, 4]; @@ -57,12 +55,6 @@ //Fill in Refresh Interval RefreshIntervalTxtBx.Text = RefreshTime.ToString(); - //Activate Language Radio Button - if (String.Equals(Language, "French")) - { RadioButtonFrench.Checked = true; } - else - { RadioButtonEnglish.Checked = true; } - //Determine how many sites exist NumberofSites = 0; for (int i = 0; i < 20; i++) @@ -84,6 +76,13 @@ //Fill in the Plugin Name PluginNameTxtBx.Text = PluginName; + + //load the images + ImageURL0.Text = reader.GetValueAsString("Images", "Image0", ""); + ImageURL1.Text = reader.GetValueAsString("Images", "Image1", ""); + ImageURL2.Text = reader.GetValueAsString("Images", "Image2", ""); + ImageURL3.Text = reader.GetValueAsString("Images", "Image3", ""); + ImageURL4.Text = reader.GetValueAsString("Images", "Image4", ""); } //Get Site List from Environment Canada @@ -141,10 +140,6 @@ private void OK_Click(object sender, EventArgs e) { - if (RadioButtonEnglish.Checked == true) - { Language = "English"; } - else - { Language = "French"; } //validate Refresh Interval int tempInteger; @@ -156,7 +151,6 @@ { writer.SetValue("BasicSettings", "PluginName", PluginNameTxtBx.Text); writer.SetValue("BasicSettings", "RefreshTime", RefreshIntervalTxtBx.Text); - writer.SetValue("BasicSettings", "Language", Language); for (int i = 0; i < 19; i++) { Modified: trunk/plugins/CanadianWeather/GUICanadianWeather.cs =================================================================== --- trunk/plugins/CanadianWeather/GUICanadianWeather.cs 2012-01-10 22:45:33 UTC (rev 4401) +++ trunk/plugins/CanadianWeather/GUICanadianWeather.cs 2012-01-11 20:30:59 UTC (rev 4402) @@ -13,6 +13,7 @@ using System.IO; using System.Xml; using System.Net; +using System.Reflection; using MediaPortal.Configuration; using MediaPortal.Dialogs; using MediaPortal.GUI.Library; @@ -21,6 +22,7 @@ using System.Globalization; #endregion + namespace MediaPortal.GUI.CanadianWeather { [PluginIcons("CanadianWeather.Resources.lf.png", "CanadianWeather.Resources.lf_disabled.png")] @@ -114,21 +116,9 @@ int intSunsetHour; int intSunsetMinute; + string strLogo; string strIcon = GUIGraphicsContext.Skin + @"\Media\CanadianWeather\na.png"; string strBaseURL = "http://dd.weatheroffice.ec.gc.ca/citypage_weather/xml/"; - string strPressure = "Pressure"; - string strVisibility = "Visibility"; - string strSunrise = "Sunrise"; - string strSunset = "Sunset"; - string strForecastIssued = "Forecast Issued: "; - string strSevenDayForecast = "Text Forecast"; - string strCurrentConditions = "Current Conditions"; - string strNotObserved = "not observed"; - string strGust = " gust "; - string strWarning = "Warning - "; - string strHigh = "High"; - string strMed = "Med."; - string strLow = "Low"; public string[] Day = new string[NUM_DAYS]; public string[] High = new string[NUM_DAYS]; @@ -150,9 +140,44 @@ List<string> ShortListOfProvs; List<string> CityNames; String strURL = "http://dd.weatheroffice.ec.gc.ca/citypage_weather/xml/siteList.xml"; - String strChooseProv = "Select a Province"; - String strChooseCity = "Select a City"; + + public static class Translation + { + ///// These will be loaded with the language files content + ///// if the selected lang file is not found, it will first try to load en(us).xml as a backup + ///// if that also fails it will use the hardcoded strings as a last resort. + + #region Translatable Fields + + public static string Pressure = "Pressure"; + public static string Visibility = "Visibility"; + public static string Sunrise = "Sunrise"; + public static string Sunset = "Sunset"; + public static string ForecastIssued = "Forecast Issued: "; + public static string SevenDayForecast = "Text Forecast"; + public static string CurrentConditions = "Current Conditions"; + public static string NotObserved = "not observed"; + public static string Gust = " gust "; + public static string Warning = "Warning - "; + public static string High = "High"; + public static string Med = "Med."; + public static string Low = "Low"; + public static string ChooseProv = "Select a Province"; + public static string ChooseCity = "Select a City"; + public static string FeelsLike = "Feels Like"; + public static string Wind = "Wind"; + public static string Humidity = "Humidity"; + public static string Dewpoint = "Dewpoint"; + public static string Satellite = "Satellite"; + public static string SelectLocation = "Select Location"; + public static string Refresh = "Refresh"; + public static string City = "City"; + public static string Weather = "Weather"; + + #endregion + } + #endregion #region enums @@ -220,6 +245,77 @@ //{ //} + public void localize() + { + //GUIDialogMenu debug = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); + //debug.SetHeading("debug"); + //debug.Add(temp.ToString()); + //debug.DoModal(GetID); + //debug.Reset(); + + string lang; + string path = ""; + + try + { + lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage()); + } + catch (Exception) + { + lang = "en-US"; + } + + if (lang.Substring(0,2) == "fr") + { + LanguageChoice = "f"; + } + else + { + LanguageChoice = "e"; + } + + path = Config.GetSubFolder(Config.Dir.Language, "CanadianWeather"); + + if (!System.IO.Directory.Exists(path)) + System.IO.Directory.CreateDirectory(path); + + XmlDocument doc = new XmlDocument(); + Dictionary<string, string> TranslatedStrings = new Dictionary<string, string>(); + string langPath = ""; + try + { + langPath = Path.Combine(path, lang + ".xml"); + doc.Load(langPath); + } + catch (Exception) + { + return; //use the hardcoded strings + } + foreach (XmlNode stringEntry in doc.DocumentElement.ChildNodes) + { + if (stringEntry.NodeType == XmlNodeType.Element) + try + { + TranslatedStrings.Add(stringEntry.Attributes.GetNamedItem("Field").Value, stringEntry.InnerText); + } + catch (Exception) + { + + } + + } + + Type TransType = typeof(Translation); + FieldInfo[] fieldInfos = TransType.GetFields(BindingFlags.Public | BindingFlags.Static); + foreach (FieldInfo fi in fieldInfos) + { + if (TranslatedStrings != null && TranslatedStrings.ContainsKey(fi.Name)) + { + TransType.InvokeMember(fi.Name, BindingFlags.SetField, null, TransType, new object[] { TranslatedStrings[fi.Name] }); + } + } + } + public bool IsRefreshing { get { return _workerActive; } @@ -252,9 +348,15 @@ lastmode = "ShowCurrent"; LoadSettings(); //get the weather settings from the user SelectedCity = Sites[0, 3] + "/" + Sites[0, 0] + "_"; // e.g., "AB/s0000047_" - LanguageChoice = "e"; //language choice defaulting to English for now. later check Language and set as appropriate + //LanguageChoice = "e"; //language choice defaulting to English for now. later check Language and set as appropriate URL = strBaseURL + SelectedCity + LanguageChoice + ".xml"; //form URL - + + //show the default controls so they are visible during page load + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNSWITCH, Translation.Satellite); + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNVIEW, Translation.SevenDayForecast); + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNREFRESH, Translation.Refresh); + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNLOCATIONSELECT, Translation.City); + OnRefresh(); } @@ -349,7 +451,7 @@ } //display the provinces for selection GUIDialogMenu dialogTempProvSelect = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); - dialogTempProvSelect.SetHeading(strChooseProv); + dialogTempProvSelect.SetHeading(Translation.ChooseProv); foreach (string Provinceelement in ProvinceArray) { dialogTempProvSelect.Add(Provinceelement); @@ -371,7 +473,7 @@ dialogTempProvSelect.Reset(); //display the cities for selection GUIDialogMenu dialogTempCitySelect = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); - dialogTempCitySelect.SetHeading(strChooseCity); + dialogTempCitySelect.SetHeading(Translation.ChooseCity); foreach (string Cityelement in CityArray) { dialogTempCitySelect.Add(Cityelement); @@ -380,8 +482,9 @@ if (dialogTempCitySelect.SelectedLabel >= 0) { + + string SelectedCity = dialogTempCitySelect.SelectedLabelText; dialogTempCitySelect.Reset(); - string SelectedCity = dialogTempCitySelect.SelectedLabelText; string TempSite = loaded.Descendants("site") .Where(x => x.Element("provinceCode").Value == SelectedTempProvince) @@ -390,15 +493,16 @@ .SingleOrDefault() .ToString(); - CityNames.Sort(); - SelectedCity = SelectedTempProvince + "/" + TempSite + "_"; // e.g., "AB/s0000047_" URL = strBaseURL + SelectedCity + LanguageChoice + ".xml"; + mode = "ShowCurrent"; lastmode = "ShowCurrent"; OnRefresh(); } + dialogTempCitySelect.Reset(); } + dialogTempProvSelect.Reset(); } public void OnCityButton() @@ -407,15 +511,15 @@ if (dialogCitySelect != null) { dialogCitySelect.Reset(); - dialogCitySelect.SetHeading(8); //my weather + dialogCitySelect.SetHeading(Translation.Weather); //my weather for (int i = 0; i < NumberofSites; i++) { dialogCitySelect.Add(Sites[i, 1] + ", " + Sites[i, 3]); } - dialogCitySelect.Add(GUILocalizeStrings.Get(396)); + dialogCitySelect.Add(Translation.SelectLocation); dialogCitySelect.DoModal(GetID); - if (dialogCitySelect.SelectedLabelText == GUILocalizeStrings.Get(396)) + if (dialogCitySelect.SelectedLabelText == Translation.SelectLocation) { dialogCitySelect.Reset(); OnTempCity(); @@ -424,7 +528,7 @@ { //create the string for the selected location SelectedCity = Sites[dialogCitySelect.SelectedLabel, 3] + "/" + Sites[dialogCitySelect.SelectedLabel, 0] + "_"; // e.g., "AB/s0000047_" - LanguageChoice = "e"; //language choice defaulting to English for now. later check Language and set as appropriate + //LanguageChoice = "e"; //language choice defaulting to English for now. later check Language and set as appropriate URL = strBaseURL + SelectedCity + LanguageChoice + ".xml"; } } @@ -601,6 +705,8 @@ { _urlImage0 = @"http://www.weatheroffice.gc.ca/data/satellite/goes_nam_1070x_100.jpg"; } + + localize(); } //Determine how many sites there are @@ -631,6 +737,7 @@ ForecastXML = htmlStream.ReadToEnd(); response.Close(); + } catch (Exception) { @@ -648,7 +755,7 @@ request.Timeout = 20000; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (Stream responseStream = response.GetResponseStream()) - using (StreamReader htmlStream = new StreamReader(responseStream)) + using (StreamReader htmlStream = new StreamReader(responseStream, Encoding.Default)) WarningHTML = htmlStream.ReadToEnd(); response.Close(); @@ -760,10 +867,10 @@ case "ShowCurrent": //show buttons - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNVIEW, strSevenDayForecast); + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNVIEW, Translation.SevenDayForecast); GUIControl.ShowControl(GetID, (int)Controls.CONTROL_BTNVIEW); GUIControl.ShowControl(GetID, (int)Controls.CONTROL_BTNLOCATIONSELECT); - GUIControl.ShowControl(GetID, (int)Controls.CONTROL_BTNREFRESH); //, GUILocalizeStrings.Get(184)); //Refresh button + GUIControl.ShowControl(GetID, (int)Controls.CONTROL_BTNREFRESH); if (WeatherWarningType != "") { @@ -771,13 +878,13 @@ switch (WeatherWarningPriority) { case "high": - ShowWeatherWarningButton(strWarning + strHigh); + ShowWeatherWarningButton(Translation.Warning + Translation.High); break; case "medium": - ShowWeatherWarningButton(strWarning + strMed); + ShowWeatherWarningButton(Translation.Warning + Translation.Med); break; case "low": - ShowWeatherWarningButton(strWarning + strLow); + ShowWeatherWarningButton(Translation.Warning + Translation.Low); break; default: //nothing @@ -800,11 +907,13 @@ case "ShowTextForecast": //toggle the button label - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNVIEW, strCurrentConditions); + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNVIEW, Translation.CurrentConditions); GUIControl.ShowControl(GetID, (int)Controls.CONTROL_BTNVIEW); GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LABELLOCATION, currentLocation); //display current location - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_IMAGELOGO, currentLocation); //display logo - + GUIControl.ShowControl(GetID, (int)Controls.CONTROL_IMAGELOGO); + + + HideCurrentConditions(); HideWeatherWarning(); HideImages(); @@ -870,8 +979,6 @@ private void ShowImages() { - //GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNSWITCH, GUILocalizeStrings.Get(19100)); - //GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_BTNVIEW, GUILocalizeStrings.Get(737)); for (int i = (int)Controls.CONTROL_IMAGE_SAT; i < (int)Controls.CONTROL_IMAGE_SAT + 5; ++i) { GUIControl.ShowControl(GetID, i); @@ -917,10 +1024,23 @@ GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LABELLOCATION, currentLocation); //display current location GUIControl.ShowControl(GetID, (int)Controls.CONTROL_LABELLOCATION); //display current location (required if coming from satellite images) GUIControl.ShowControl(GetID, (int)Controls.CONTROL_FORECASTUPDATED); //display time of forecast + + if (LanguageChoice == "f") + { + strLogo = GUIGraphicsContext.Skin + String.Format(@"\Media\CanadianWeather\EC logo-Fr.png"); //display logo if french + } + else + { + strLogo = GUIGraphicsContext.Skin + String.Format(@"\Media\CanadianWeather\EC logo.png"); //display logo if english + } + GUIImage logo = (GUIImage)GetControl((int)Controls.CONTROL_IMAGELOGO); + logo.ColourDiffuse = 0xffffffff; + logo.SetFileName(strLogo); + GUIControl.ShowControl(GetID, (int)Controls.CONTROL_IMAGELOGO); //display logo //display time of forecast - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_FORECASTUPDATED, strForecastIssued + LocalizedTimeStamp); + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_FORECASTUPDATED, Translation.ForecastIssued + LocalizedTimeStamp); //display current temp, current condition icon, and current conditions text GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LABELNOWTEMP, currentTemperature); @@ -940,14 +1060,14 @@ GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LABELSUNSET, SunsetTime); //sunset //display static labels - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICFEEL, GUILocalizeStrings.Get(402)); // - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICWIND, GUILocalizeStrings.Get(404)); // - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICRELHUMIDITY, GUILocalizeStrings.Get(406)); // - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICDEWPOINT, GUILocalizeStrings.Get(405)); // - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICPRESSURE, strPressure); // - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICVISIBILIY, strVisibility); // - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICSUNRISE, strSunrise); // - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICSUNSET, strSunset); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICFEEL, Translation.FeelsLike); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICWIND, Translation.Wind); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICRELHUMIDITY, Translation.Humidity); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICDEWPOINT, Translation.Dewpoint); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICPRESSURE, Translation.Pressure); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICVISIBILIY, Translation.Visibility); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICSUNRISE, Translation.Sunrise); // + GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_STATICSUNSET, Translation.Sunset); // } private void HideImages() @@ -1092,7 +1212,7 @@ } catch { - ObservedtextSummary = strNotObserved; + ObservedtextSummary = Translation.NotObserved; } //current condition text @@ -1105,11 +1225,11 @@ } catch { - currentCondition = strNotObserved; + currentCondition = Translation.NotObserved; } if (currentCondition == "" || currentCondition == null) { - currentCondition = strNotObserved; + currentCondition = Translation.NotObserved; } //icon @@ -1142,7 +1262,7 @@ } catch { - currentTemperature = strNotObserved; + currentTemperature = Translation.NotObserved; } @@ -1199,16 +1319,21 @@ .ToString(); if (currentDewpoint == "" || currentDewpoint == null) { - currentDewpoint = strNotObserved; + currentDewpoint = Translation.NotObserved; } else { currentDewpoint += DEGREE_CHARACTER + "C"; + if (LanguageChoice == "f") + { + currentDewpoint = currentDewpoint.Replace(".", ",");//replace the period with a comma for french + } } + } catch { - currentDewpoint = strNotObserved; + currentDewpoint = Translation.NotObserved; } //pressure @@ -1236,17 +1361,21 @@ } if (currentPressure == "" || currentPressure == null && currentPressuretendency == "" || currentPressuretendency == null ) { - currentPressureAndTendency = strNotObserved; + currentPressureAndTendency = Translation.NotObserved; } else { if (currentPressure == "" || currentPressure == null) { - currentPressureAndTendency = strNotObserved; + currentPressureAndTendency = Translation.NotObserved; } else { currentPressureAndTendency = currentPressure + " kPa, " + currentPressuretendency; + if (LanguageChoice == "f") + { + currentPressureAndTendency = currentPressureAndTendency.Replace(".", ",");//replace the period with a comma for french + } } } @@ -1260,16 +1389,20 @@ .ToString(); if (currentVisibility == "" || currentVisibility == null) { - currentVisibility = strNotObserved; + currentVisibility = Translation.NotObserved; } else { currentVisibility += " km"; + if (LanguageChoice == "f") + { + currentVisibility = currentVisibility.Replace(".", ",");//replace the period with a comma for french + } } } catch { - currentVisibility = strNotObserved; + currentVisibility = Translation.NotObserved; } //humidity @@ -1281,7 +1414,7 @@ .ToString(); if (currentRelativeHumidity == "" || currentRelativeHumidity == null) { - currentRelativeHumidity = strNotObserved; + currentRelativeHumidity = Translation.NotObserved; } else { @@ -1290,7 +1423,7 @@ } catch { - currentRelativeHumidity = strNotObserved; + currentRelativeHumidity = Translation.NotObserved; } //wind @@ -1330,12 +1463,12 @@ //append the word "gust" and the gust speed if it exists if (currentWindgust.Length > 1) { - currentWindspeed += strGust + currentWindgust; + currentWindspeed += Translation.Gust + currentWindgust; } if (currentWindspeed == "") { - currentWindCombinedString = strNotObserved; + currentWindCombinedString = Translation.NotObserved; } else { @@ -1430,8 +1563,13 @@ foreach (var forecast in loaded.Descendants("forecastGroup").Elements("forecast")) { string tempday = forecast.Element("period").Attribute("textForecastName").Value; - if (tempint > 0 && tempday.Contains("night")) + if (tempint == 0 && tempday.Contains("soir")) { + tempday = "ce soir"; //shortens "ce soir et cette nuit" + } + + if (tempint > 0 && (tempday.Contains("night") || tempday.Contains("soir"))) + { //this filters out the possibility of 8 forecasts occurring and the 2nd or 3rd one is a "night"time forecast which we won't display //it also grabs the "low" in that night forecast and moves it to the next day var templow = (string)forecast.Element("temperatures") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |