Skip to content

Commit

Permalink
Fix mozilla/thimble.mozilla.org#1361 - Localize "Move File" extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Gideon Thomas committed Feb 25, 2016
1 parent 6dc813c commit fc7617e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
11 changes: 11 additions & 0 deletions locales/en-US/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,14 @@ CMD_ENABLE_QUICK_VIEW=Quick View on Hover
# extensions/default/WebPlatformDocs

DOCS_MORE_LINK=Read more

# extensions/default/bramble-move-file

CMD_MOVE_FILE=Move To...
PROJECT_ROOT=Project Root
PICK_A_FOLDER_TO_MOVE_TO=Pick a folder
ERROR_MOVING_FILE_DIALOG_HEADER=Move Error
# {0} is the name of the file/folder being moved and {1} is the name of the folder it is being moved to
UNEXPECTED_ERROR_MOVING_FILE=An unexpected error occurred when attempting to move {0} to {1}
# {0} is the name of the file/folder being moved and {1} is the name of the folder it is being moved to
ERROR_MOVING_FILE_SAME_NAME=A file or folder with the name {0} already exists in {1}. Consider renaming either one to continue."
19 changes: 13 additions & 6 deletions src/extensions/default/bramble-move-file/MoveToDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ define(function (require, exports, module) {
var FileSystem = brackets.getModule("filesystem/FileSystem");
var BracketsFiler = brackets.getModule("filesystem/impls/filer/BracketsFiler");
var Path = BracketsFiler.Path;
var Strings = brackets.getModule("strings");
var StringUtils = brackets.getModule("utils/StringUtils");

var MoveUtils = require("MoveUtils");
var dialogTemplate = require("text!htmlContent/move-to-dialog.html");
Expand Down Expand Up @@ -74,14 +76,16 @@ define(function (require, exports, module) {

if(error.type === MoveUtils.NEEDS_RENAME) {
Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR,
"Move Error",
"A file or folder with the name " + from + " already exists in " + to + ". Consider renaming either one to continue.");
Strings.ERROR_MOVING_FILE_DIALOG_HEADER,
StringUtils.format(Strings.ERROR_MOVING_FILE_SAME_NAME, from, to)
);
return;
}

Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR,
"Move Error",
"An unexpected error occurred when attempting to move " + from + " to " + to);
Strings.ERROR_MOVING_FILE_DIALOG_HEADER,
StringUtils.format(Strings.ERROR_MOVING_FILE, from, to)
);

console.error("[Bramble] Failed to move `", source, "` to `", destination, "` with: ", error);
}
Expand Down Expand Up @@ -136,7 +140,7 @@ define(function (require, exports, module) {
var parentPath = projectRoot.replace(/\/?$/, "");
var directories = [{
path: parentPath,
name: "Project Root",
name: Strings.PROJECT_ROOT,
children: false,
indent: 0,
noIcon: true,
Expand Down Expand Up @@ -194,7 +198,10 @@ define(function (require, exports, module) {

var dialogContents = {
defaultPath: defaultPath,
source: context.fullPath
source: context.fullPath,
PICK_A_FOLDER_TO_MOVE_TO: Strings.PICK_A_FOLDER_TO_MOVE_TO,
OK: Strings.OK,
CANCEL: Strings.CANCEL
};
var subdirectoryContents = {
subdirectories: directoryTreeTemplate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="move-to-dialog modal">
<div class="modal-header">
<h1 class="dialog-title">Pick a folder</h1>
<h1 class="dialog-title">{{ PICK_A_FOLDER_TO_MOVE_TO }}</h1>
</div>

<div class="modal-body">
Expand All @@ -12,7 +12,7 @@ <h1 class="dialog-title">Pick a folder</h1>
</div>

<div class="modal-footer">
<button class="dialog-button btn primary" data-button-id="ok">OK</button>
<button class="dialog-button btn" data-button-id="cancel">Cancel</button>
<button class="dialog-button btn primary" data-button-id="ok">{{ OK }}</button>
<button class="dialog-button btn" data-button-id="cancel">{{ CANCEL }}</button>
</div>
</div>
3 changes: 2 additions & 1 deletion src/extensions/default/bramble-move-file/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ define(function (require, exports, module) {
var Commands = brackets.getModule("command/Commands");
var Menus = brackets.getModule("command/Menus");
var ExtensionUtils = brackets.getModule("utils/ExtensionUtils");
var Strings = brackets.getModule("strings");
var MoveToDialog = require("MoveToDialog");

var MOVE_FILE = "bramble-move-file.moveFile";

CommandManager.register("Move To...", MOVE_FILE, MoveToDialog.open);
CommandManager.register(Strings.CMD_MOVE_FILE, MOVE_FILE, MoveToDialog.open);
var menu = Menus.getContextMenu(Menus.ContextMenuIds.PROJECT_MENU);
menu.addMenuItem(MOVE_FILE, null, Menus.AFTER, Commands.FILE_RENAME);

Expand Down

0 comments on commit fc7617e

Please sign in to comment.