mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 16:38:50 +02:00
before big intl merge on levels
This commit is contained in:
parent
9a497cfbad
commit
eedce6616a
10 changed files with 260 additions and 92 deletions
218
build/bundle.js
218
build/bundle.js
|
@ -4460,17 +4460,6 @@ exports.isBrowser = function() {
|
||||||
return inBrowser;
|
return inBrowser;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getLocale = function() {
|
|
||||||
if (constants.GLOBAL.locale) {
|
|
||||||
return constants.GLOBAL.locale;
|
|
||||||
}
|
|
||||||
return exports.getDefaultLocale();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.getDefaultLocale = function() {
|
|
||||||
return 'en_US';
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.splitTextCommand = function(value, func, context) {
|
exports.splitTextCommand = function(value, func, context) {
|
||||||
func = _.bind(func, context);
|
func = _.bind(func, context);
|
||||||
_.each(value.split(';'), function(command, index) {
|
_.each(value.split(';'), function(command, index) {
|
||||||
|
@ -7199,7 +7188,27 @@ var util = require('../util');
|
||||||
|
|
||||||
var strings = require('../intl/strings').strings;
|
var strings = require('../intl/strings').strings;
|
||||||
|
|
||||||
|
var getDefaultLocale = exports.getDefaultLocale = function() {
|
||||||
|
return 'en_US';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getLocale = exports.getLocale = function() {
|
||||||
|
if (constants.GLOBAL.locale) {
|
||||||
|
return constants.GLOBAL.locale;
|
||||||
|
}
|
||||||
|
return getDefaultLocale();
|
||||||
|
};
|
||||||
|
|
||||||
|
// lets change underscores template settings so it interpolates
|
||||||
|
// things like "{branchName} does not exist".
|
||||||
|
var templateSettings = _.clone(_.templateSettings);
|
||||||
|
templateSettings.interpolate = /\{(.+?)\}/g;
|
||||||
|
var template = function(str, params) {
|
||||||
|
return _.template(str, params, templateSettings);
|
||||||
|
};
|
||||||
|
|
||||||
var str = exports.str = function(key, params) {
|
var str = exports.str = function(key, params) {
|
||||||
|
params = params || {};
|
||||||
// this function takes a key like "error-branch-delete"
|
// this function takes a key like "error-branch-delete"
|
||||||
// and parameters like {branchName: 'bugFix', num: 3}.
|
// and parameters like {branchName: 'bugFix', num: 3}.
|
||||||
//
|
//
|
||||||
|
@ -7212,7 +7221,7 @@ var str = exports.str = function(key, params) {
|
||||||
// 'You can not delete the branch bugFix because you are currently on that branch!
|
// 'You can not delete the branch bugFix because you are currently on that branch!
|
||||||
// This is error number 3'
|
// This is error number 3'
|
||||||
|
|
||||||
var locale = util.getLocale();
|
var locale = getLocale();
|
||||||
if (!strings[key]) {
|
if (!strings[key]) {
|
||||||
console.warn('NO INTL support for key ' + key);
|
console.warn('NO INTL support for key ' + key);
|
||||||
return 'NO INTL support for key ' + key;
|
return 'NO INTL support for key ' + key;
|
||||||
|
@ -7225,31 +7234,51 @@ var str = exports.str = function(key, params) {
|
||||||
return 'No translation for that key ' + key;
|
return 'No translation for that key ' + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - interpolation
|
return template(
|
||||||
return strings[key][locale];
|
strings[key][locale],
|
||||||
|
params
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
var getIntlKey = exports.getIntlKey = function(obj, key) {
|
||||||
|
if (!obj || !obj[key]) {
|
||||||
|
throw new Error('that key ' + key + 'doesnt exist in this blob' + obj);
|
||||||
|
}
|
||||||
|
if (!obj[key][getDefaultLocale()]) {
|
||||||
|
console.warn(
|
||||||
|
'WARNING!! This blob does not have intl support:',
|
||||||
|
obj,
|
||||||
|
'for this key',
|
||||||
|
key
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj[key][getLocale()];
|
||||||
|
};
|
||||||
|
|
||||||
|
var getHint = exports.getHint = function(level) {
|
||||||
|
return getIntlKey(level, 'hint') || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getName = exports.getName = function(level) {
|
||||||
|
return getIntlKey(level, 'name') || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
var getStartDialog = exports.getStartDialog = function(level) {
|
var getStartDialog = exports.getStartDialog = function(level) {
|
||||||
if (!level || !level.startDialog) {
|
var startDialog = getIntlKey(level, 'startDialog');
|
||||||
throw new Error('start dialog doesnt exist in that blob');
|
if (startDialog) { return startDialog; }
|
||||||
}
|
|
||||||
if (!level.startDialog[util.getDefaultLocale()]) {
|
|
||||||
console.warn('WARNING!! This dialog does not have intl support: ', level);
|
|
||||||
}
|
|
||||||
var locale = util.getLocale();
|
|
||||||
if (level.startDialog[locale]) {
|
|
||||||
return level.startDialog[locale];
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need to return english but add their locale error
|
// this level translation isnt supported yet, so lets add
|
||||||
var startCopy = _.clone(level.startDialog[util.getDefaultLocale()] || level.startDialog);
|
// an alert to the front and give the english version.
|
||||||
console.log('start copy is', startCopy, 'and defaukt', level);
|
|
||||||
var errorAlert = {
|
var errorAlert = {
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
markdown: str('error-untranslated')
|
markdown: str('error-untranslated')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var startCopy = _.clone(
|
||||||
|
level.startDialog[util.getDefaultLocale()] || level.startDialog
|
||||||
|
);
|
||||||
startCopy.childViews.unshift(errorAlert);
|
startCopy.childViews.unshift(errorAlert);
|
||||||
|
|
||||||
return startCopy;
|
return startCopy;
|
||||||
|
@ -13486,6 +13515,7 @@ require.define("/src/js/level/sandboxCommands.js",function(require,module,export
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
|
|
||||||
var constants = require('../util/constants');
|
var constants = require('../util/constants');
|
||||||
|
var intl = require('../intl');
|
||||||
|
|
||||||
var Errors = require('../util/errors');
|
var Errors = require('../util/errors');
|
||||||
var CommandProcessError = Errors.CommandProcessError;
|
var CommandProcessError = Errors.CommandProcessError;
|
||||||
|
@ -13505,9 +13535,9 @@ var instantCommands = [
|
||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
[/^(locale|locale reset)$/, function(bits) {
|
[/^(locale|locale reset)$/, function(bits) {
|
||||||
constants.GLOBAL.locale = util.getDefaultLocale();
|
constants.GLOBAL.locale = intl.getDefaultLocale();
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: 'Locale reset to default, which is ' + util.getDefaultLocale()
|
msg: 'Locale reset to default, which is ' + intl.getDefaultLocale()
|
||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
[/^locale (\w+)$/, function(bits) {
|
[/^locale (\w+)$/, function(bits) {
|
||||||
|
@ -19759,6 +19789,10 @@ require.define("/src/js/util/mock.js",function(require,module,exports,__dirname,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
require.define("fs",function(require,module,exports,__dirname,__filename,process,global){// nothing to see here... no file methods for the browser
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/js/visuals/tree.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
require.define("/src/js/visuals/tree.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
|
@ -22424,7 +22458,27 @@ var util = require('../util');
|
||||||
|
|
||||||
var strings = require('../intl/strings').strings;
|
var strings = require('../intl/strings').strings;
|
||||||
|
|
||||||
|
var getDefaultLocale = exports.getDefaultLocale = function() {
|
||||||
|
return 'en_US';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getLocale = exports.getLocale = function() {
|
||||||
|
if (constants.GLOBAL.locale) {
|
||||||
|
return constants.GLOBAL.locale;
|
||||||
|
}
|
||||||
|
return getDefaultLocale();
|
||||||
|
};
|
||||||
|
|
||||||
|
// lets change underscores template settings so it interpolates
|
||||||
|
// things like "{branchName} does not exist".
|
||||||
|
var templateSettings = _.clone(_.templateSettings);
|
||||||
|
templateSettings.interpolate = /\{(.+?)\}/g;
|
||||||
|
var template = function(str, params) {
|
||||||
|
return _.template(str, params, templateSettings);
|
||||||
|
};
|
||||||
|
|
||||||
var str = exports.str = function(key, params) {
|
var str = exports.str = function(key, params) {
|
||||||
|
params = params || {};
|
||||||
// this function takes a key like "error-branch-delete"
|
// this function takes a key like "error-branch-delete"
|
||||||
// and parameters like {branchName: 'bugFix', num: 3}.
|
// and parameters like {branchName: 'bugFix', num: 3}.
|
||||||
//
|
//
|
||||||
|
@ -22437,7 +22491,7 @@ var str = exports.str = function(key, params) {
|
||||||
// 'You can not delete the branch bugFix because you are currently on that branch!
|
// 'You can not delete the branch bugFix because you are currently on that branch!
|
||||||
// This is error number 3'
|
// This is error number 3'
|
||||||
|
|
||||||
var locale = util.getLocale();
|
var locale = getLocale();
|
||||||
if (!strings[key]) {
|
if (!strings[key]) {
|
||||||
console.warn('NO INTL support for key ' + key);
|
console.warn('NO INTL support for key ' + key);
|
||||||
return 'NO INTL support for key ' + key;
|
return 'NO INTL support for key ' + key;
|
||||||
|
@ -22450,31 +22504,51 @@ var str = exports.str = function(key, params) {
|
||||||
return 'No translation for that key ' + key;
|
return 'No translation for that key ' + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - interpolation
|
return template(
|
||||||
return strings[key][locale];
|
strings[key][locale],
|
||||||
|
params
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
var getIntlKey = exports.getIntlKey = function(obj, key) {
|
||||||
|
if (!obj || !obj[key]) {
|
||||||
|
throw new Error('that key ' + key + 'doesnt exist in this blob' + obj);
|
||||||
|
}
|
||||||
|
if (!obj[key][getDefaultLocale()]) {
|
||||||
|
console.warn(
|
||||||
|
'WARNING!! This blob does not have intl support:',
|
||||||
|
obj,
|
||||||
|
'for this key',
|
||||||
|
key
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj[key][getLocale()];
|
||||||
|
};
|
||||||
|
|
||||||
|
var getHint = exports.getHint = function(level) {
|
||||||
|
return getIntlKey(level, 'hint') || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getName = exports.getName = function(level) {
|
||||||
|
return getIntlKey(level, 'name') || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
var getStartDialog = exports.getStartDialog = function(level) {
|
var getStartDialog = exports.getStartDialog = function(level) {
|
||||||
if (!level || !level.startDialog) {
|
var startDialog = getIntlKey(level, 'startDialog');
|
||||||
throw new Error('start dialog doesnt exist in that blob');
|
if (startDialog) { return startDialog; }
|
||||||
}
|
|
||||||
if (!level.startDialog[util.getDefaultLocale()]) {
|
|
||||||
console.warn('WARNING!! This dialog does not have intl support: ', level);
|
|
||||||
}
|
|
||||||
var locale = util.getLocale();
|
|
||||||
if (level.startDialog[locale]) {
|
|
||||||
return level.startDialog[locale];
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need to return english but add their locale error
|
// this level translation isnt supported yet, so lets add
|
||||||
var startCopy = _.clone(level.startDialog[util.getDefaultLocale()] || level.startDialog);
|
// an alert to the front and give the english version.
|
||||||
console.log('start copy is', startCopy, 'and defaukt', level);
|
|
||||||
var errorAlert = {
|
var errorAlert = {
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
markdown: str('error-untranslated')
|
markdown: str('error-untranslated')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var startCopy = _.clone(
|
||||||
|
level.startDialog[util.getDefaultLocale()] || level.startDialog
|
||||||
|
);
|
||||||
startCopy.childViews.unshift(errorAlert);
|
startCopy.childViews.unshift(errorAlert);
|
||||||
|
|
||||||
return startCopy;
|
return startCopy;
|
||||||
|
@ -22485,6 +22559,44 @@ var getStartDialog = exports.getStartDialog = function(level) {
|
||||||
});
|
});
|
||||||
require("/src/js/intl/index.js");
|
require("/src/js/intl/index.js");
|
||||||
|
|
||||||
|
require.define("/src/js/intl/merge.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var intlKey = exports.intlKey = function(obj, key) {
|
||||||
|
if (typeof obj[key] !== 'string') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj[key] = {
|
||||||
|
'en_US': obj[key]
|
||||||
|
};
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
var intlLevel = exports.intlLevel = function(level) {
|
||||||
|
var keys = [
|
||||||
|
'hint',
|
||||||
|
'name'
|
||||||
|
];
|
||||||
|
_.each(keys, function(key) {
|
||||||
|
intlKey(level, key);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
return level;
|
||||||
|
};
|
||||||
|
|
||||||
|
var intlPath = exports.intlPath = function(path) {
|
||||||
|
var level = require(path).level;
|
||||||
|
level = intlLevel(level);
|
||||||
|
|
||||||
|
var output = JSON.stringify(level, null, 2);
|
||||||
|
fs.writeFileSync(path, output);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
require("/src/js/intl/merge.js");
|
||||||
|
|
||||||
require.define("/src/js/intl/strings.js",function(require,module,exports,__dirname,__filename,process,global){exports.strings = {
|
require.define("/src/js/intl/strings.js",function(require,module,exports,__dirname,__filename,process,global){exports.strings = {
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
'error-untranslated-key': {
|
'error-untranslated-key': {
|
||||||
|
@ -24107,6 +24219,7 @@ require.define("/src/js/level/sandboxCommands.js",function(require,module,export
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
|
|
||||||
var constants = require('../util/constants');
|
var constants = require('../util/constants');
|
||||||
|
var intl = require('../intl');
|
||||||
|
|
||||||
var Errors = require('../util/errors');
|
var Errors = require('../util/errors');
|
||||||
var CommandProcessError = Errors.CommandProcessError;
|
var CommandProcessError = Errors.CommandProcessError;
|
||||||
|
@ -24126,9 +24239,9 @@ var instantCommands = [
|
||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
[/^(locale|locale reset)$/, function(bits) {
|
[/^(locale|locale reset)$/, function(bits) {
|
||||||
constants.GLOBAL.locale = util.getDefaultLocale();
|
constants.GLOBAL.locale = intl.getDefaultLocale();
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: 'Locale reset to default, which is ' + util.getDefaultLocale()
|
msg: 'Locale reset to default, which is ' + intl.getDefaultLocale()
|
||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
[/^locale (\w+)$/, function(bits) {
|
[/^locale (\w+)$/, function(bits) {
|
||||||
|
@ -24820,17 +24933,6 @@ exports.isBrowser = function() {
|
||||||
return inBrowser;
|
return inBrowser;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getLocale = function() {
|
|
||||||
if (constants.GLOBAL.locale) {
|
|
||||||
return constants.GLOBAL.locale;
|
|
||||||
}
|
|
||||||
return exports.getDefaultLocale();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.getDefaultLocale = function() {
|
|
||||||
return 'en_US';
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.splitTextCommand = function(value, func, context) {
|
exports.splitTextCommand = function(value, func, context) {
|
||||||
func = _.bind(func, context);
|
func = _.bind(func, context);
|
||||||
_.each(value.split(';'), function(command, index) {
|
_.each(value.split(';'), function(command, index) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
1
build/bundle.min.e3e97703.js
Normal file
1
build/bundle.min.e3e97703.js
Normal file
File diff suppressed because one or more lines are too long
2
build/bundle.min.js
vendored
2
build/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -264,7 +264,8 @@
|
||||||
<div class="view box horizontal centerAlign justify">
|
<div class="view box horizontal centerAlign justify">
|
||||||
<div class="box horizontal">
|
<div class="box horizontal">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
View #<%= i + 1 %>: <%= views[i].type %>
|
View
|
||||||
|
#<%= i + 1 %>: <%= views[i].type %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="singleViewButtons box horizontal">
|
<div class="singleViewButtons box horizontal">
|
||||||
|
@ -409,7 +410,7 @@
|
||||||
For a much easier time perusing the source, see the individual files at:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
-->
|
-->
|
||||||
<script src="build/bundle.min.48d953af.js"></script>
|
<script src="build/bundle.min.e3e97703.js"></script>
|
||||||
|
|
||||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
<!-- 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
|
The downside? No raw logs to parse for analytics, so I have to include
|
||||||
|
|
|
@ -4,7 +4,27 @@ var util = require('../util');
|
||||||
|
|
||||||
var strings = require('../intl/strings').strings;
|
var strings = require('../intl/strings').strings;
|
||||||
|
|
||||||
|
var getDefaultLocale = exports.getDefaultLocale = function() {
|
||||||
|
return 'en_US';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getLocale = exports.getLocale = function() {
|
||||||
|
if (constants.GLOBAL.locale) {
|
||||||
|
return constants.GLOBAL.locale;
|
||||||
|
}
|
||||||
|
return getDefaultLocale();
|
||||||
|
};
|
||||||
|
|
||||||
|
// lets change underscores template settings so it interpolates
|
||||||
|
// things like "{branchName} does not exist".
|
||||||
|
var templateSettings = _.clone(_.templateSettings);
|
||||||
|
templateSettings.interpolate = /\{(.+?)\}/g;
|
||||||
|
var template = function(str, params) {
|
||||||
|
return _.template(str, params, templateSettings);
|
||||||
|
};
|
||||||
|
|
||||||
var str = exports.str = function(key, params) {
|
var str = exports.str = function(key, params) {
|
||||||
|
params = params || {};
|
||||||
// this function takes a key like "error-branch-delete"
|
// this function takes a key like "error-branch-delete"
|
||||||
// and parameters like {branchName: 'bugFix', num: 3}.
|
// and parameters like {branchName: 'bugFix', num: 3}.
|
||||||
//
|
//
|
||||||
|
@ -17,7 +37,7 @@ var str = exports.str = function(key, params) {
|
||||||
// 'You can not delete the branch bugFix because you are currently on that branch!
|
// 'You can not delete the branch bugFix because you are currently on that branch!
|
||||||
// This is error number 3'
|
// This is error number 3'
|
||||||
|
|
||||||
var locale = util.getLocale();
|
var locale = getLocale();
|
||||||
if (!strings[key]) {
|
if (!strings[key]) {
|
||||||
console.warn('NO INTL support for key ' + key);
|
console.warn('NO INTL support for key ' + key);
|
||||||
return 'NO INTL support for key ' + key;
|
return 'NO INTL support for key ' + key;
|
||||||
|
@ -30,31 +50,51 @@ var str = exports.str = function(key, params) {
|
||||||
return 'No translation for that key ' + key;
|
return 'No translation for that key ' + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - interpolation
|
return template(
|
||||||
return strings[key][locale];
|
strings[key][locale],
|
||||||
|
params
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
var getIntlKey = exports.getIntlKey = function(obj, key) {
|
||||||
|
if (!obj || !obj[key]) {
|
||||||
|
throw new Error('that key ' + key + 'doesnt exist in this blob' + obj);
|
||||||
|
}
|
||||||
|
if (!obj[key][getDefaultLocale()]) {
|
||||||
|
console.warn(
|
||||||
|
'WARNING!! This blob does not have intl support:',
|
||||||
|
obj,
|
||||||
|
'for this key',
|
||||||
|
key
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj[key][getLocale()];
|
||||||
|
};
|
||||||
|
|
||||||
|
var getHint = exports.getHint = function(level) {
|
||||||
|
return getIntlKey(level, 'hint') || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getName = exports.getName = function(level) {
|
||||||
|
return getIntlKey(level, 'name') || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
var getStartDialog = exports.getStartDialog = function(level) {
|
var getStartDialog = exports.getStartDialog = function(level) {
|
||||||
if (!level || !level.startDialog) {
|
var startDialog = getIntlKey(level, 'startDialog');
|
||||||
throw new Error('start dialog doesnt exist in that blob');
|
if (startDialog) { return startDialog; }
|
||||||
}
|
|
||||||
if (!level.startDialog[util.getDefaultLocale()]) {
|
|
||||||
console.warn('WARNING!! This dialog does not have intl support: ', level);
|
|
||||||
}
|
|
||||||
var locale = util.getLocale();
|
|
||||||
if (level.startDialog[locale]) {
|
|
||||||
return level.startDialog[locale];
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need to return english but add their locale error
|
// this level translation isnt supported yet, so lets add
|
||||||
var startCopy = _.clone(level.startDialog[util.getDefaultLocale()] || level.startDialog);
|
// an alert to the front and give the english version.
|
||||||
console.log('start copy is', startCopy, 'and defaukt', level);
|
|
||||||
var errorAlert = {
|
var errorAlert = {
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
markdown: str('error-untranslated')
|
markdown: str('error-untranslated')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var startCopy = _.clone(
|
||||||
|
level.startDialog[util.getDefaultLocale()] || level.startDialog
|
||||||
|
);
|
||||||
startCopy.childViews.unshift(errorAlert);
|
startCopy.childViews.unshift(errorAlert);
|
||||||
|
|
||||||
return startCopy;
|
return startCopy;
|
||||||
|
|
34
src/js/intl/merge.js
Normal file
34
src/js/intl/merge.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
var _ = require('underscore');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var intlKey = exports.intlKey = function(obj, key) {
|
||||||
|
if (typeof obj[key] !== 'string') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj[key] = {
|
||||||
|
'en_US': obj[key]
|
||||||
|
};
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
var intlLevel = exports.intlLevel = function(level) {
|
||||||
|
var keys = [
|
||||||
|
'hint',
|
||||||
|
'name'
|
||||||
|
];
|
||||||
|
_.each(keys, function(key) {
|
||||||
|
intlKey(level, key);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
return level;
|
||||||
|
};
|
||||||
|
|
||||||
|
var intlPath = exports.intlPath = function(path) {
|
||||||
|
var level = require(path).level;
|
||||||
|
level = intlLevel(level);
|
||||||
|
|
||||||
|
var output = JSON.stringify(level, null, 2);
|
||||||
|
fs.writeFileSync(path, output);
|
||||||
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@ var _ = require('underscore');
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
|
|
||||||
var constants = require('../util/constants');
|
var constants = require('../util/constants');
|
||||||
|
var intl = require('../intl');
|
||||||
|
|
||||||
var Errors = require('../util/errors');
|
var Errors = require('../util/errors');
|
||||||
var CommandProcessError = Errors.CommandProcessError;
|
var CommandProcessError = Errors.CommandProcessError;
|
||||||
|
@ -21,9 +22,9 @@ var instantCommands = [
|
||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
[/^(locale|locale reset)$/, function(bits) {
|
[/^(locale|locale reset)$/, function(bits) {
|
||||||
constants.GLOBAL.locale = util.getDefaultLocale();
|
constants.GLOBAL.locale = intl.getDefaultLocale();
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: 'Locale reset to default, which is ' + util.getDefaultLocale()
|
msg: 'Locale reset to default, which is ' + intl.getDefaultLocale()
|
||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
[/^locale (\w+)$/, function(bits) {
|
[/^locale (\w+)$/, function(bits) {
|
||||||
|
|
|
@ -16,17 +16,6 @@ exports.isBrowser = function() {
|
||||||
return inBrowser;
|
return inBrowser;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getLocale = function() {
|
|
||||||
if (constants.GLOBAL.locale) {
|
|
||||||
return constants.GLOBAL.locale;
|
|
||||||
}
|
|
||||||
return exports.getDefaultLocale();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.getDefaultLocale = function() {
|
|
||||||
return 'en_US';
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.splitTextCommand = function(value, func, context) {
|
exports.splitTextCommand = function(value, func, context) {
|
||||||
func = _.bind(func, context);
|
func = _.bind(func, context);
|
||||||
_.each(value.split(';'), function(command, index) {
|
_.each(value.split(';'), function(command, index) {
|
||||||
|
|
|
@ -264,7 +264,8 @@
|
||||||
<div class="view box horizontal centerAlign justify">
|
<div class="view box horizontal centerAlign justify">
|
||||||
<div class="box horizontal">
|
<div class="box horizontal">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
View #<%= i + 1 %>: <%= views[i].type %>
|
View
|
||||||
|
#<%= i + 1 %>: <%= views[i].type %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="singleViewButtons box horizontal">
|
<div class="singleViewButtons box horizontal">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue