diff --git a/conf/locale/babel_underscore.cfg b/conf/locale/babel_underscore.cfg index a726b22e3a..7df8b38a16 100644 --- a/conf/locale/babel_underscore.cfg +++ b/conf/locale/babel_underscore.cfg @@ -3,6 +3,8 @@ input_encoding = utf-8 [underscore: common/templates/**.underscore] input_encoding = utf-8 +[underscore: lms/templates/**.underscore] +input_encoding = utf-8 [extractors] underscore = django_babel_underscore:extract diff --git a/docs/en_us/developers/source/i18n.rst b/docs/en_us/developers/source/i18n.rst index 3255e4a19e..7a6e75bab9 100644 --- a/docs/en_us/developers/source/i18n.rst +++ b/docs/en_us/developers/source/i18n.rst @@ -50,7 +50,7 @@ See the detailed Style Guidelines at the end for details. Editing source files ******************** -While editing source files (including Python, Javascript, or HTML template +While editing source files (including Python, JavaScript, or HTML template files), use the appropriate conventions. There are a few things to know how to do: @@ -70,13 +70,14 @@ The code samples below show how to do each of these things for: * `Python source code`_ * `Django template files`_ * `Mako template files`_ -* `Javascript files`_ +* `JavaScript files`_ * `Coffeescript files`_ +* `Underscore template files`_ * `Other kinds of code`_ Note that you have to take into account not just the programming language involved, -but the type of file: Javascript embedded in an HTML Mako template is treated differently -than Javascript in a pure .js file. +but the type of file: JavaScript embedded in an HTML Mako template is treated differently +than JavaScript in a pure .js file. Python source code ================== @@ -139,36 +140,36 @@ functions first. Here's a Mako template example:: ## Translators: message to the translator ${_("Welcome!")} -Javascript files +JavaScript files ================ .. highlight:: javascript -In order to internationalize Javascript, first the html template (base.html) -must load a special Javascript library (and Django must be configured to serve +In order to internationalize JavaScript, first the HTML template (base.html) +must load a special JavaScript library (and Django must be configured to serve it):: -Then, in Javascript files (`*.js`):: +Then, in JavaScript files (`*.js`):: // Translators: this will help the translator. var message = gettext('Welcome!'); -Note that Javascript embedded in HTML in a Mako template file is handled -differently. There, you use the Mako syntax even within the Javascript. +Note that JavaScript embedded in HTML in a Mako template file is handled +differently. There, you use the Mako syntax even within the JavaScript. Coffeescript files ================== .. highlight:: coffeescript -Coffeescript files are compiled to Javascript files, so it works mostly like -Javascript:: +Coffeescript files are compiled to JavaScript files, so it works mostly like +JavaScript:: `// Translators: this will help the translator.` message = gettext('Hey there!') - # Interpolation has to be done in Javascript, not Coffeescript: + # Interpolation has to be done in JavaScript, not Coffeescript: message = gettext("Error getting student progress url for '<%= student_id %>'.") full_message = _.template(message, {student_id: unique_student_identifier}) @@ -179,7 +180,7 @@ native Coffeescript features that break the extraction from the .js files: concatenation in the .js file, so string extraction won't work. 2. You cannot use Coffeescript comments for translator comments, since they are - not passed through to the Javascript file. + not passed through to the JavaScript file. :: @@ -198,6 +199,36 @@ native Coffeescript features that break the extraction from the .js files: .. highlight:: python +Underscore template files +========================= + +.. highlight:: underscore + +Underscore template files are used in conjunction with JavaScript, and so the +same techniques are used for localization. Ensure that the i18n JavaScript +library has already been loaded, and then use the regular i18n functions +such as ``gettext`` and ``interpolate`` from your template. + +For example:: + +