Hi,

I would like to translate taxonomy terms within my own PHP code snippets (embedded in custom blocks). Translations for the terms are provided by the "translation table"-module, i.e. I filled out the translation table for the corresponding taxonomy.

However, a call of
t($term->name)
where $term is a valid term object does not translate the term. It remains unchanged in the source language.

Should this work? Does it need additional steps to use the t-function on taxonomy terms?

Current version is Drupal 6.13 with all modules up to date.

Thanks,
Amin

Comments

amin.m-1’s picture

Finally, I have found a solution to get the translated name of a taxonomy term. The tt()-function instead of the t()-function does the job because taxonomy terms are treated as "user defined strings".

It has slightly more complicated arguments. A call looks like this:
$name=tt("taxonomy:term:$term->tid:name", $term->name);

In order to find out how to build the first argument ("taxonomy:term..."), it is useful to have a look at the search results shown under http://yourhostname/admin/build/translate/search (Menu: Site Building -> Translate interface -> Search). You have to concat the text group of column 1 with a colon (":") and the details shown in column 2.

Greetings,
Amin

mixman’s picture

Thanks, this was helpful for me.

czeky’s picture

maybe stupid question, I'm not fully understand.. is it translatable without any patching? can't find the strings..

arhak’s picture

needs i18ntaxonomy module which comes with http://drupal.org/project/i18n

vsalvans’s picture

Thanks! it was just waht I needed.

user defined strings are in po files like this:

#: term:321:name
msgid "apple"
msgstr "poma"

Actually you just need the term id and term name and build de string for the first argument of tt(). It's true you need i18n taxonomy module

MattMoody’s picture

Thanks