1

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'?

3
  • 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
    Commented Mar 27, 2014 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
    Commented Mar 27, 2014 at 11:12
  • I know, that's why I didn't post this as an answer.
    – Mołot
    Commented Mar 27, 2014 at 11:13

1 Answer 1

0

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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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