2017-06-28 39 views
2

我目前使用simpleWeather.js顯示在我的個人網站簡單的天氣預報。這很好,但我遇到了一個簡單的問題。在荷蘭語中顯示明天和明天?

目前它輸出預報在英國,如:

  • THU:22℃
  • FRI:26℃下
  • SAT:23℃

然而代替示出的「THU:」我想讓它顯示「Donderdag:」。 顯然,本週剩餘日子的結果相同。

我知道這是較受歡迎的有一個工作的代碼示例,所以我創建了一個在這裏:

https://codepen.io/anon/pen/Moreab

$(document).ready(function() { 
    $.simpleWeather({ 
    location: 'Austin, TX', 
    woeid: '', 
    unit: 'c', 
    success: function(weather) { 

    html = '<p>'+weather.forecast[1].day+': <i class="weerklein icon-'+weather.forecast[1].code+'"></i> min. '+weather.forecast[1].low+' max. '+weather.forecast[1].high+'</p>'; 
    html += '<p>'+weather.forecast[2].day+': <i class="weerklein icon-'+weather.forecast[2].code+'"></i> min. '+weather.forecast[2].low+' max. '+weather.forecast[2].high+'</p>'; 
    html += '<p>'+weather.forecast[3].day+': <i class="weerklein icon-'+weather.forecast[3].code+'"></i> min. '+weather.forecast[3].low+' max. '+weather.forecast[3].high+'</p>'; 
    html += '<p>'+weather.forecast[4].day+': <i class="weerklein icon-'+weather.forecast[4].code+'"></i> min. '+weather.forecast[4].low+' max. '+weather.forecast[4].high+'</p>'; 

    $("#weather").html(html); 
}, 
error: function(error) { 
    $("#weather").html('<p>'+error+'</p>'); 
} 
}); 
}); 

它看起來醜陋,但它顯示正是我的意思。正如你可以看到它顯示THU:FRI:SAT:等等

我希望這些改變對他們的荷蘭的親戚。 有人能告訴我如何做到這一點? TY。

回答

2

您可以使用對象的英文名字翻譯成荷蘭語:

var day_to_dutch = { 
    Mon: 'Maandag', 
    Tue: 'Dinsdag', 
    Wed: 'Woensdag', 
    Thu: 'Donderdag', 
    Fri: 'Vrijdag', 
    Sat: 'Zaterdag', 
    Sun: 'Zondag' 
}; 

翻譯可以做如下:

day_to_dutch[weather.forecast[1].day] 
+0

謝謝!你是一個拯救生命的人!我花了一個多小時來完成這項工作,但我不知道我在做什麼。 :P非常感謝。在時間限制結束後將接受最佳答案。再一次感謝你。 – Tr3m0r