How to translate an Exposure gallery to your own language

Posted: September 29, 2010 in Exposure how-to's
Tags: , , ,

In version 0.4 of Exposure I introduced support for localization. This means that the texts used in Exposure can be translated to any language. In the latest download package you will find a new folder called “localization” which contains two JavaScript files, one for each additional language (currently German and Swedish). To use one of these languages instead of the default (which is English), simply include one of these language files in your HTML code:

<script src="res/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../jquery.exposure.js?v=0.4" type="text/javascript"></script>
<script src="../localization/texts_de.js" type="text/javascript"></script>

This example is copied from the first Exposure demo. By simply adding the third line here the result will be a gallery that’s translated to German:

German example

Exposure speaking German.

Adding your own translation is also dead easy. Simply copy one of the localization JavaScript files, open it up, and change the text strings to something suitable in your own language. Save your copy, and include it in the same way that we did in the example above.

Here’s what a plain English translation would look like:

/**
* Exposure plugin texts translated to English.
*/
jQuery.extend(jQuery.exposure.texts, {
first : "First",
previous : "Prev",
next : "Next",
last : "Last"
});

…and here’s a version of the same text translated to Morse code.

/**
* Exposure plugin texts translated to Morse code.
*/
jQuery.extend(jQuery.exposure.texts, {
first : "..-. .. .-. ... -",
previous : ".--. .-. . ...-",
next : "-. . -..- -",
last : ".-.. .- ... -"
});

If you want to contribute to the Exposure project by submitting a translation for your own language send me an e-mail to kris@blogocracy.org.

Advertisements

Comments are closed.