Created
September 6, 2017 02:47
-
-
Save taufiksu/5a4223b7f0e88989c6a3f34a51c18607 to your computer and use it in GitHub Desktop.
Multi Language Code For Framework 7
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 localize = { | |
locals: { | |
'id': { | |
title: "Judul Baru", | |
description: "Deskripsi Baru" | |
}, | |
'en': { | |
title: "New Title", | |
description: "New Description" | |
} | |
}, | |
start: function (lang) { | |
lang = lang.toLowerCase(); | |
var langs = this.locals; | |
$$('.lang').each(function () { | |
var txt = $$(this).data('lang'); | |
var to = $$(this).data('lang-to'); | |
if (txt !== '' && typeof langs[lang][txt] !== 'undefined') { | |
switch (to) { | |
case 'text': | |
$$(this).text(langs[lang][txt]); | |
break; | |
case 'placeholder': | |
case 'alt': | |
case 'title': | |
$$(this).attr(to, langs[lang][txt]); | |
break; | |
case 'html': | |
default: | |
$$(this).html(langs[lang][txt]); | |
break; | |
} | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// To Use It
Put the code when cordova start
Put in html file