Hello, I was wondering if it is possible to translate a string in a specific language. Lets say I hate "Hello" (en), and "Allo" (fr), and whatever the current locale is, I want to force the printing of "Allo",

(I know this is not true, but I am looking for a drupal function that does that)
print t("Hello", "fr")

I use Localizer and Locale

Thanks !

Comments

weedoo’s picture

Ok I found it, you need localizer installed, then you can call this function...

function localizer_t($string, $args = 0, $_locale = '')

where $_locale is the locale to which you want $string to be translated, if it is found in the translation table.

Hope this is useful to someone

xano’s picture

Simply disabling the English locale will suffice :) All strings will be automatically and dynamically translated to French then.

weedoo’s picture

Site is french and english, both language are used, except for this spesific string I needed in only one language, on french and english version of the site !

xano’s picture

Then you could alter the French string using the locale module instead of hardcoding it. It's a bit easier and if in the future you might want to undo it you save yourself the trouble of removing the code again.