I'm trying to figure out how do this:
I have a user generated content which in not being translated in different languages, I want to give users opportunity to categories this content with selection of terms that are translated in their language and also search content by selecting terms in their language.
So if a term in one language is assigned to a content by a user then all the translations of that term should also be automatically assigned to that content. One searching for that content can get it by specifying the term in any of the languages in which the term is translated.

Just translating the terms in multilingual category does not give the wanted behavior. The content is only recognized by the term that was assigned to it at creation and not by the term translations.

I would really appreciate any clue or suggestion.

CommentFileSizeAuthor
#10 add_node_terms_translations.zip2.96 KBDamjan Dvorsek

Comments

qingdao’s picture

hej damjan, I'm having the same problem ...

I havent found a good solution by now. What you can do is the following. Create a vocabulary just in english language and don't translate anything. Then before output the category on a page, you have to write a function which translate the category to the specific language. This is not a nice solution, because it's dirty hacking and performance will also suffer. Usually the t-function from drupal is used to translate contents. Unfortunatelly identifiers, like names of categories, are not passed to the t-function. So writing this function for translation is actually a duplication of the t-function, but i don't have any other idea how to solve this problem in a good way.

Did you find any solution ?

qingdao’s picture

i found a solution and it actually was pretty easy ;-)

- create a non language specific vocabulary
- go to Administer -> Multilingual System -> Translation
- there you can choose which vocabularies supposed to be translated

after this you can translate the terms of your vocabulary by using Administer -> Localization -> Manage Strings
and thats is.

Damjan Dvorsek’s picture

Thanks, that is great.
I have one question, do I have to specifie the languge for the terms

qingdao’s picture

no don't specify any language for the terms :-)

Damjan Dvorsek’s picture

I don't know why but I can't make this work. I made a vocabulary with no laguage specified, I entered terms with no language specified, I enable translation of vocabulary in Multilingual system, but when I try to translate them in Localization -> Manage Strings I can not finde the terms from the vocabulary.

Do you maybe have any idea what I'm doing wrong. I have also change the i18n modul to the lates version 5.x-2.2 and I have all the modules from this package checked, but with out succes .

Thanx for any help,
Damjan

qingdao’s picture

hmmm if the strings (terms) for translation are not found, its because they are not passed to the t-function, so always before you output an term use the t-function. For example if you list all nodes associated to one term, the name of the term will be the title. so replace in your page.tpl.php the "print $title;" with "print t($title);". Try this and after try to find the term with the Localization -> Manage Strings (sometimes it takes some minutes after your changes because of caching.)

lesliewu’s picture

I have followed qindao's steps and have translated my terms through Localization. However, the translated strings are not shown on the forum page. What am I doing wrong? Thanks.

qingdao’s picture

always before output a category or term, it need to be passed to the t-function, otherwise the i18n is not working. In the example above I only showed how it works for the page title.
You can do a little hack of the taxonomy module, which isnt the best approach but at least its working:

- open modules/taxonomy/taxonomy.modul
- change line 725 to: '#title' => t($vocabulary->name),
- and 739 to: $default_terms[$term->tid] = t($term);

after this your taxonomy and terms should be displayed in the choosen language

attention: its not a good way to hack core modules, because with the next update you can lose all your changes, the better approach is to write a own module and implement hook_form_alter to change the form

lesliewu’s picture

Thanks for your help. However, I have replaced the 2 lines of code but still I can't make it work. My terms (which are already translated) are still showing in English. Any thing else I can try?

Damjan Dvorsek’s picture

StatusFileSize
new2.96 KB

For me the translation trough localization didn't give consistent results, so I didn't have any choice but to bite into development of a custom module. Here is my first :-) module that adds to a node all the translations of chosen vocabulary terms upon node submission. You have to set the translations of the terms inside the vocaburay.
So far I have tested it with multi and single choice vocabularies. The free tag vocabularies, which are usualy not translated also don't bother the module. The changes (additions of new term translations) of vocabulary are not avtomaticaly synhronised with the nodes.

If you decide to use it and have any feedback on it pleas let me know.

doomed’s picture

I think my problem is similar, if not the same.

I posted about it here:

http://drupal.org/node/239648

pmichelazzo’s picture

So easy and so cool!

Running well.
Thank you so much

jose reyero’s picture

Status: Active » Closed (duplicate)