MarcDufresne/BetterWeather — pull request #14 by alogblog (2014-04-22 13:59:58+00:00)
Title: Korean translation & east asian address form adaptations

Hell Marc Dufresne!

First of all I'd like to thank you for your sharing good app.

I added Korean translation and some modification to your wonderful app. Please consider my request.
From now, I will explain my mods.

1. Addition of wind speed label feature.

Just a small accessary. If user select "Show wind label" option in preference, BetterWeather shows wind speed information as label ( http://www.windfinder.com/wind/windspeed.htm ).

2. Can search location with non-English characters.

In current app, we(non-Engish user) cannot search our city by entering our own language, can do it only with English. For example, if we type "서울"(in Korean, it is "Seoul"), this app doesnt list results.
As a result, even localized(values-zh/it/fr...) app displays weather info. as its own characters except city name.
This problem fixed.

2. From here, all mods are for east asaian(Korean, Chinese, Japanese, or any other countries)

2.1 Wind speed display.

For CJK users (or any other asian), the representations like 10 km/h or 10 m/s are also valid, but not natural.
For example, we Korean read "10 m/s" as "초속(second speed) 10 미터(meter)".
Japanese do it as "秒速10メートル", Chinese "每秒10米". Its MORE natural.
So I added 4th option like "Wind: %1$s %4$s%2$s%3$s".
Western users will have empty string in %4$s, so all current values-* translations have no efftects.

2.2 Location display

Current BetterWeaterh fixes location format as "small location, large location". For example, "New York, USA". Yes, it is the address form of western users.

At least CJK(or other asian or some western(IDK)) write address like "large location --to--> small location". For example, "Korea, Seoul, a borough, a city, a town, my home". I know CJ also do.
So I added %1$s, %2$s option.
%1$s is for small location, %2$s is for large location.
Of course normal western have "%1$s, %2$s" form(default), CJK users do "%2$s %1$s" form.

2.3 Method getting small/large location name from Yahoo XML.

Current BetterWeather get location name from two source, one is WHERE Yahoo XML, the other is WEATHER Yahoo XML.

But WEATHER XML gives us only ENGLISH represented location name(always "Seoul", not "서울") which you use in displaying widget.
Localized location names are only from WHERE XML with option like lang=ko-KR option.
So I used it in getting location names. (This means some modification to your original source was necessary)

And you used "locality*" element in WHERE XML for getting location. But I tried some Korea/Japan/USA locations and looked through those XML. I found "locality" elements dont alway exists, but "admin*" elments do.

So I used name <= admin3 <= admin2 <= admin1 <= country steps.
For example, "newyork"(search keyword) has
name = "New York"
country = "USA"
admin1 = "New Yokr"
admin2 = admin3 = "" elements. Then final widget has "New York, USA"

"trenton" has
name = "Trenton"
country = "USA"
admin1 = "New Jersey"
admin2 = "Mercer"
admin3 = "" elements. Then it has "Trenton, Mercer" in final widget.

In conclusion, my steps can catch all cases without failure, although some keywords to small town has one-step larger location name, not big location name.

Phew~ small mods, but superfluous long posts :(

Anyway, please watch my mods and apply these as possible as you can.
Of cource my programming is not good, necessatrily it has inefficient mods because I dint fully understand your source. So please re-mods mine for efficient one.

Thanks.