Gallery3:Localization - Gallery Codex
Personal tools

Gallery3:Localization

From Gallery Codex

Localizing Gallery 3

Gallery 3 is internationalized. Instead of containing language specific text messages, it tracks text in a special way so that it can be extracted and translated into other languages. Users will see a version of the text that has been converted into their own language.

In order for the users to see a localized version of Gallery's text, somebody must first translate the text messages that Gallery is going to display. This process is called "localization".

Gallery 3 has a built-in user interface to add your translations. To translate in Gallery 3, do the following:

  1. Browse to Admin > Settings > Language and activate the language you want to translate to.
  2. If the target translation isn't the default language for your Gallery, go to your user settings and make the new language your account's preferred language.
  3. Now enable the translation mode at the very bottom of the page Admin > Settings > Language by clicking on Start translating
  4. At the bottom right, click on Translate to show the translation interface
  5. Now you can browse around in your Gallery, select a message in the lower left and enter the translation in the lower right.

To translate messages like "Start translating" and "Login", i.e. messages that are never shown when you are in the translation mode, click in the translation UI on Show all. Also, note that you first have to click on Update languages to index all messages of your Gallery before Show all really shows all messages.

Sharing Your Translations

Translating is a lot of work. Luckily you don't have to do it all yourself. If we all share our own translations, we all only have to do a fraction of the work. Please share your translations! To share (= upload) your translations, do the following:

  1. As a one time configuration step, Admin > Settings > Language and follow the instructions at the bottom of the page to get a translation API key. Once you have your translation API key, enter it in the box at the bottom of the page and click on Save settings.
  2. Once configured, all you have to do is click the Submit translations button on the same page to upload your translations to the translation server.

Notes

  • All your translations are stored in a single database table ("outgoing_translations") on your own Gallery server.
    • It's recommended that you create a backup of this table if you've spent a lot of time adding your own translations. Else all the work might be gone if something bad happens to the server or to the Gallery installation.
  • The translation server is a database to share translations with other Gallery users, and it's located at www.galleryproject.org.
  • There are multiple reasons why your translation submission to the translation server might not be accepted immediately
    • If there is an existing translation for the same message and the same language, and you submit a newer alternate translation, the newer translation wins. But if the existing translation received more votes, it will remain the default translation for this message.
    • If your translation contains HTML elements (e.g. <a>Click me</a>), then it is only immediately activated if the HTML is part of the small subset of valid HTML that is allowed in Gallery 3 translation messages.

Style Guide

  • Translations should have the same placeholders as the source message (e.g. %author)
  • Translations can only contain a specific subset of HTML (see below)
  • Translations must be well formed HTML (e.g. all HTML elements must be closed)
  • All HTML element attributes must use double-quotes as value delimiter. Single-quotes are not allowed as delimiter.

Allowed HTML

  • a (link anchor) element
    • allowed attributes: class, href.
    • Allowed values for href: a placeholder (e.g. %url) or "#"
    • And <a %attr>Click me</a> is allowed as well (using %attr as a placeholder for various element attributes, as defined by the source message)
  • b, br, i, em, strong (no attributes allowed)

Theme and module customization

    <? $locale = Gallery_I18n::instance()->locale(); 
      if ($locale == "en_US") { ?>
       US English content here.
    <? } if ($locale == "en_GB") { ?>
       GB English content here.
    <? } ?>

You might want to see some more details: Internationalization