Created
April 1, 2015 19:17
-
-
Save AlphaNerd/48f6b1ff0f894d1ba5d3 to your computer and use it in GitHub Desktop.
Basic translation script for SimpleWeather.js - Translates to French once weather.currently is passed in to function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var daysCast = 1; | |
jQuery.simpleWeather({ | |
woeid: '2357536', //2357536 | |
location: 'Shediac,NB', | |
unit: 'c', | |
success: function(weather) { | |
html = '<div id="an-todayImage"><img src="'+weather.forecast[0].image+'"/></div>'; | |
html += '<div id="an-todayTemp" class="uk-width-small-1-2"><h1>'+weather.temp+'°'+weather.units.temp+'</h1></div>'; | |
html += '<div><ul style="padding-top:15px;padding-left:15px!important;"><li style="display:inline;margin-right:10px;"><b>'+weather.city+', '+weather.region+'</b><br></li>'; | |
html += '<li style="display:inline;margin-right:10px;" class="currently">'+checkWXLang(weather.currently)+'</li>'; | |
html += '<li style="display:inline;margin-right:10px;">'+weather.alt.temp+'°F</li></ul></div>'; | |
// for(var i=0;i<daysCast;i++) { | |
// html += '<div class="an-forecastDay uk-width-1-3">'+weather.forecast[i].day+': '+weather.forecast[i].high+'</span>'+'<img src="'+weather.forecast[i].image+'"/></div>'; | |
// } | |
jQuery("#weather").html(html); | |
}, | |
error: function(error) { | |
jQuery("#weather").html('<p>'+error+'</p>'); | |
} | |
}); | |
console.log("Weather retrieved."); | |
function checkWXLang(weather){ | |
if (jQuery("body").hasClass("fr")){ | |
for (var key in myWXcodes) { | |
if (key === weather){ | |
var myWX = myWXcodes[key] | |
return myWX; | |
} | |
} | |
}else{ | |
console.log("Weather in correct language"); | |
return weather; | |
} | |
} | |
var myWXcodes = ({ | |
"Tornado":"Tournade", | |
"Tropical storm":"Tempête Tropicale", | |
"Hurricane":"Ouragan", | |
"Sever thunderstorms":"Orages Violents", | |
"Thunderstorms":"Orages", | |
"Mixed rain and snow":"Mélange de pluie et neige", | |
"Mixed rain and sleet":"Mélange de pluie et grésil", | |
"Mixed snow and sleet":"Mélange de neige et grésil", | |
"Freezing drizzle":"Bruine Verglaçante", | |
"Freezing drizzle":"Bruine Verglaçante", | |
"Drizzle":"Bruine", | |
"Freezing rain":"Pluie verglaçante", | |
"Showers":"Pluie", | |
"Showers":"Pluie", | |
"Snow flurries":"Averse de neige", | |
"Light snow showers":"Averse de neige légère", | |
"Blowing snow":"Poudrerie", | |
"Snow":"Neige", | |
"Hail":"Grêle", | |
"Sleet":"Grésil", | |
"Dust":"Poussièreux", | |
"Foggy":"Brûmeux", | |
"Haze":"Brûme", | |
"Smoky":"Enfûmé", | |
"Blustery":"Blustery", | |
"Windy":"Venteux", | |
"Cold":"Froid", | |
"Cloudy":"Nuageux", | |
"Mostly cloudy (night)":"Quelques éclaircis (nuit)", | |
"Mostly cloudy (day)":"Quelques éclaircis (jours)", | |
"Party cloudy (night)":"Partiellement nuageux (nuit)", | |
"Partly cloudy (day)":"Partiellement nuageux (jours)", | |
"Clear (night)":"Clair (nuit)", | |
"Sunny":"Ensoleiller", | |
"Fair (night)":"Beau (nuit)", | |
"Fair (day)":"Beau (jours)", | |
"Mixed rain and hail":"Mélange de pluie et verglats", | |
"hot":"Chaud", | |
"Isolated Thunderstorms":"Orages isolée", | |
"Scattered thunderstorms":"Orages dispercés", | |
"Scattered thunderstorms":"Orages dispercés", | |
"Scattered showers":"Pluie dispercés", | |
"Heavy snow":"Fortes chûtes de neige", | |
"Partly cloudy":"Partiellement nuageux", | |
"Thundershowers":"Averses orageuses", | |
"Snow showers":"Averses de neige", | |
"Isolated Thundershowers":"Orages isolés" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment