From da48df848466e53efdb4b86d40f027f2a1be43bb Mon Sep 17 00:00:00 2001 From: Ty Voliter Date: Mon, 6 Aug 2012 13:38:30 -0700 Subject: [PATCH 01/16] localize --- src/index.html | 76 +++++++++++++++++++++++++++++++++--------------- src/strings.json | 22 ++++++++++++++ 2 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 src/strings.json diff --git a/src/index.html b/src/index.html index d7c6024c602..f21957b7263 100644 --- a/src/index.html +++ b/src/index.html @@ -39,6 +39,7 @@ + @@ -51,9 +52,6 @@ - - - @@ -91,7 +89,7 @@
- Experimental Build + {{ExperimentalBuild}} @@ -114,13 +112,13 @@
-
JSLint errors
+
{{JSLintErrors}}
-
Search Results
+
{{SearchResults}}
×
@@ -139,21 +137,21 @@

Error

Message goes here

@@ -216,5 +214,35 @@

Brackets

    + + + + + diff --git a/src/strings.json b/src/strings.json new file mode 100644 index 00000000000..8224bc2ba7d --- /dev/null +++ b/src/strings.json @@ -0,0 +1,22 @@ +{ + "ExperimentalBuild": "!!Experimental Build", + "JSLintErrors": "!!JSLint Errors", + "SearchResults": "!!Search Results", + "OK": "!!OK", + "DontSave": "!!Don't Save", + "Save": "!!Save", + "Cancel": "!!Cancel", + "ReloadFromDisk": "!!Reload from Disk", + "KeepChangesInEditor": "!!Keep Changes in Editor", + "CloseDontSave": "!!Close (Don't Save)", + "KeepChangesInEditor": "!!Keep Changes in Editor", + "RelaunchChrome": "!!Relaunch Chrome", + "About": "!!About", + "Brackets": "!!Brackets", + "Close": "!!Close", + "AboutTextLine1": "sprint 12 experimental build ", + "AboutTextLine2": "Copyright 2012 Adobe Systems Incorporated and its licensors. All rights reserved.", + "AboutTextLine3": "Notices, terms and conditions pertaining to third party software are located at ", + "AboutTextLine4": " and incorporated by reference herein.", + "AboutTextLine5": "Documentation and source at " +} \ No newline at end of file From 5f2c46fd065642de40b9c79b72f526a4b1407d98 Mon Sep 17 00:00:00 2001 From: Ty Voliter Date: Wed, 8 Aug 2012 21:58:36 -0700 Subject: [PATCH 02/16] - delete strings.json and move content to strings.js. Now there is only one loc file! - added file htmlContentLoad.js that is a require module that dynamically renders html templates and localized strings in the body of teh page - break apart index.html into main-view.html, modal-windows.html, and side-bar.html --- src/brackets.js | 2 + src/htmlContent/htmlContentLoad.js | 64 ++++++++++ src/htmlContent/main-view.html | 61 ++++++++++ src/htmlContent/modal-windows.html | 81 +++++++++++++ src/htmlContent/side-bar.html | 21 ++++ src/index.html | 188 +---------------------------- src/strings.js | 22 ++++ src/strings.json | 22 ---- 8 files changed, 252 insertions(+), 209 deletions(-) create mode 100644 src/htmlContent/htmlContentLoad.js create mode 100644 src/htmlContent/main-view.html create mode 100644 src/htmlContent/modal-windows.html create mode 100644 src/htmlContent/side-bar.html delete mode 100644 src/strings.json diff --git a/src/brackets.js b/src/brackets.js index 547c26dde66..628fc798289 100644 --- a/src/brackets.js +++ b/src/brackets.js @@ -50,6 +50,8 @@ define(function (require, exports, module) { require("thirdparty/path-utils/path-utils.min"); require("thirdparty/smart-auto-complete/jquery.smart_autocomplete"); + require("htmlContent/htmlContentLoad"); + // Load LiveDeveopment require("LiveDevelopment/main"); diff --git a/src/htmlContent/htmlContentLoad.js b/src/htmlContent/htmlContentLoad.js new file mode 100644 index 00000000000..70840193dcb --- /dev/null +++ b/src/htmlContent/htmlContentLoad.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global require, define, brackets: true, $, PathUtils, Mustache, window, navigator */ + +require.config({ + paths: { + "text" : "thirdparty/text" + } +}); + +/** + * brackets is the root of the Brackets codebase. This file pulls in all other modules as + * dependencies (or dependencies thereof), initializes the UI, and binds global menus & keyboard + * shortcuts to their Commands. + * + * TODO: (issue #264) break out the definition of brackets into a separate module from the application controller logic + * + * Unlike other modules, this one can be accessed without an explicit require() because it exposes + * a global object, window.brackets. + */ +define(function (require, exports, module) { + "use strict"; + + // Load dependent non-module scripts + var Strings = require("strings"), + rootView = require("text!htmlContent/main-view.html"); + + // Load each html template into an object back. Key should match filename with the "dot" + // repaced with a hyphen. Example: side-bar.html > side-barhtml + var templates = { + "modal-windows-html": require("text!htmlContent/modal-windows.html"), + "side-bar-html": require("text!htmlContent/side-bar.html") + }; + + // Combine template and string dictionaries + var mustacheDict = $.extend({}, Strings, templates); + $('body').html(Mustache.render(rootView, mustacheDict)); + + + +}); diff --git a/src/htmlContent/main-view.html b/src/htmlContent/main-view.html new file mode 100644 index 00000000000..4086fb00674 --- /dev/null +++ b/src/htmlContent/main-view.html @@ -0,0 +1,61 @@ + +
    + + {{&side-bar-html}} + + +
    + +
    + + + + +
    + {{ExperimentalBuild}} + + + + + ★ + +
    + + +
    +   +
    +
    + +
    +
    +
    [  ]
    +
    +
    + +
    +
    +
    {{JSLintErrors}}
    +
    +
    +
    +
    +
    +
    {{SearchResults}}
    +
    + × +
    +
    +
    +
    +
    + + {{&modal-windows-html}} + +
    +
      +
      +
      +
        +
        \ No newline at end of file diff --git a/src/htmlContent/modal-windows.html b/src/htmlContent/modal-windows.html new file mode 100644 index 00000000000..b3096a702e7 --- /dev/null +++ b/src/htmlContent/modal-windows.html @@ -0,0 +1,81 @@ + + + + + + + \ No newline at end of file diff --git a/src/htmlContent/side-bar.html b/src/htmlContent/side-bar.html new file mode 100644 index 00000000000..00e775f9b25 --- /dev/null +++ b/src/htmlContent/side-bar.html @@ -0,0 +1,21 @@ + + \ No newline at end of file diff --git a/src/index.html b/src/index.html index f21957b7263..9cea44dc3ee 100644 --- a/src/index.html +++ b/src/index.html @@ -55,193 +55,7 @@ - -
        - - - - -
        - -
        - - - - -
        - {{ExperimentalBuild}} - - - - - ★ - -
        - - -
        -   -
        -
        - -
        -
        -
        [  ]
        -
        -
        - -
        -
        -
        {{JSLintErrors}}
        -
        -
        -
        -
        -
        -
        {{SearchResults}}
        -
        - × -
        -
        -
        -
        -
        - - - - - - - - -
        -
          -
          -
          -
            -
            - - - + diff --git a/src/strings.js b/src/strings.js index 05201ae16e8..a7caa85b9e1 100644 --- a/src/strings.js +++ b/src/strings.js @@ -162,4 +162,26 @@ define(function (require, exports, module) { // Special commands invoked by the native shell exports.CMD_CLOSE_WINDOW = "Close Window"; + + + exports.ExperimentalBuild = "!!Experimental Build"; + exports.JSLintErrors = "!!JSLint Errors"; + exports.SearchResults = "!!Search Results"; + exports.OK = "!!OK"; + exports.DontSave = "!!Don't Save"; + exports.Save = "!!Save"; + exports.Cancel = "!!Cancel"; + exports.ReloadFromDisk = "!!Reload from Disk"; + exports.KeepChangesInEditor = "!!Keep Changes in Editor"; + exports.CloseDontSave = "!!Close (Don't Save)"; + exports.KeepChangesInEditor = "!!Keep Changes in Editor"; + exports.RelaunchChrome = "!!Relaunch Chrome"; + exports.About = "!!About"; + exports.Brackets = "!!Brackets"; + exports.Close = "!!Close"; + exports.AboutTextLine1 = "sprint 12 experimental build "; + exports.AboutTextLine2 = "Copyright 2012 Adobe Systems Incorporated and its licensors. All rights reserved."; + exports.AboutTextLine3 = "Notices; terms and conditions pertaining to third party software are located at "; + exports.AboutTextLine4 = " and incorporated by reference herein."; + exports.AboutTextLine5 = "Documentation and source at "; }); diff --git a/src/strings.json b/src/strings.json deleted file mode 100644 index 8224bc2ba7d..00000000000 --- a/src/strings.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "ExperimentalBuild": "!!Experimental Build", - "JSLintErrors": "!!JSLint Errors", - "SearchResults": "!!Search Results", - "OK": "!!OK", - "DontSave": "!!Don't Save", - "Save": "!!Save", - "Cancel": "!!Cancel", - "ReloadFromDisk": "!!Reload from Disk", - "KeepChangesInEditor": "!!Keep Changes in Editor", - "CloseDontSave": "!!Close (Don't Save)", - "KeepChangesInEditor": "!!Keep Changes in Editor", - "RelaunchChrome": "!!Relaunch Chrome", - "About": "!!About", - "Brackets": "!!Brackets", - "Close": "!!Close", - "AboutTextLine1": "sprint 12 experimental build ", - "AboutTextLine2": "Copyright 2012 Adobe Systems Incorporated and its licensors. All rights reserved.", - "AboutTextLine3": "Notices, terms and conditions pertaining to third party software are located at ", - "AboutTextLine4": " and incorporated by reference herein.", - "AboutTextLine5": "Documentation and source at " -} \ No newline at end of file From e31995637bd6754ab9bc65225f72d5d5c2c568ef Mon Sep 17 00:00:00 2001 From: Ty Voliter Date: Thu, 9 Aug 2012 16:42:05 -0700 Subject: [PATCH 03/16] Remove decomp of index.html into separate template files. Integrate localization pull request https://github.com/adobe/brackets/pull/1285/files from jdiehl that uses requires i18n.js plugin --- src/brackets.js | 4 +- src/command/Commands.js | 1 + src/command/Menus.js | 2 + src/debug/DebugCommandHandlers.js | 92 ++++++++++++- src/htmlContent/htmlContentLoad.js | 24 +--- src/htmlContent/main-view.html | 114 ++++++++++++++-- src/htmlContent/modal-windows.html | 81 ------------ src/htmlContent/side-bar.html | 21 --- src/nls/de-DE/strings.js | 200 +++++++++++++++++++++++++++++ src/nls/strings.js | 198 ++++++++++++++++++++++++++++ src/project/SidebarView.js | 16 +-- src/strings.js | 163 +---------------------- src/thirdparty/i18n.js | 161 +++++++++++++++++++++++ 13 files changed, 776 insertions(+), 301 deletions(-) delete mode 100644 src/htmlContent/modal-windows.html delete mode 100644 src/htmlContent/side-bar.html create mode 100644 src/nls/de-DE/strings.js create mode 100644 src/nls/strings.js create mode 100644 src/thirdparty/i18n.js diff --git a/src/brackets.js b/src/brackets.js index 628fc798289..c8310e2fd71 100644 --- a/src/brackets.js +++ b/src/brackets.js @@ -28,7 +28,9 @@ require.config({ paths: { "text" : "thirdparty/text" - } + }, + // store the locale in localStorage until CEF sets the correct navigator.language + locale: window.localStorage.getItem("locale") }); /** diff --git a/src/command/Commands.js b/src/command/Commands.js index 35c19406d5b..abee1c5b570 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -88,6 +88,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 7bb03d3a41c..2b46e99c1d6 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -906,6 +906,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 6cdcbf61c8a..824ae9d96ff 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,93 @@ define(function (require, exports, module) { function _handleNewBracketsWindow() { window.open(window.location.href); } + + function _handleSwitchLanguage() { + var stringsPath = FileUtils.getNativeBracketsDirectoryPath() + "/nls"; + 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 = $("