Skip to content

Localizing Bramble

Gideon Thomas edited this page Mar 14, 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/editor.properties file.

Important Note: These files should not be edited directly. The true source for these strings is in the Thimble repository. Once string changes have been committed to the Thimble repository, Brackets automatically "syncs" the changes to its own repository. For local development and testing, you can make the changes to the strings in the Brackets repository with the aim to not commit them and instead commit them in the Thimble repository.

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 and 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 for Thimble and Brackets.
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 Brackets - locales/en-US/editor.properties and Thimble - 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 editor.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

For an architectural diagram that might aid in explanation, look at the Thimble wiki

Every time a new string is added to the locales/en-US/editor.properties file (in Thimble) and is committed, it will show up as an "unlocalized string" on Pontoon for each locale. There, contributors will localize the string and, once accepted, they will be committed on Thimble. Consequently, the build step in Thimble will trigger a "pull my strings" build on Brackets which will "pull down" the new changes that were made for that locale on Thimble and automatically update its own repository with the new strings. This in turn will trigger a second "normal" build which will deploy Brackets as it should. This is relevant since it explains why there might be a slight delay in seeing your changes on https://bramble.mofostaging.net

Clone this wiki locally