2017-06-28 8 views
2

私は現在、simpleWeather.jsを使用して私の個人的なウェブサイトに簡単な天気予報を表示しています。素晴らしいですが、私は簡単な問題を経験しています。明日と翌日をオランダ語で表示していますか?

よう現在のところそれは、英語での予測を出力します

  • 木:22°C
  • 金:26°C
  • SAT:23°C

しかし代わりに示します"THU:" "Donderdag"を表示したい。 明らかに、残りの曜日の同じ結果です。

私は作業コード例を持っている兼ね備えています知っているので、私はここに1を作成しました:

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>'); 
} 
}); 
}); 

をそれは醜いが、私が意味する、まさに示しています。あなたが見ることができるように、それは以下を示しています:金:土:等...

私はそれらをオランダの親戚に変更します。 誰かがこれを達成する方法を教えてもらえますか? 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

ありがとうございました!あなたは命を救う人です!私はこの仕事をするのに1時間以上を費やしますが、私は何をしているのか分かりません。 :Pとても多くのありがとう。制限時間が終わったときに最善の答えとして受け入れます。もう一度ありがとうございます。 – Tr3m0r

関連する問題