felixhageloh / weather-widget

A weather widget for Übersicht
64 stars 32 forks source link

Add language api option please #8

Closed martinorob closed 9 years ago

martinorob commented 9 years ago

Hi, this is not an Issue but a request. (i don't know where i have to write a request). May you add the option to change the language go the weather-widget?

Yahoo api have the "language" option.

Thanks

felixhageloh commented 9 years ago

This is the right place :) I am not sure that Yahoo actually supports different languages ... do you have a link that shows it? In any case, you can change the weekday names to your language: Look for dayMapping: in the widget file and just change the weekday names there

martinorob commented 9 years ago

Hi Felix, yes i can change the weekday name in dayMapping but this doesn't change the forecast language!

In the documentation of yahoo api i have found this

https://developer.yahoo.com/weather/documentation.html

language: The language of the weather forecast, for example, en-us for US English.

and in the developer page https://developer.yahoo.com/weather/

there is a:

"lang": "it-it" option.

May this help you to implement the language option?

Thanks

felixhageloh commented 9 years ago

thanks for the pointers.

I can't seem to find the option though. The first link just shows the language the feed is in (not the language you want it in) and I see no references to language options in the second link. It could be that you have more options when you have an account with Yahoo (which I don't)

I also tried sending a language with the request with `lang=it-it" and various permutations, but it doesn't do anything. I also found this link that suggests that they don't support different languages, but the link is quite old.

I will keep looking though!

martinorob commented 9 years ago

Thanks Felix, you are right... i have not remember that when i was using Geektools i have created a "langMapping" option..

like this: "Partly Cloud") desc="Parz. Nuvoloso";; "Showers") desc="Pioggia";; "Partly Cloudy") desc="Nuvoloso";; "AM Showers") desc="Pioggia al Mattino";; "PM Showers") desc="Pioggia alla sera";; "PM Thunderstorms") desc="Temporali alla sera";; "Scattered Thunderstorms") desc="Temporali sparsi";; "Light Rain with Thunder") desc="Pioviggina con temporali";; "Thunderstorms") desc="Temporali";; "Heavy Rain") desc="Pioggia persistente";; "Mostly Sunny") desc="Parz. Soleggiato";; "Light Rain") desc="Piovischio";; "Fog") desc="Nebbia";; "Fair") desc="Sereno";; "Sunny") desc="Soleggiato";; "AM Rain") desc="Pioggia al mattino";; "PM Rain") desc="Pioggia alla sera";; "Mostly Cloudy") desc="Prev. Nuvoloso";; "Isolated Thunderstorms") desc="Temporali isolati";; "Thundershowers") desc="Temporali";; "Heavy Thunderstorms") desc="Forti Temporali";; "Clear") desc="Bel tempo";; "Rain") desc="Pioggia";; "Cloudy") desc="Nuvoloso";;

but that was in bash...

may you add the "langMapping" option at this point? :)

felixhageloh commented 9 years ago

I will have a look!

for now you could add it yourself: on line 189 change el.find('.text').text weather.condition.text to el.find('.text').text @textMapping[weather.condition.text]

and then add the text mapping at the end like:

textMapping: 
  "Partly Cloud"            :"Parz. Nuvoloso"
  "Showers"                 :"Pioggia"
  "Partly Cloudy"           :"Nuvoloso"
  "AM Showers"              :"Pioggia al Mattino"
  "PM Showers"              :"Pioggia alla sera"
  "PM Thunderstorms"        :"Temporali alla sera"
  "Scattered Thunderstorms" :"Temporali sparsi"
  "Light Rain with Thunder" :"Pioviggina con temporali"
  "Thunderstorms"           :"Temporali"
  "Heavy Rain"              :"Pioggia persistente"
  "Mostly Sunny"            :"Parz. Soleggiato"
  "Light Rain"              :"Piovischio"
  "Fog"                     :"Nebbia"
  "Fair"                    :"Sereno"
  "Sunny"                   :"Soleggiato"
  "AM Rain"                 :"Pioggia al mattino"
  "PM Rain"                 :"Pioggia alla sera"
  "Mostly Cloudy"           :"Prev. Nuvoloso"
  "Isolated Thunderstorms"  :"Temporali isolati"
  "Thundershowers"          :"Temporali"
  "Heavy Thunderstorms"     :"Forti Temporali"
  "Clear"                   :"Bel tempo"
  "Rain"                    :"Pioggia"
  "Cloudy"                  :"Nuvoloso"  
martinorob commented 9 years ago

It work like a charm!!!!!!!! Thanks you Felix!!!!!

Martino