I have a problem. My multilingual site have 'Italian' as default language and I have a problem with the taxonomy name translation.

In views when I add taxonomy name field this is always displayed in Italian ad never translated so I think to sobstitute the name field to a php field like

<?php print t($row->name); ?>

but $row->name is italian and the t() function assume this string in english and translate it when the site is 'IT'

I tryed to use taxonomy context but drupal double the entry enter image description here

How can I have in my damn view a field with the right taxonomy name? Can I tell drupal 'translate from IT to EN when the site is English'?

  • Good luck with that. I gave up long time ago and now I write everything in English. Even if I never plan to display English version. Additional bonus - I don't need to change code of my modules when marketing decides to change texts. – Mołot Mar 27 '14 at 11:08
  • I can't resetup all the site language and trnslated string only for ONE block in the site T_T Why the context exist if they don't work? – Shyghar Mar 27 '14 at 11:12
  • I know, that's why I didn't post this as an answer. – Mołot Mar 27 '14 at 11:13

This is how I did it for an array of untranslated terms:

foreach ($terms as $term => $str) {
  $translation = db_query("SELECT t.translation FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = 'en' WHERE s.source = :source", array(':source' => $str))->fetchAll();
  $terms[$term] = $translation[1]->translation;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.