drupal 7 taxonomy term translation in user profile field i18n - drupal

Problem: in the user profile page taxonomy term United Kingdom is displaying only in default language but not translating.
I have vocabulary Countries that has "Localize" option.
I've translated all the terms. For example: United Kingdom = Vereinigtes Königreich = Royaume-Uni = Великобритания.
I've made a menu Countries - so in language versions menu items are displaying translated and ok!
But in the user profile page Field Country is displaying only in default language and not translating if I go to lang versions.
The labels are displaying translated so I have Country, Land, Pays, Страна - labels. But the term United Kingdom is displaying only in english.
I am using Internationalization i18n, Taxonomy translation, Field Translation, String translation, Multilingual select modules.
here I have two methods language selection /admin/config/regional/language/configure : url and by default.
/admin/config/regional/i18n/select here i have checked both Select nodes by language Select taxonomy terms by language
I've tried to use Entity Translation but it is very big and difficult and not that I need.
May be there is User translation module?
Please what should I do to translate terms in user profile fields drupal 7?

You can always pass your variable trough t() function in your template, where you are printing it out and it will become translatable. It's work-around, but it can save time and nerves.

Trying to use Profile2 and Profile2 Translation modules and using field Country in Main profile (Profile2) I've solved this problem.
But Profile2 is not useful for me cause it makes new page in user editing page and lot of users have already set up field Country I do not whant to work with database.
If I knew I was using Profile2 + Profile2 Translation first!
May be you give recommendations how to get it with Profile module?

Related

Drupal Multilingual translating views Argument

I am working on a multi lingual site using i18n module in Drupal 6 Version.
I have created Taxonomy terms per langauge and created mapping for the two languages I am using.
Now i created a page view(URL collections/%) with taxonomy term as views argument, for listing the nodes related to that term id.
Now the problem is when I view the url collections/4 in English its listing all the nodes related to that term id .
But when I click on the language Switcher the url become fr/collections/4 instead of fr/collections/20 where 20 is the translated term id for term id 4.
Please help me in solving this issue.
Thanks in Advance.
You should add a filter for language as well! That will do the job!

How to search a list of users based on taxonomy term in drupal 7?

I want to search users from a list of users by selecting taxonomy. and also I wanted to add taxonomy field in users profile/registration form.
Suppose I have different taxonomy like "Technology","Eduaction","Stocks" then by clicking on any of this I want the list of users who had selected the same taxonomy.Please suggest solution. I am extremely new to Drupal and also I am not a PHP programmer. I am using Drupal 7
To do that you need to download and enable following modules: Views, Chaos tool suite, Pathauto and Token.
And then follow steps below (I will assume that list of users on the particular tag will have URL like site.com/user-list/n where n is id of the term):
Create a new vocabulary (Structure/Taxonomy/Add vocabulary). Do not add any terms yet!
Add new alias pattern for your terms (Configuration/Search and metadata/URL aliases/Patterns/Taxonomy term paths). Pattern for "Pattern for all [Your vocabulary from step #1)] paths" should be user-list/[term:tid]
Now you can add new terms (Structure/Taxonomy/add terms).
Go to Configuration/People/Account settings, tab "MANAGE FIELDS". Add new field with type of data to store "term reference". While saving this field choose "Display on user registration form."
Now it's time to create a View, because basic term output works only with nodes. So, Modules/Views/Configure/Add new view. Change "Show: " from "content" to "users" and press "Continue & edit".
On the View's page you should set "Page settings Path:" to user-list and create a contextual filter (Advanced/Contextual filters/Add). You should add "User: [You vocabulary] (your_vocabulary) Appears in: user:user." filter. Now you can save the view. Notice, that in that state only users' names will be listed, if you want to add avatar and so on, you should add specific fields to your view besides "User: Name".
Now it should work just fine. Hope it helps.

Displaying content of term reference instead of link (Drupal 7)

I need help with this Drupal 7 situation:
I'm publishing travel agency offers using my own content type named "offer"
I'm storing information about hotels (descriptions, prices, photos, etc.) in taxonomy named "hotel"
I need to display relevant hotel info in each offer
And here is my problem. I've added a new term reference field named "field_hotel", but I only get a link to taxonomy term instead of actual content.
I tried to use this code, entity_load() runs fine, but I get "EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids()" error in field_view_field(().
$term = entity_load('taxonomy_term', array($hotel["und"][0]["taxonomy_term"]->tid));
$view = field_view_field('taxonomy_term', $term, 'field_hotel');
print render($view);
What am I doing wrong?
Thank you for your answers
Instead of storing hotel information in taxonomy terms, I'd suggest that you create a separate content type for hotels. That way, you'll be able to link offers to hotels using References, which is a much more flexible approach. That will also allow you to display hotel information on the offer page using Views.
Try replacing the second line with $view = taxonomy_term_view($term);
See documentation for taxonomy_term_view.

Drupal 7 - how to set up and translate field collection

I have taxonomy term with field collection field set to unlimited values. FC contains few texfield, textarea and image fields. FC and it's fields are set to be translated by user.
Taxonomy term is localized - all terms are the same for all languages just that they are translated. I have entity translation turned on for taxonomy term and node but not for FC because it trigers notice about not valid base path.
With this configuration: I create term and save it, after initial creation i can add any number of FCs and save them. On translate form I can then add translations for them. And when saved values remain saved for different laguages.
Problem occures when I create a view with relationship to FC, add FC fields and set contextual filter to termID (showing this view via panel on taxonomy terms). Field language stting is set to current user language. On views preview with manually set termID I see proper result for language in url (en/admin/structure/views..) and correct result if I change language prefix. But on term page it doesn't show anything.
I am using latest dev entiy translation an field collection modules.
I also tried setup with entity translation enabled for FC but again i don't get right output from views.
Where am I doing it wrong? FC setup, multilangual setup or in views. Does anyone have a hint how to make FC translatable?
I retested on clean installation. All this apply for what I described in #9 . Same result but some new/confirmed observations and possible workaround:
There is a bug in FC when translating fields for the first time values are not properly saved:
values are saved but when I refresh edit page, fields exist but are
empty/blank, fields on default language are ok
what really happens: when saving translation of FC fields, they are wrongfully linked to default language and not to translated one, also they don't show up when reopening default language so that they could be deleted. This can be bad if you accidentally catch them in a view as I did (for some time this was misleading me because titles were the same).
possible workaround: when first translating you have to delete values that are copied from default language and save it, then you can enter translated values
ET for FC enabled: same issue and workaround
After creating some content on terms and translating them with workaround, I tried to show them in panels via view.
I created a panel and set selection to taxonomy vocabulary I am using and under content I created "new custom content" in which I included some substitutions - for FC field %term:field_test_fc (this is my test content)
when I change language, values change accordingly to selected language
substitution renders all fields of FC and shows them in correct language
this is why this issue is bugging me… it should work on a view too because if term itself can distinguish between different languages of FC fields so can view via panel
I created view (page) in which I list all FC fields of all terms grouped by term name using relationship of that FC
content does change accordingly to the selected language =)
I created another view (content pane) as above and just added context filter, set it to termID and attach it to panels
view shows only FC fields of language that was used last when saving term. This mean that when editing and saving term in default language, view will only show fields of default language. weird :S
ET for FC enabled: it broke both views (showing fields of all languages everywhere), fixed by adding filter based on FC field: language and setting it to current user language
panels view still didn’t work as expected, but I knew that there was a problem with context filter
what I had to do is to remove validation criteria from context filter ( termID)
After solving last problem, view for panel is working and viewing term in both languages shows correct (translated) FC fields =).
Hope it helps understanding where problems occur and how to go around them. Fix would be nice though =)
Field Collections as a module has not yet been patched to support multilingual well. The debate is whether the field collection itself should be set to language-neutral, allowing the underlying fields to be language specific.
However, the field-collection module by itself does not currently support multilingual. There are a number of patches related to this on Drupal.org, including the following two major patch threads:
https://drupal.org/node/1344672
https://drupal.org/node/1316162
The Lingotek Translation module for Drupal 7 is successful at translating field collections and displaying them because it gets around the limitations of the Field Collection module using a combination of hook_entity_load, hook_entity_update, and a translation process that does not rely on the entity_translation module's UI.

Create a Drupal view that loads all articles that share any one taxonomy term (Contextual Filters)

I have a custom article type that contains a list of taxonomy terms
For example articles can be tagged with a location and possibly multiple topics.
On any given article's display page I would like to be able to pull a single view that gives a list of other articles that share any of of the taxonomy terms.
If an article was tagged with the topics of recipes & chicken as well as the location of new york I would like my single view to present the five most recent articles that share any one of the above tags.
The taxonomy terms have been added to the articles in the form of new fields of either the "Term reference" or "Node Reference" type. (field_topic, field_location)
I know that I have to somehow use a Contextual Filter, but I am having some trouble figuring out how to set and debug my "default argument".
I suspect that I've got to choose:
Taxonomy term ID from URL
Load the default filter from the node page
Do something with PHP code
I'm really struggling to get this displaying anything, and I can't even see a way to debug to find out what the values I'm getting are.
Can anyone help figure this out? Even some guidance on the right direction to look would be welcome at this point.
You can do this in just clicks if you have Drupal 7 and Views 3 (You already have this I'm sure).
Your configuration is correct so far.
Choose " Provide default value " as action to take if arg is not given.
Choose Term ID from URL"
Check "Load default filter from node page, that's good for related taxonomy blocks"
:)
this will load term IDs from the current node's term reference field if arguments are not given.

Resources