Closed (won't fix)
Project:
Facet API
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Jul 2011 at 14:20 UTC
Updated:
11 Apr 2020 at 21:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
cpliakas commentedTranslation is not as simple as the post above. Let's define some context around this request along with the problems we are trying to solve.
Comment #2
chriscalip commentedFor sure; those facet blocks generates links. The idea is to translate the title of those links case in point
See Screenshot.png
Filtro por idioma and Filter by gender , those block titles can be translated but we cant seem to translate the link titles inside the block content.
Comment #3
chriscalip commentedI would gladly put in some coding time to generate a patch per your request; I could use some of your guidance though since I am not so familiar with the module.
Comment #4
cpliakas commentedThanks for posting back with the screenshot. In terms of the search, I want to confirm that you are searching by the same string, i.e. "en" for English, you just want the display names of the Facet items to be translated. Same would be true for "Male", "Female", and the other items in the screenshot.
Thanks,
Chris
Comment #5
chriscalip commentedHey Chris,
1. Yup just want to display names of the Facet items to be translated.
2. I was not going ambitious that the context/facet content links would change depending on the language. Is this even possible, is it only in the theoretical realm, practical realm already being done by other d7 installs?
Cheers,
Chris
Comment #6
cpliakas commentedOK, cool. Unfortunately #2 is a highly discussed topic, and AFAIK there is no elegant solution for doing it right now.
Regarding #1, my personal opinion would be to write a custom module that integrates with the Internationalization module. How you would do this is implement hook_facetapi_facet_info_alter() and change the "map callback" functions to ones in your module that do the mapping using the appropriate i18n functions. I am not an expert in the i18n module by any means, but this is the avenue you would take to translate the user generated data.
Changing to a support request because the integration points are in place i18n integration is outside of the scope of the core module. Would absolutely love to have a contrib that does the integration, though.
Thanks,
Chris
Comment #7
chriscalip commentedChris,
ok dokes will make a contrib module to do integration. Nothing like website client project sponsorship to make contrib modules happen :) ahem at least will try, first d7 site here :) . d7 domain access, apachesolr, faceted search, i18n, panels oh what fun :)
Cheers!
Comment #8
cpliakas commentedClient sponsorship = awesomeness!
Comment #9
cpliakas commentedRespectfully marking as "won't fix" since the code should exist as another project.
Comment #10
BarisW commentedFor now, a simple fix could be to just wrap the t() function on the title:
Change
into
Comment #11
cpliakas commentedBarisW,
Your solution would technically work, however it is against best practices in terms of how the t() function should be used according to the guidelines at http://drupal.org/node/322729. To quote the passage in the cheat sheet:
The values in this field are probably user generated strings such as taxonomy terms or content types, so a different method of translation should be used.
Thanks,
Chris
Comment #12
BarisW commentedHi Chris,
I know and I agree. But in this case, it works. And because it's in a theme function, I didn't hace to hack the module.
So it's a dirty fix until there is a better solution.
Comment #13
cpliakas commentedGotcha. Thanks for clarifying, and I am sure it will help someone else out.
Thanks,
Chris
Comment #14
egomac commentedI havent tried this but #10 seems to be only translating the text and not the term id. What if you are using a different term id for a facet item based on translation? For example:
tid: 1
termname: Bars
tid: 10
termname: 酒吧
Take note that the 2 terms are linked by a translation set. This means that the expected behavior for a facet in an english site will need to have a term id of 1 and a term text as "Bars" and when switched to a chinese language, the term id needs to be 10 and so will the text change to "酒吧"
Comment #15
tnightingale commentedsubscribe
Edit: Just noticed this issue is closed :-P my bad. However I am interested in this subject.
Comment #16
cpliakas commentedthegreat is awesome and posted a sandbox project at http://drupal.org/sandbox/thegreat/1276796 to start work on this issue. Let's start collaborating there on how to solve this tough problem.
Comment #17
janchojnacki commentedBased on the BarisW's code created working patch for me.
Comment #18
tnightingale commentedJust an update (also posted on my sandbox page).
I18n for taxonomy term facets has essentially been resolved as a result of this: http://drupal.org/node/1340858#comment-5259368. If your taxonomy has been translated/localized via i18n_taxonomy then entity_label('taxonomy_term', $tid) will return the localized term name.
As a result I'm currently not planning any further development to facetapi_i18n.
Comment #19
finex commented@jaanhoinatski: your patch works but if you have vocabularies term already translated you've to translate them again due to a different string context.
Moreover instead of editing
theme_facetapi_link_inactive()andtheme_facetapi_link_active()it could be fixed from the execute() method (from widget_links.inc), something like:Moreover in certain case probably this would not be correct, so I'm currently working on a facet based settings to enable the translation.
Comment #20
Anonymous (not verified) commentedThis is finally the thread I was searching for! Pulling my hair out on this for days now. :)
@FiNex: I tried you idea at #19 and it works partially:
While I have five facet blocks, three are based on taxonomies and worked already before. The other two are based on fields. One block is now properly showing the translated fields. The last one doesn't. Maybe one of the 'certain cases'.
Anyway, let me know if you need people to test your patches, I am more than happy to help.
Comment #21
Anonymous (not verified) commentedTurned out I had a translation mess with the second block => all working now with the following patch:
Comment #22
brainHax commentedSo with all these solutions, do you still have to translate each terms from translate interface? there is no way to use "Translate Taxonomy term" still ! ?
Comment #23
marwen.blel commentedhello. i noticed that you suggessed many solutions!
which one is the best to integrates with facet api module? or is there any update that contains fixed issues!