Skip to content

Localizing Bramble

Gideon Thomas edited this page Mar 3, 2016 · 6 revisions

Brackets (bramble) uses RequireJS' i18n plugin to show localized content. Since strings are translated on Pontoon, they need to be stored in the locales/en-US/messages.properties file.

Strings

Brackets core

We do not use most of the features and hence the strings that Brackets core provides. Hence, the strings that we do use have been extracted an put into the editor.properties file. Any changes to the strings that we may use from Brackets core must be made in the editor.properties file.
Note: Please follow the comment conventions used in the file and categorize the strings with the help of these comments.

Extensions

All strings that are localizable for an extension must be put into the editor.properties file located at locales/en-US/editor.properties.
Note: Please follow the comment conventions used in the file. To add new strings for an extension, add a comment with the path to the extension above the list of strings.

Usage

Code

To use a string in a source file, require in the strings file like so:

define(function(require) {
   var Strings = require("strings");
   // For extensions, use the following code instead
   // var Strings = brackets.getModule("strings");
   ...
});

which will give you access to an object containing key-value pairs (similar to what is in the editor.properties file) which can be used to access each string with their respective key. RequireJS will automatically use the correct locale's string as long as the correct key is used.

Running Localized Brackets

Development

For development, you must run npm run build before running npm start (this might change to make it easier). This will generate requirejs compatible strings from the messages.properties files. Anytime a new string is added, these steps must be repeated.

Production

If running using the built version of Brackets i.e. npm run production (and Thimble is configured to run in a production environment), there is no need to run the localize npm scripts since they are automatically run with the grunt steps. However, any changes made to the editor.properties file will require the npm run production step to be run again.

Pontoon

[PENDING]

Clone this wiki locally