Quantcast
Channel: Recent posts across whole site
Viewing all articles
Browse latest Browse all 49206

Fixing translation errors with @placeholders

$
0
0

Hi.

I have a problem with a few translations that have been done for our Drupal site.

A number of the translatable strings in our system contain @placeholders for inserting variables into a string at run-time. These are generally fine, but a few of them are breaking when the site is translated.

The problem appears to be due to punctuation on either the original or translated strings.

For example, an original English string may look like this:

@user's picture

But when it's translated (in this case to Danish), it comes out looking like this:

@users billede

This breaks Drupal's t() function because Danish doesn't use an aspostrophie for possessives, and so the placeholder @user is not in the translated string, so it simply shows on the site as "@users billede".

Similarly, the following string:

Template file for !langname translations

is translated into German with a hyphen:

Vorlagendatei für die !language-Übersetzung

In this case, the hyphen is picked up as part of the placeholder, which breaks the placeholder system. And in fact there is potential in languages like German, where words can often joined together without spaces, for it to be even harder to deal with.

Does Drupal have a mechanism for getting around this sort of problem?

(By the way, in case it makes any difference to the answer, we're on Drupal 6)


Viewing all articles
Browse latest Browse all 49206

Trending Articles