views:

32

answers:

1

We're building a multi-language Drupal stack and one of the concerns we have is that our payment processor is going to have to send back some information to us. We've been able to narrow this down so that the strings they're sending back look like

<country code>-<number of months>

so we can easily translate that into any number of languages, except English.

t('FR-12') is all well and good if we want to translate that into a french description, but because there's not an English language a similar string like t('EN-12') is not translatable.

Similarly for the generic string: #API_Connection_Error

This sort of generic string approach seemed really compelling to me at first but it seems to not work in Drupal. Do you have any suggestions about how to translate generic strings like this into both English and other languages?

Thank you, I've been looking through Google all morning.

+3  A: 

I see two ways to achieve this at the moment:

  1. You could just replace the default English language definition with a custom version. That way, you can 'translate' selected English strings just as with any other language. If you have configured locale module to fallback to the original string in case of absent translations, you can just add your special cases as translations to your custom English version, and everything else will use the original English version.

  2. Take a look at the String Overrides module - it allows you to define custom overrides for any string that gets passed through t(), with separate overrides per language, including the original English.

I'd use the second option in your case, except if the number of 'external' strings is very high. See the first if clause of the t() function for the mechanism used for the overrides (lookup in language specific Drupal variable arrays).

Note that the String Overrides module just adds admin UI pages to configure those Drupal variables in the Backend - you could add/adjust them yourself as well (e.g. from a custom module).

Henrik Opel
Thanks for the reply, this is exactly what I needed to know. I ended up going with String Overrides as you suggested if only because I'm confident that having a different English would confuse the snot out of the translators. I wish I could give you more than 25 points!
Chuck Vose