Switch branches/tags
v34.10744 v34.10534 v0.36.0-10998 untagged-293a2ac7be89eb7a80b8 untagged-71c185fc4eecfb5086d0 test-45 sprint-41 sprint-40 sprint-39 sprint-38 sprint-37 sprint-36 sprint-35 sprint-34.1 sprint-34 sprint-33 sprint-32 sprint-31 sprint-31a sprint-30 sprint-29 sprint-28 sprint-27 sprint-26 sprint-25 sprint-24 sprint-23 sprint-22 sprint-21 sprint-20 sprint-19 sprint-18 sprint-17 sprint-16 sprint-15 sprint-14 sprint-13 sprint-12 sprint-11 sprint-10 sprint-9 sprint-8 sprint-7 sprint-7a sprint-6 sprint-5 sprint-4 sprint-3 sprint-2 sprint-1 splitview-pre-tree2 splitview-pre-tree release-39 release-1.13 release-1.13-prerelease-3 release-1.13-prerelease-2 release-1.13-prerelease-1 release-1.12 release-1.12-prerelease release-1.11 release-1.11-prerelease-2 release-1.11-prerelease-1 release-1.10 release-1.10-prerelease-4 release-1.10-prerelease-3 release-1.10-prerelease-2 release-1.10-prerelease-1 release-1.9 release-1.9-prerelease release-1.9-prerelease-2 release-1.8 release-1.8-prerelease1 release-1.8-prerelease release-1.7 release-1.7-prerelease1 release-1.6 release-1.6+eb4 release-1.6-prerelease1 release-1.5 release-1.5+eb4 release-1.4 release-1.4+eb4 release-1.4-prerelease1 release-1.3 release-1.3+eb4 release-1.3-prerelease1 release-1.2 release-1.2+eb4 release-1.2+eb4-Prerelease1Linux release-1.2-prerelease1 release-1.2-prerelease1-Linux release-1.1 release-1.1+eb4 release-1.1-rc1 release-1.1-prerelease1 release-1.0 release-1.0+eb4 release-1.0-rc1 release-1.0-beta1 release-0.44
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Localization in Brackets

Brackets has basic support for displaying user visible text in other languages. The document describes how localized text can be added to core Brackets code and Brackets Plugins

Javascript and HTML that displays user visible strings in Brackets should not use static English strings directly in code. Instead, strings should be stored in a the file brackets \src\nls\root\strings.js. Code that wishes to display strings should import the String module from src\string.js. This module dynamically loads a strings.js file in the nls folder for the current local. JavaScript can then directly reference properties of the String module to access strings, and HTML can use the String module in combination with Mustache.js templating to display localized strings. Brackets uses the i18n RequireJS plugin for to load localized strings. The plugin loads the strings.js file according to the user’s locale and also provides a fallback to English for missing translations.

Adding new localized strings to Brackets

Add new English strings to the file brackets\src\nls\root\strings.js. Translations in other languages should be added to the strings.js file in each of the locale folders inside the “nls” folder. For example, modify brackets\src\nls\fr\strings.js for French

Using Localized strings in Brackets modules

Strings JavaScript

  1. Load the Strings module in the file where the string is to be used Strings = require("strings");

  2. Reference a string by selecting a property from the String module. For example, Strings.NOT_FOUND_ERR yields the string “The file could not be found." for an English locale.

Strings HTML

Localizing HTML in Brackets requires use of the templating framework mustache.js since HTML cannot directly reference properties in strings.js. Strings for both JavaScript and HTML are stored \src\nls\root\strings.js, but in HTML they are referenced using the template syntax {{stringKeyName}}.

For example,

<h1 class="dialog-title">{{SAVE_CHANGES}}</h1>


<h1 class="dialog-title">Save Changes</h1>

Mustache recognizes this syntax and can substite the appropriate string. Mustache is run when Brackets launches during module load. Code in brackets.js loads the appropriate strings.js file using i18n, loads html content from a file as a text, runs Mustache on the text using strings.js for the data lookup, and then inserts the result into the DOM. Core brackets code that depends on the DOM should listen for the “htmlContentLoadComplete” before inspecting or manipulating the dome

Localization Guidelines

Multiple strings keys in strings.js should not be concatenated together since word order often varies between languages


Brackets does not support localizing keyboard shortcuts yet

Localization Support for Brackets Plugins

Localization in plugins works very similarly to how localization works for core Brackets module. The i18n RequireJS plugin is used to dynamically load a string.js file for the appropriate locale. JavaString can then reference strings via property name from the loaded string module and mustache can be used on on html fragments to insert localized text.

For an example of a simple localized plugin see: brackets\src\extensions\disabled\LocalizationExample

Move this plugin to the extensions\user\ folder to run the plugin. It will add a "My New Command" menu item to the end of the Edit menu. This command shows an alert with localized text and then a modal dialog with localized HTML content.

Below is the folder structure and comments on the role of each file

  • main.js – loads the Strings module for the plugin and uses mustache to localize html content

  • package.json - add the translation languages as in the example: "i18n": ["en", "fr" ]. Also, add any localized metadata for displayed metadata in the Extension Manager, as in the example: "fr": { "title": "localized title" }.

  • strings.js – uses i18n to load a strings.js file in the nls folder

  • htmlContent

    • htmlfragment.html – html template to be localized by mustache
  • nls

    • strings.js – configures i18n by specifying the root folder and listing the locales supported by the plugin
    • root
      • strings.js – contains the English strings
    • fr
      • strings.js – contains the French strings
    • etc. for each locale

Strings for plugins vs Brackets

Note that there is a distinction between loading strings for a plugin vs. strings in the Brackets core. To access strings local to your plugin use var strings = require("strings"). To load the core Brackets strings use var bracketsStrings = brackets.getModule("strings")