天氣英文說明部份如何中文化?爬了很多文還是搞不懂,希望能協助小弟。

天氣設定檔如附件。

檔案上傳失敗以貼文方式,如下:weather.js
var useRealFeel = false;
var stylesheet = 'mini'
var iconSet = 'vclouds'
var iconExt = '.png'
var source = 'yahooWeather'
var updateInterval = 15
var postal;
var MiniIcons =
[
"0", //0 tornado
"1", //1 tropical storm
"2", //2 hurricane
"3", //3 severe thunderstorms
"4", //4 thunderstorms
"5", //5 mixed rain and snow
"6", //6 mixed rain and sleet
"7", //7 mixed snow and sleet
"8", //8 freezing drizzle
"9", //9 drizzle
"10", //10 freezing rain
"11", //11 showers
"12", //12 showers
"13", //13 snow flurries
"14", //14 light snow showers
"15", //15 blowing snow
"16", //16 snow
"17", //17 hail
"18", //18 sleet
"19", //19 dust
"20", //20 foggy
"21", //21 haze
"22", //22 smoky
"23", //23 blustery
"24", //24 windy
"25", //25 cold
"26", //26 cloudy
"27", //27 mostly cloudy (night)
"28", //28 mostly cloudy (day)
"29", //29 partly cloudy (night)
"30", //30 partly cloudy (day)
"31", //31 clear (night)
"32", //32 sunny
"33", //33 fair (night)
"34", //34 fair (day)
"35", //35 mixed rain and hail
"36", //36 hot
"37", //37 isolated thunderstorms
"38", //38 scattered thunderstorms
"39", //39 scattered thunderstorms
"40", //40 scattered showers
"41", //41 heavy snow
"42", //42 scattered snow showers
"43", //43 heavy snow
"44", //44 partly cloudy
"45", //45 thundershowers
"46", //46 snow showers
"47", //47 isolated thundershowers
"dunno", //3200 not available
]
function enableWeather() {
document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+"na"+iconExt;
validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)
};
function setPostal(obj) {
if (obj.error == false){
if(obj.cities.length > 0){
postal = escape(obj.cities[0].zip).replace(/^%u/g, "%")
document.getElementById("WeatherContainer").className = "";
weatherRefresherTemp();
}
else {
document.getElementById("WeatherContainer").className = "errorLocaleNotFound";
}
}
else {
document.getElementById("WeatherContainer").className = "errorLocaleValidate";
setTimeout('validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)', Math.round(1000*60*5));
}
};
function dealWithWeather(obj) {
if (obj.error == false){
if(useRealFeel == true){
tempValue = convertTemp(obj.realFeel);
}
else {
tempValue = convertTemp(obj.temp)
}
var xl = convertTemp(obj.plus1low);
var xxl = convertTemp(obj.plus2low);
var xxxl = convertTemp(obj.plus3low);
var xxxxl = convertTemp(obj.plus4low);
var xh = convertTemp(obj.plus1high);
var xxh = convertTemp(obj.plus2high);
var xxxh = convertTemp(obj.plus3high);
var xxxxh = convertTemp(obj.plus4high);
document.getElementById("temp")[removed]=tempValue+ "°";
document.getElementById("lowhigh")[removed]="低溫: "+convertTemp(obj.plus0low)+ "° / 高溫: "+convertTemp(obj.plus0high)+ "°";
document.getElementById("tempplus2day")[removed] = '' + longform(obj.plus1day) + '
' +
obj.plus1text + '
' + xl + '° | ' + xh + '°';
document.getElementById("tempplus3day")[removed] = '' + longform(obj.plus2day) + '
' +
obj.plus2text + '
' + xxl + '° | ' + xxh + '°';
document.getElementById("tempplus4day")[removed] = '' + longform(obj.plus3day) + '
' +
obj.plus3text + '
' + xxxl + '° | ' + xxxh + '°';
document.getElementById("tempplus5day")[removed] = '' + longform(obj.plus4day) + '
' +
obj.plus4text + '
' + xxxxl + '° | ' + xxxxh + '°';
document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+MiniIcons[obj.icon]+iconExt;
document.getElementById("WeatherContainer").className = "";
document.getElementById("city")[removed] = obj.city;
document.getElementById("condition")[removed] = obj.condition;
}else{
document.getElementById("WeatherContainer").className = "errorWeatherDataFetch";
}
};
function weatherRefresherTemp() {
fetchWeatherData(dealWithWeather,postal);
setTimeout(weatherRefresherTemp, 60*1000*updateInterval);
};
function constructError (string) {
return {error:true, errorString:string};
};
function findChild (element, nodeName) {
var child;
for (child = element.firstChild; child != null; child = child.nextSibling) {
if (child.nodeName == nodeName)
return child;
}
return null;
};
function fetchWeatherData (callback, zip) {
url="http://xml.weather.yahoo.com/forecastrss/" //u=Farenheit, because accuWeather sucks
var xml_request = new XMLHttpRequest();
xml_request.onload = function(e) {xml_loaded(e, xml_request, callback);}
xml_request.overrideMimeType("text/xml");
xml_request.open("GET", url+zip+".xml");
xml_request.setRequestHeader("Cache-Control", "no-cache");
xml_request.send(null);
return xml_request;
};
function xml_loaded (event, request, callback) {
if (request.responseXML)
{
var obj = {error:false, errorString:null};
var effectiveRoot = findChild(findChild(request.responseXML, "rss"), "channel");
obj.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");
conditionTag = findChild(findChild(effectiveRoot, "item"), "yweather:condition");
obj.temp = conditionTag.getAttribute("temp");
obj.icon = conditionTag.getAttribute("code");
obj.condition = conditionTag.getAttribute("text");
obj.city = findChild(effectiveRoot, "yweather:location").getAttribute("city");
obj.city = "桃園市";
obj.plus0low = request.responseXML.getElementsByTagName("forecast")[0].getAttribute("low");
obj.plus1low = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("low");
obj.plus2low = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("low");
obj.plus3low = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("low");
obj.plus4low = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("low");
obj.plus0high = request.responseXML.getElementsByTagName("forecast")[0].getAttribute("high");
obj.plus1high = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("high");
obj.plus2high = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("high");
obj.plus3high = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("high");
obj.plus4high = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("high");
obj.plus0day = request.responseXML.getElementsByTagName("forecast")[0].getAttribute("day");
obj.plus1day = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("day");
obj.plus2day = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("day");
obj.plus3day = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("day");
obj.plus4day = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("day");
obj.plus0code = request.responseXML.getElementsByTagName("forecast")[0].getAttribute("code");
obj.plus1code = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("code");
obj.plus2code = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("code");
obj.plus3code = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("code");
obj.plus4code = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("code");
obj.plus1text = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("text");
obj.plus2text = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("text");
obj.plus3text = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("text");
obj.plus4text = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("text");
callback (obj);
}
else {
callback ({error:true, errorString:"XML request failed. no responseXML"});
}
};
function longform(day) {
if (day == "Mon") { return "星期一"};
if (day == "Tue") { return "星期二"};
if (day == "Wed") { return "星期三"};
if (day == "Thu") { return "星期四"};
if (day == "Fri") { return "星期五"};
if (day == "Sat") { return "星期六"};
if (day == "Sun") { return "星期日"};
}
function validateWeatherLocation (location, callback) {
var obj = {error:false, errorString:null, cities: new Array};
obj.cities[0] = {zip: location}; //Not very clever, are we?
callback (obj);
};
function convertTemp(num) {
if (isCelsius == true)
return Math.round (((num - 32) * 5) / 9);
else
return parseInt(num);
};
$(document).ready(function () {
enableWeather();
});