nate-parrott / Flashlight

The missing Spotlight plugin system
http://flashlight.nateparrott.com
Other
5.39k stars 411 forks source link

Non-language specific localisation #434

Closed Taffjones closed 9 years ago

Taffjones commented 9 years ago

Maybe it's just the weather plugin, but whenever I do a search it assumes I'm in the USA. e.g. "weather bristol" gives the weather for bristol, US. "weather london" gives "???" because there are several places with that name in the US

cHemingway commented 9 years ago

You can put "Bristol,GB" to get the UK version, and the same with London.

Maybe Flashlight should automatically add your country code ( in your case, "GB") if you don't specify it , but also allow you to override it (e.g put London,CA). I have attempted this here cHemingway/Flashlight@71f459d5b22e4b3d6693c5e218f0b566d8f629eb, and it works fine for Bristol and London, but it does not work for New York, as there is of course no New York in the UK.

The API used (openweathermap.org) could really do with a way of hinting that you want results localised to a specific location,

nate-parrott commented 9 years ago

Maybe try first with country code appended, and if it fails, try without? I've noticed this also happens on the U.S. state level, though — San Francisco doesn't work... On Wed, Apr 29, 2015 at 9:17 PM Chris Hemingway notifications@github.com wrote:

You can put "Bristol,GB" to get the UK version, and the same with London.

Maybe Flashlight should automatically add your country code ( in your case, "GB") if you don't specify it , but also allow you to override it (e.g put London,CA). I have attempted this here cHemingway/Flashlight@71f459d https://github.com/cHemingway/Flashlight/commit/71f459d5b22e4b3d6693c5e218f0b566d8f629eb, and it works fine for Bristol and London, but it does not work for New York, as there is of course no New York in the UK.

The API used (openweathermap.org) could really do with a way of hinting that you want results localised to a specific location,

— Reply to this email directly or view it on GitHub https://github.com/nate-parrott/Flashlight/issues/434#issuecomment-97626834 .

cHemingway commented 9 years ago

Looking at it more closely, the openweathermap API does have the option to return multiple results by changing the "search accuracy" level, which I thought you could then localise further by selecting the result with the correct country code, as it returns that with the name.

Unfortunately you can't return multiple 5 day forecasts at once, so the code would have to be changed to make 2 API requests, the first to fetch matching countries to select the local/specified one (or not if it fails), and the second to get the actual forecasts.

cHemingway commented 9 years ago

OK so my latest commit should do exactly that, see cHemingway/Flashlight@e57163520b94a9f23d896930bda77415c41c524f

I have tested it, and it works for Bristol, London, and now New York for me in the UK, so fixes the specific issue @Taffjones had. Its still quite rough though, I think my parsing needs some work. It also needs translated (weather_de.html and weather_fr.html) but that shouldn't be too difficult.

Taffjones commented 9 years ago

It sounds like a good solution. Let me know when I can try it out and I'll give it a shot.

Thanks!

cHemingway commented 9 years ago

OK, try and download this modified weather.bundle. and unzip it into /Users//Library/FlashlightPlugins/ to replace your existing weather plugin (after you have backed the old one up of course). Let me know if you find any bugs.