diff --git a/main.js b/main.js index 3621009..ce2dcbe 100644 --- a/main.js +++ b/main.js @@ -14,6 +14,8 @@ define(function (require, exports, module) { Menus = brackets.getModule("command/Menus"), PanelManager = brackets.getModule("view/PanelManager"); + var Strings = require("strings"); + var $panel = $(), $panelError = $(), gists = null; @@ -80,12 +82,10 @@ define(function (require, exports, module) { $panel .on("click", ".close", function() { CommandManager.execute(TOGGLE_PANEL); }) .on("click", ".list-group-item", function(event) { - console.log(gists); gists.forEach( function(gist) { if (gist.id == $(event.target).data("id")) { renderGist(gist); - console.log(gist); return; } }); @@ -94,7 +94,7 @@ define(function (require, exports, module) { }).error( function() { - $panelError = $(Mustache.render(panelError)); + $panelError = $(Mustache.render(panelError, Strings)); PanelManager.createBottomPanel("fezvrasta.gist-manager.panel", $panelError, 200); }); @@ -107,7 +107,7 @@ define(function (require, exports, module) { var menu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU); menu.addMenuItem(TOGGLE_PANEL, null, Menus.AFTER); - $panel = $(Mustache.render(panel)); + $panel = $(Mustache.render(panel, Strings)); PanelManager.createBottomPanel("fezvrasta.gist-manager.panel", $panel, 200); $panel.on("click", "#load-gists", loadContent); diff --git a/nls/root/strings.js b/nls/root/strings.js new file mode 100644 index 0000000..38eef1c --- /dev/null +++ b/nls/root/strings.js @@ -0,0 +1,6 @@ +/*jshint maxlen:false */ + +define({ + LOAD_GISTS: "Load gists", + LOADING_ERROR: "There was an error during the loading of Git Manager..." +}); diff --git a/nls/strings.js b/nls/strings.js new file mode 100644 index 0000000..c4ff6b2 --- /dev/null +++ b/nls/strings.js @@ -0,0 +1,15 @@ +/* + * @see: https://github.com/adobe/brackets/tree/master/src/extensions/samples/LocalizationExample + */ +define(function (require, exports, module) { + // Code that needs to display user strings should call require("strings") to load + // strings.js. This file will dynamically load strings.js for the specified by bracketes.locale. + // + // Translations for other locales should be placed in nls/>/strings.js + // Localization is provided via the i18n plugin. + // All other bundles for languages need to add a prefix to the exports below so i18n can find them. + module.exports = { + root: true + }; + +}); diff --git a/strings.js b/strings.js new file mode 100644 index 0000000..0dde9b2 --- /dev/null +++ b/strings.js @@ -0,0 +1,9 @@ +/** + * This file provides the interface to user visible strings in Brackets. Code that needs + * to display strings should should load this module by calling var Strings = require("strings"). + * The i18n plugin will dynamically load the strings for the right locale and populate + * the exports variable. See nls/root/strings.js for the master file of English strings. + */ +define(function (require, exports, module) { + module.exports = require("i18n!nls/strings"); +}); diff --git a/templates/panel.html b/templates/panel.html index 2528e42..35614ae 100644 --- a/templates/panel.html +++ b/templates/panel.html @@ -4,7 +4,7 @@ Gist Manager
- +
× diff --git a/templates/panelError.html b/templates/panelError.html index 54e861c..b247bbf 100644 --- a/templates/panelError.html +++ b/templates/panelError.html @@ -8,7 +8,7 @@
- Error... + {{LOADING_ERROR}}