WebParser: Weather Skin Translations
One of the things that is often asked is "How can I translate the weather conditions text, returned by WebParser when creating or editing a weather skin, to my own language?"
This actually pretty simple to do. First find the measure or measures (often in a weather skin there will be 3 - 5 of them) which are returning the "weather conditions" text. It will look something like this:
Note that a weather skin normally works by having a first, primary measure that retrieves all the information from the weather RSS feed in one shot. Then there will be subsequent measures which will extract the individual bits of information from the large array of values returned by this first measure. So you will often see something like:
Followed by something like this later on in the skin:
As you can see, the measure [MeasureCurrentWeatherConditions] is using as its "Url=" the result of [MeasureYahooWeather] (our first main RSS measure) and specifically asking for StringIndex 34, the index in the array of returned values which holds the first of the "Weather Condition" values, in this case the "Current Conditions".
Since Weather.com / Yahoo Weather return these values in English, you may want to translate them to your native language. To do so, add a line at the end of each of the measures that specifically return "Weather Conditions" text. In our current example, after the line "StringIndex=34".
Substitute="(?i)^Cloudy$":"Bewölkt","^Partly Cloudy$":"Teilweise Bewölkt"
And so on... Continuing with the pattern:
Substitute="Thing to replace":"Thing to replace with","Thing to replace":"Thing to replace with"
The punctuation is important. "Thing to replace" and "Thing to replace with" are enclosed in quotes. There is a colon between them. Pairs are separated with commas.
We use RegExpSubstitute so a regular expression comparison is used. Then in the Substitute option, we first tell it to be case insensitive
(?i), and look for very specific strings by using start-of-string
^ and end-of-string
$ as boundaries.
That is all there is to it. In our example above, "Cloudy" will be replaced with "Bewölkt" when the text is later displayed in a meter.
What "Weather Conditions" text codes are returned by Yahoo Weather so I know what to translate?"
Here is a list with the number of the icon and the text returned: