intl dom refresh when locale changes final push for Issue #42

This commit is contained in:
Peter Cottle 2013-02-24 00:33:22 -08:00
parent 1b0d836a42
commit bd62fa735e
9 changed files with 55 additions and 8 deletions

View file

@ -40,10 +40,21 @@ var init = function() {
wait: true
});
events.on('localeChanged', intlRefresh);
initRootEvents(eventBaton);
initDemo(sandbox);
};
var intlRefresh = function() {
if (!window.$) { return; }
$('span.intl-aware').each(function(i, el) {
var intl = require('../intl');
var key = $(el).attr('data-intl');
$(el).text(intl.str(key).toUpperCase());
});
};
var initRootEvents = function(eventBaton) {
// we always want to focus the text area to collect input
var focusTextArea = function() {

View file

@ -2,7 +2,8 @@ exports.strings = {
///////////////////////////////////////////////////////////////////////////
'learn-git-branching': {
'__desc__': 'The title of the app, with spaces',
'en_US': 'Learn Git Branching'
'en_US': 'Learn Git Branching',
'ko': 'Git 브랜치 배우기'
},
///////////////////////////////////////////////////////////////////////////
'select-a-level': {

View file

@ -23,6 +23,8 @@ var instantCommands = [
}],
[/^(locale|locale reset)$/, function(bits) {
constants.GLOBAL.locale = intl.getDefaultLocale();
var Main = require('../app').getEvents().trigger('localeChanged');
throw new CommandResult({
msg: intl.str(
'locale-reset-command',
@ -33,6 +35,7 @@ var instantCommands = [
[/^locale (\w+)$/, function(bits) {
constants.GLOBAL.locale = bits[1];
var Main = require('../app').getEvents().trigger('localeChanged');
throw new CommandResult({
msg: intl.str(
'locale-command',

View file

@ -23,7 +23,8 @@ var toGlobalize = {
GitDemonstrationView: require('../views/gitDemonstrationView'),
Markdown: require('markdown'),
LevelDropdownView: require('../views/levelDropdownView'),
BuilderViews: require('../views/builderViews')
BuilderViews: require('../views/builderViews'),
Intl: require('../intl')
};
_.each(toGlobalize, function(module) {