如何在this.resources.language
函数中访问setLanguage()
,其中属性当前语言是资源中的四种之一?
myLanguage = new Language( 'en' );
function Language (currentLanguage) {
this.currentLanguage = currentLanguage;
this.resources = {
en: {
latest_songs_heading: "Latest",
popular_songs_heading: "Popular",
},
de: {
latest_songs_heading: "Neueste",
popular_songs_heading: "Beliebteste",
},
es: {
latest_songs_heading: "Más reciente",
popular_songs_heading: "El mas popular",
},
po: {
latest_songs_heading: "Mais recentes",
popular_songs_heading: "O mais popular",
}
},
this.getLanguage = function() {
return 'Current language: ' + this.currentLanguage;
}
this.setLanguage = function() {
var language = this.currentLanguage;
return this.resources.language;
}
}