Created
March 19, 2016 14:52
-
-
Save github-polymer-user/05aa08b49c1ff436ff7b to your computer and use it in GitHub Desktop.
Polymer i18n alpha
This file contains 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
app.LocalizationBehavior = { | |
properties: { | |
locale: { | |
type: String, | |
reflectToAttribute: true | |
}, | |
/*localized: { | |
type: Boolean, | |
value: false | |
},*/ | |
i18n: { | |
type: String, | |
reflectedToAttribute: true | |
} | |
}, | |
localize: function(callback, path, files, tag, namespace, id) { | |
//this.localized = false; | |
//this.locale = app.i18n.lang; | |
// [].forEach.call(namespaces, function() { | |
// | |
// }); | |
var _callback = function(locale) { | |
if (this.locale !== locale) { | |
this.locale = locale; | |
app.i18n.bootstrap(this.getElementsByTagName(tag), namespace); | |
app.i18n.setLocale(namespace, locale, id); | |
} else { | |
return; | |
} | |
//this.localized = true; | |
}.bind(this); | |
//namespace + (id !== undefined ? '.' + id : ''), | |
app.i18n.attach(_callback); | |
//app.i18n.subscribe(_callback); | |
app.i18n.load(path, files, namespace, function() { | |
if (app.i18n.ready(files) === true) { | |
if (callback !== undefined && callback !== null && typeof callback === 'function') { | |
callback(); | |
} | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment