Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Added support for localization.
Browse files Browse the repository at this point in the history
  • Loading branch information
FezVrasta committed Jun 18, 2014
1 parent b4ecff7 commit 83b8418
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
8 changes: 4 additions & 4 deletions main.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
});
Expand All @@ -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);

});
Expand All @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions 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..."
});
15 changes: 15 additions & 0 deletions 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/<locale<optional country code>>/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
};

});
9 changes: 9 additions & 0 deletions 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");
});
2 changes: 1 addition & 1 deletion templates/panel.html
Expand Up @@ -4,7 +4,7 @@
<span class="title">Gist Manager</span>
<div class="btn-group">
<input type="text" id="github-username" placeholder="GitHub username...">
<button class="btn btn-default" id="load-gists">Load gists</button>
<button class="btn btn-default" id="load-gists">{{LOAD_GISTS}}</button>
</div>
<span class="pull-right">
<a href="#" class="close">&times;</a>
Expand Down
2 changes: 1 addition & 1 deletion templates/panelError.html
Expand Up @@ -8,7 +8,7 @@
</div>

<div class="gist-manager-content resizable-content">
Error...
{{LOADING_ERROR}}
</div>

</div>

0 comments on commit 83b8418

Please sign in to comment.