Taking (some of) the pain out of translating Drupal

Xlationist is a module that makes it easier to translate strings in Drupal
Xlationist is a module that makes it easier to translate strings in Drupal

Things that annoy us also have a tendency to make us think about how they can be improved. The translation form in Drupal has annoyed me countless times and gave me the idea for my new module – Xlationist.

As a Drupal site administrator whose native language isn't English you know the drill. You've built a site and everything looks splendid except for one tiny detail – the language of the site. You've installed the latest language pack from drupal.org but you find English strings here and there through your pages. But hunting them down and nailing them in your native idioma, langue or språk isn't all you need to do. You have to do it using the translation interface in Drupal which leaves a lot to be desired.

So you head over to the Translate Interface page, click Search, type in the right keywords and you're awarded with the matching strings. Click Edit and you'll see something like this:

The Translate Interface form in Drupal 6

Translating a string like this usually involves figuring out what the best translation is, type it and copy the parts of the original string you need.

Translatable strings in Drupal do not contain literal just text but placeholders as well. Those are the words with @, ! and % in front of them. They're replaced by the corresponding variables when the string is displayed to the user. Placeholders have to be kept intact in the translated string, a task that requires manually copying them. A boring, error-prone and slow task. It can also be difficult to see mistakes and the only way to discover them is to view the translated string in context.

Introducing Xlationist

Pronounced "translationist", this module adds a few lines of CSS and JavaScript to do its magic and here's the result:

Hey, those placeholders are clickable! And they're green too! Groovy!

Inserting placeholders into the translation textarea is a matter of putting the caret where you need it and clicking the placeholder. If you want to start translating using the entire original text, just click the big green button. Easy as pie.

The result is fewer typing errors, less copy-and-paste and the ability to focus more on translating and writing.

The current version of the module is considered alpha. I wrote it in less than three hours in an attempt to put some of my ideas in code. As a result, the module hasn't been tested with every browser or with many languages. I know of at least one character encoding bug that needs to be fixed. The code can be improved upon and patches are more than welcome, as always.

Also, if you translate Drupal using Translate Interface, be sure to contribute your translations using the excellent localization server by Gábor Hojtsy. By contributing them you help make Drupal accessible to more people and make it possible for modules to come bundled with translations direct off the localization server. It's a feature that isn't there yet but hopefully soon!

I have more ideas for Xlationist and how it can be improved as well as for other parts of Drupal's administration pages in need of usability goodness. My ultimate goal is to deprecate the module by getting this into core as it's where it should be. I hope to be able to submit a patch for Drupal 8 as soon as Xlationist has learnt to walk and bugs have been ironed out.

http://drupal.org/project/xlationist

NB: Admittedly the word "translationist" doesn't exist in the dictionary. I just thought it would be cool to have a module with a name starting with an X. More importantly though, the name should not limit the purpose, and Xlationist may likely be extended in the future why the name Xlationist fits the bill.

Bilagor: 

Kommentarer

Nice! Too bad we’ll have to wait until D8 to be able to see this in core. May be worth a D7 patch anyway - usability improvement!

I asked Bojhan about the chances of getting this into D7 and he says it’s frozen what UI improvements are concerned. Looks like I’ll have to wait for D8 to get this in.

What about joining efforts? I think what would be coolest is if we could join forces and improvements of the localization server, the localization client and now xlationist. Your ideas around copying just the placeholder with a simple click can be of use in the l10n_server and client alike. We could also spread the live diffing behavior from the server to the client and to this form, which would make it even more powerful. Ie. if the string has a translation already, you could see the diff when you add a neąw translation.

I think there are lots of great things happening, and it would probably be better to join forces and spread these innovations as far and wide as possible so we have a more or less unified UI to work with for translations. What do you think?

I agree wholeheartedly! I’ll start by turning this into a patch for the l10n_server so we get it into the interface there as well. Another idea I had was to make it possible to turn Locale into a client for l10n to submit suggestions and retrieve existing translated strings on demand, similar to what you proposed above.

Skriv ny kommentar

  • Webbadresser och e-postadresser görs automatiskt till länkar.
  • Lägger till typografiska justeringar.
  • Tillåtna HTML-taggar: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Rader och stycken bryts automatiskt.
  • Du kan skriva kod med <code>...</code> (generiska) eller <?php ... ?> (markerade PHP) taggar
Innehållet i detta fält är privat och kommer inte att visas publikt.