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

@ -6602,7 +6602,8 @@ require.define("/src/js/intl/strings.js",function(require,module,exports,__dirna
///////////////////////////////////////////////////////////////////////////
'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': {
@ -6845,10 +6846,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() {
@ -13747,6 +13759,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',
@ -13757,6 +13771,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',
@ -20173,10 +20188,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() {
@ -22887,7 +22913,8 @@ require.define("/src/js/intl/strings.js",function(require,module,exports,__dirna
///////////////////////////////////////////////////////////////////////////
'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': {
@ -24714,6 +24741,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',
@ -24724,6 +24753,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',
@ -25192,7 +25222,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) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
build/bundle.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -412,7 +412,7 @@
For a much easier time perusing the source, see the individual files at:
https://github.com/pcottle/learnGitBranching
-->
<script src="build/bundle.min.6e347137.js"></script>
<script src="build/bundle.min.4924ef88.js"></script>
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
The downside? No raw logs to parse for analytics, so I have to include

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) {