From ba4510d77546069c9f2a07a0be7e66fb9b745e22 Mon Sep 17 00:00:00 2001 From: Jonathan Diehl Date: Fri, 20 Jul 2012 09:54:24 +0200 Subject: [PATCH 1/8] added German localization and language switching --- src/command/Commands.js | 1 + src/command/Menus.js | 2 + src/debug/DebugCommandHandlers.js | 87 ++++++++++++++- src/strings.js | 161 +++++----------------------- src/strings/de-DE.js | 168 +++++++++++++++++++++++++++++ src/strings/en-US.js | 169 ++++++++++++++++++++++++++++++ 6 files changed, 454 insertions(+), 134 deletions(-) create mode 100644 src/strings/de-DE.js create mode 100644 src/strings/en-US.js diff --git a/src/command/Commands.js b/src/command/Commands.js index 57c907ea2d2..64c4cd4af8c 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -85,6 +85,7 @@ define(function (require, exports, module) { exports.DEBUG_RUN_UNIT_TESTS = "debug.runUnitTests"; exports.DEBUG_SHOW_PERF_DATA = "debug.showPerfData"; exports.DEBUG_NEW_BRACKETS_WINDOW = "debug.newBracketsWindow"; + exports.DEBUG_SWITCH_LANGUAGE = "debug.switchLanguage"; // Command that does nothing. Can be used for place holder menuItems diff --git a/src/command/Menus.js b/src/command/Menus.js index 6b5b3371937..fea536ec3ea 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -829,6 +829,8 @@ define(function (require, exports, module) { {key: "Cmd-R", platform: "mac"}]); menu.addMenuItem(Commands.DEBUG_NEW_BRACKETS_WINDOW); menu.addMenuDivider(); + menu.addMenuItem(Commands.DEBUG_SWITCH_LANGUAGE); + menu.addMenuDivider(); menu.addMenuItem(Commands.DEBUG_RUN_UNIT_TESTS); menu.addMenuItem(Commands.DEBUG_SHOW_PERF_DATA); diff --git a/src/debug/DebugCommandHandlers.js b/src/debug/DebugCommandHandlers.js index 15c84b88356..8b68bd514ce 100644 --- a/src/debug/DebugCommandHandlers.js +++ b/src/debug/DebugCommandHandlers.js @@ -33,7 +33,9 @@ define(function (require, exports, module) { Editor = require("editor/Editor").Editor, Strings = require("strings"), PerfUtils = require("utils/PerfUtils"), - NativeApp = require("utils/NativeApp"); + NativeApp = require("utils/NativeApp"), + NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem, + FileUtils = require("file/FileUtils"); function handleShowDeveloperTools(commandData) { brackets.app.showDeveloperTools(); @@ -130,6 +132,87 @@ define(function (require, exports, module) { function _handleNewBracketsWindow() { window.open(window.location.href); } + + function _handleSwitchLanguage() { + var stringsPath = FileUtils.getNativeBracketsDirectoryPath() + "/strings"; + NativeFileSystem.requestNativeFileSystem(stringsPath, function (dirEntry) { + dirEntry.createReader().readEntries(function (entries) { + + var $activeLanguage; + var $submit; + function setLanguage(event) { + if ($activeLanguage) { + $activeLanguage.css("font-weight", "normal"); + } + $activeLanguage = $(event.currentTarget); + $activeLanguage.css("font-weight", "bold"); + $submit.attr("disabled", false); + } + + var $modal = $("