a bunch of keys from level directory

This commit is contained in:
Peter Cottle 2013-02-23 22:15:37 -08:00
parent 3adec8d88a
commit 9048f09d9f
7 changed files with 665 additions and 349 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,142 @@
exports.strings = {
////////////////////////////////////////////////////////////////////////////
'refresh-tree-command': {
'__desc__': 'when the tree is visually refreshed',
'en_US': 'Refreshing tree...'
},
'locale-command': {
'__desc__': 'when the locale is set to something',
'en_US': 'Locale set to {locale}'
},
///////////////////////////////////////////////////////////////////////////
'locale-reset-command': {
'__desc__': 'when the locale is reset',
'en_US': 'Locale reset to default, which is {locale}'
},
///////////////////////////////////////////////////////////////////////////
'cd-command': {
'__desc__': 'dummy command output for the command in the key',
'en_US': 'Directory changed to "/directories/dont/matter/in/this/demo"'
},
///////////////////////////////////////////////////////////////////////////
'ls-command': {
'__desc__': 'Dummy command output for the command in the key',
'en_US': 'DontWorryAboutFilesInThisDemo.txt'
},
'mobile-alert': {
'__desc__': 'When someone comes to the site on a mobile device, they can not input commands so this is a nasty alert to tell them',
'en_US': 'Can\'t bring up the keyboard on mobile / tablet :( try visiting on desktop! :D'
},
///////////////////////////////////////////////////////////////////////////
'share-tree': {
'__desc__': 'When you export a tree, we want you to share the tree with friends',
'en_US': 'Share this tree with friends! They can load it with "import tree"'
},
///////////////////////////////////////////////////////////////////////////
'paste-json': {
'__desc__': 'When you are importing a level or tree',
'en_US': 'Paste a JSON blob below!'
},
///////////////////////////////////////////////////////////////////////////
'solved-map-reset': {
'__desc__': 'When you reset the solved map to clear your solved history, in case someone else wants to use your browser',
'en_US': 'Solved map was reset, you are starting from a clean slate!'
},
///////////////////////////////////////////////////////////////////////////
'level-cant-exit': {
'__desc__': 'When the user tries to exit a level when they are not in one',
'en_US': 'You are not in a level! You are in a sandbox, start a level with "levels"'
},
///////////////////////////////////////////////////////////////////////////
'level-no-id': {
'__desc__': 'When you say an id but that level doesnt exist',
'en_US': 'A level for that id "{id}" was not found! Opening up a level selection view'
},
///////////////////////////////////////////////////////////////////////////
'undo-stack-empty': {
'__desc__': 'The undo command can only undo back until the last time the level was reset or the beginning of the level',
'en_US': 'The undo stack is empty!'
},
///////////////////////////////////////////////////////////////////////////
'already-solved': {
'__desc__': 'When you play in a level that is already solved',
'en_US': 'You have alreaady solved this levle, try other levels with "levels" or go back to sandbox with "sandbox"'
},
///////////////////////////////////////////////////////////////////////////
'command-disabled': {
'__desc__': 'When you try a command that is disabled',
'en_US': 'That git command is disabled for this level!'
},
///////////////////////////////////////////////////////////////////////////
'share-json': {
'__desc__': 'when you have made the level, prompt to share this',
'en_US': 'Here is the JSON for this level! Share it with somenoe or send it to me on Github'
},
///////////////////////////////////////////////////////////////////////////
'want-start-dialog': {
'__desc__': 'prompt to add a start dialog',
'en_US': 'You have not specified a start dialog, would you like to add one?'
},
///////////////////////////////////////////////////////////////////////////
'want-hint': {
'__desc__': 'prompt to add a hint',
'en_US': 'You have not specified a hint, would you like to add one?'
},
///////////////////////////////////////////////////////////////////////////
'prompt-hint': {
'__desc__': 'prompt for hint',
'en_US': 'Enter the hint for this level, or leave this blank if you do not want to include one'
},
///////////////////////////////////////////////////////////////////////////
'prompt-name': {
'__desc__': 'prompt for level name',
'en_US': 'Enter the name for the level'
},
///////////////////////////////////////////////////////////////////////////
'solution-empty': {
'__desc__': 'If you define a solution without any commands, aka a level that is solved without doing anything',
'en_US': 'Your solution is empty!! Something is amiss'
},
///////////////////////////////////////////////////////////////////////////
'define-start-warning': {
'__desc__': 'When you define the start point again, it overwrites the solution and goal so we add a warning',
'en_US': 'Defining start point... solution and goal will be overwritten if they were defined earlier'
},
///////////////////////////////////////////////////////////////////////////
'help-vague-level': {
'__desc__': 'When you are in a level and you say help, its vague and you need to specify',
'en_US': 'You are in a level, so multiple forms of help are available. Please select either "help level" or "help general"'
},
///////////////////////////////////////////////////////////////////////////
'help-vague-builder': {
'__desc__': 'When you are in a level builder, the help command is vague so you need to specify what you mean',
'en_US': 'You are in a level builder, so multiple forms of help are available. Please select either "help general" or "help builder"'
},
///////////////////////////////////////////////////////////////////////////
'hide-start': {
'__desc__': 'The helper message for the window that shows the start tree for a level',
'en_US': 'You can hide this window with "hide start"'
},
///////////////////////////////////////////////////////////////////////////
'level-builder': {
'__desc__': 'The name for the environment where you build levels',
'en_US': 'Level Builder'
},
///////////////////////////////////////////////////////////////////////////
'no-start-dialog': {
'__desc__': 'when the user tries to open a start dialog for a level that does not have one',
'en_US': 'There is no start dialog to show for this level!'
},
///////////////////////////////////////////////////////////////////////////
'no-hint': {
'__desc__': 'when no hint is available for a level',
'en_US': "Hmm, there doesn't seem to be a hint for this level :-/"
},
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
'error-untranslated-key': {
'__desc__': 'This error happens when we are trying to translate a specific key and the locale version is mission',
'en_US': 'The translation for {key} does not exist yet :( Please hop on github and offer up a translation!'
},
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
'error-untranslated': {
'__desc__': 'The general error when we encounter a dialog that is not translated',
'en_US': 'This dialog or text is not yet translated in your locale :( Hop on github to aid in translation!'

View file

@ -4,6 +4,7 @@ var Q = require('q');
var util = require('../util');
var Main = require('../app');
var intl = require('../intl');
var Errors = require('../util/errors');
var Visualization = require('../visuals/visualization').Visualization;
@ -59,7 +60,7 @@ var LevelBuilder = Level.extend({
initName: function() {
this.levelToolbar = new LevelToolbar({
name: 'Level Builder'
name: intl.str('level-builder')
});
},
@ -73,7 +74,7 @@ var LevelBuilder = Level.extend({
initStartVisualization: function() {
this.startCanvasHolder = new CanvasTerminalHolder({
additionalClass: 'startTree',
text: 'You can hide this window with "hide start"'
text: intl.str('hide-start')
});
this.startVis = new Visualization({
@ -89,7 +90,7 @@ var LevelBuilder = Level.extend({
startOffCommand: function() {
Main.getEventBaton().trigger(
'commandSubmitted',
'echo "Get Building!!"'
'echo :D'
);
},
@ -118,9 +119,7 @@ var LevelBuilder = Level.extend({
return [
[/^help$|^\?$/, function() {
throw new Errors.CommandResult({
msg: 'You are in a level builder, so multiple forms of ' +
'help are available. Please select either ' +
'"help general" or "help builder"'
msg: intl.str('help-vague-builder')
});
}]
];
@ -160,9 +159,7 @@ var LevelBuilder = Level.extend({
defineStart: function(command, deferred) {
this.hideStart();
command.addWarning(
'Defining start point... solution and goal will be overwritten if they were defined earlier'
);
command.addWarning(intl.str('define-start-warning'));
this.resetSolution();
this.level.startTree = this.mainVis.gitEngine.printTree();
@ -176,7 +173,7 @@ var LevelBuilder = Level.extend({
if (!this.gitCommandsIssued.length) {
command.set('error', new Errors.GitError({
msg: 'Your solution is empty!! something is amiss'
msg: intl.str('solution-empty')
}));
deferred.resolve();
return;
@ -191,12 +188,12 @@ var LevelBuilder = Level.extend({
},
defineName: function(command, deferred) {
this.level.name = prompt('Enter the name for the level');
this.level.name = prompt(intl.str('prompt-name'));
if (command) { command.finishWith(deferred); }
},
defineHint: function(command, deferred) {
this.level.hint = prompt('Enter a hint! Or blank if you dont want one');
this.level.hint = prompt(intl.str('prompt-hint'));
if (command) { command.finishWith(deferred); }
},
@ -225,7 +222,7 @@ var LevelBuilder = Level.extend({
finish: function(command, deferred) {
if (!this.gitCommandsIssued.length || !this.definedGoal) {
command.set('error', new Errors.GitError({
msg: 'Your solution is empty or goal is undefined!'
msg: intl.str('solution-empty')
}));
deferred.resolve();
return;
@ -247,7 +244,7 @@ var LevelBuilder = Level.extend({
// ask for a hint if there is none
var askForHintView = new ConfirmCancelTerminal({
markdowns: [
'You have not specified a hint, would you like to add one?'
intl.str('want-hint')
]
});
askForHintView.getPromise()
@ -268,7 +265,7 @@ var LevelBuilder = Level.extend({
var askForStartView = new ConfirmCancelTerminal({
markdowns: [
'You have not specified a start dialog, would you like to add one?'
intl.str('want-start-dialog')
]
});
askForStartView.getPromise()
@ -291,7 +288,7 @@ var LevelBuilder = Level.extend({
// ok great! lets just give them the goods
new MarkdownPresenter({
fillerText: JSON.stringify(this.getExportObj(), null, 2),
previewText: 'Here is the JSON for this level! Share it with someone or send it to me on Github!'
previewText: intl.str('share-json')
});
command.finishWith(deferred);
}, this));

View file

@ -1,4 +1,5 @@
var _ = require('underscore');
var intl = require('../intl');
var GitCommands = require('../git/commands');
@ -20,7 +21,7 @@ DisabledMap.prototype.getInstantCommands = function() {
var instants = [];
var onMatch = function() {
throw new GitError({
msg: 'That git command is disabled for this level!'
msg: intl.str('command-disabled')
});
};

View file

@ -80,7 +80,7 @@ var Level = Sandbox.extend({
startDialog: function(command, deferred) {
if (!this.level.startDialog) {
command.set('error', new Errors.GitError({
msg: 'There is no start dialog to show for this level!'
msg: intl.str('no-start-dialog')
}));
deferred.resolve();
return;
@ -171,6 +171,7 @@ var Level = Sandbox.extend({
// allow them for force the solution
var confirmDefer = Q.defer();
// TODO intl
var confirmView = new ConfirmCancelTerminal({
markdowns: [
'## Are you sure you want to see the solution?',
@ -183,7 +184,7 @@ var Level = Sandbox.extend({
confirmDefer.promise
.then(issueFunc)
.fail(function() {
command.setResult("Great! I'll let you get back to it");
command.setResult("");
})
.done(function() {
// either way we animate, so both options can share this logic
@ -299,10 +300,7 @@ var Level = Sandbox.extend({
afterCommandDefer: function(defer, command) {
if (this.solved) {
command.addWarning(
"You've already solved this level, try other levels with 'show levels'" +
"or go back to the sandbox with 'sandbox'"
);
command.addWarning(intl.str('already-solved'));
defer.resolve();
return;
}
@ -415,15 +413,10 @@ var Level = Sandbox.extend({
return hint;
}, this);
var hintMsg = (this.level.hint) ?
this.level.hint :
"Hmm, there doesn't seem to be a hint for this level :-/";
return [
[/^help$|^\?$/, function() {
throw new Errors.CommandResult({
msg: 'You are in a level, so multiple forms of help are available. Please select either ' +
'"help level" or "help general"'
msg: intl.str('help-vague-level')
});
}],
[/^hint$/, function() {

View file

@ -4,6 +4,7 @@ var Q = require('q');
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var util = require('../util');
var intl = require('../intl');
var Main = require('../app');
var Errors = require('../util/errors');
@ -124,7 +125,7 @@ var Sandbox = Backbone.View.extend({
var toRestore = this.undoStack.pop();
if (!toRestore) {
command.set('error', new Errors.GitError({
msg: 'The undo stack is empty!'
msg: intl.str('undo-stack-empty')
}));
deferred.resolve();
return;
@ -156,7 +157,10 @@ var Sandbox = Backbone.View.extend({
// handle the case where that level is not found...
if (!levelJSON) {
command.addWarning(
'A level for that id "' + desiredID + '" was not found!! Opening up level selection view...'
intl.str(
'level-no-id',
{ id: desiredID }
)
);
Main.getEventBaton().trigger('commandSubmitted', 'levels');
@ -203,7 +207,7 @@ var Sandbox = Backbone.View.extend({
exitLevel: function(command, deferred) {
command.addWarning(
"You aren't in a level! You are in a sandbox, start a level with `level [id]`"
intl.str('level-cant-exit')
);
command.set('status', 'error');
deferred.resolve();
@ -220,7 +224,7 @@ var Sandbox = Backbone.View.extend({
resetSolved: function(command, deferred) {
Main.getLevelArbiter().resetSolvedMap();
command.addWarning(
"Solved map was reset, you are starting from a clean slate!"
intl.str('solved-map-reset')
);
command.finishWith(deferred);
},
@ -267,7 +271,7 @@ var Sandbox = Backbone.View.extend({
importTree: function(command, deferred) {
var jsonGrabber = new BuilderViews.MarkdownPresenter({
previewText: "Paste a tree JSON blob below!",
previewText: intl.str('paste-json'),
fillerText: ' '
});
jsonGrabber.deferred.promise
@ -300,7 +304,7 @@ var Sandbox = Backbone.View.extend({
importLevel: function(command, deferred) {
var jsonGrabber = new BuilderViews.MarkdownPresenter({
previewText: 'Paste a level JSON blob in here!',
previewText: intl.str('paste-json'),
fillerText: ' '
});
@ -350,7 +354,7 @@ var Sandbox = Backbone.View.extend({
childViews: [{
type: 'MarkdownPresenter',
options: {
previewText: 'Share this tree with friends! They can load it with "import tree"',
previewText: intl.str('share-tree'),
fillerText: treeJSON,
noConfirmCancel: true
}
@ -371,7 +375,7 @@ var Sandbox = Backbone.View.extend({
},
mobileAlert: function(command, deferred) {
alert("Can't bring up the keyboard on mobile / tablet :( try visiting on desktop! :D");
alert(intl.str('mobile-alert'));
command.finishWith(deferred);
},

View file

@ -13,25 +13,31 @@ var CommandResult = Errors.CommandResult;
var instantCommands = [
[/^ls/, function() {
throw new CommandResult({
msg: "DontWorryAboutFilesInThisDemo.txt"
msg: intl.str('ls-command')
});
}],
[/^cd/, function() {
throw new CommandResult({
msg: "Directory Changed to '/directories/dont/matter/in/this/demo'"
msg: intl.str('cd-command')
});
}],
[/^(locale|locale reset)$/, function(bits) {
constants.GLOBAL.locale = intl.getDefaultLocale();
throw new CommandResult({
msg: 'Locale reset to default, which is ' + intl.getDefaultLocale()
msg: intl.str(
'locale-reset-command',
{ locale: intl.getDefaultLocale() }
)
});
}],
[/^locale (\w+)$/, function(bits) {
constants.GLOBAL.locale = bits[1];
throw new CommandResult({
msg: "Locale set to " + bits[1]
msg: intl.str(
'locale-command',
{ locale: bits[1] }
)
});
}],
[/^refresh$/, function() {
@ -39,7 +45,7 @@ var instantCommands = [
events.trigger('refreshTree');
throw new CommandResult({
msg: "Refreshing tree..."
msg: intl.str('refresh-tree-command')
});
}],
[/^rollup (\d+)$/, function(bits) {