06.05.2013 Views

Drupal 6 JavaScript and jQuery - Ebook-Cours.com

Drupal 6 JavaScript and jQuery - Ebook-Cours.com

Drupal 6 JavaScript and jQuery - Ebook-Cours.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lost in Translations<br />

What if a term should remain untranslated?<br />

Some of the terms that the extractor finds may be terms you don't want to<br />

translate. To leave these terms untranslated, just set the msgstr to be an<br />

empty string: msgstr "".<br />

To make the translation file available to <strong>Drupal</strong>'s translation system, you should<br />

simply put the translation file in the translations/ directory of your theme (or<br />

module). For us, the file is placed in sites/all/themes/frobnitz/translations/.<br />

From there, <strong>Drupal</strong> takes over <strong>and</strong> we're done.<br />

While developing a translation, you may have to manually reload your<br />

translation in order to coerce <strong>Drupal</strong> into re-parsing the translation files.<br />

See the next section for details.<br />

Running the code with the Spanish translation will show text that looks like this:<br />

Hoy es Jueves. Quedan 2 dias til Sábado.<br />

How is this working? <strong>Drupal</strong> has taken our translation file <strong>and</strong> built a new <strong>JavaScript</strong><br />

file (located in sites/default/files/languages/). When the page loads <strong>and</strong><br />

Spanish is the selected language, <strong>Drupal</strong> adds a link to that extra <strong>JavaScript</strong> file:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

The highlighted section shows the inclusion of the translation <strong>JavaScript</strong> that <strong>Drupal</strong><br />

created for us. The contents of that file look like this:<br />

<strong>Drupal</strong>.locale = {<br />

'pluralFormula': function($n) { return Number(($n!=1)); },<br />

'strings': {<br />

[ 152 ]<br />

This material is copyright <strong>and</strong> is licensed for the sole use by Richard Ostheimer on 18th June 2009<br />

2205 hilda ave., , missoula, , 59801

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!