Translations

From SubjectsPlus

Jump to: navigation, search

Version 0.9 allows for languages other than English in the Admin.

French translation now complete, June 2010! Thanks, Benoit Hamel!

How the translations work

Each bit of text is run through the tr() function, so in the code of an admin page, you might have something like the following bit of PHP:

print tr("vHi", "Hi");

If your language is set to English ($language = "en" in the config.php file), it will just print out the text in the second set of quotes. If you have set the language to, say, "fr" for French, the translation function will look for a file beginning with those two characters in the folder assets/lang/ -- in this case, fr.php.

fr.php has a set of variables referring to the translated text, so the correct text will be displayed. I.e., fr.php file would have a line

$vHi = "Salut"; // Hi

with the French translation in place, and the comment showing the original English text for reference.

If the language is set to French, but the term has not yet been translated, the name of the variable will appear instead. So, if the above salutation had not been translated, the page might read, "vHi, Andrew." You would know then to search fr.php for vHi and translate it.

There are additional things that need to be translated: forms-[language].php to handle form creation, and popup_help.php, which needs to be pointing to the desired language. The sample data in tables.sql will also need to be translated.

Making a new translation

To create a new translation, say, Spanish, you would:

  • Find the language.php file (which is filled with the variables, all of them empty)
  • Copy this to a new file which you would call by the new translation, i.e., es.php
  • Lovingly translate everything
  • Copy forms-en.php to a new file called forms-es.php
  • Lovingly translate the appropriate stuff
  • Do the same for popup_help.php (no dash-language after, since this is accessed through FCKEditor, and I can't (as of now) pass in variables from the config.php file)
  • Change config.php so that $language = "es";
  • Send your translation files back to the group so they can be added to the distribution!

To-Do

  • Um, complete at least one translation.
  • Allow individual users, rather than the entire installation, to choose a language. This won't be hard, but there needs to be some interest expressed.
  • Test the translation -- not sure about unicode stuff rendering properly; French diacritics came through okay on one server, not so well on another. (HTML entities fine, of course)
  • Figure out how to handle the public-facing pages. Run things through tr(), or just leave it to end users to translate the text in the page proper (since they will probably be mucking with the public-facing pages anyway).
  • Is using .pot files a more viable long term strategy? Is there sufficient interest in translations?
Personal tools