I'm not sure this is the right place to post this. Seems to me that language names when language is used as a facet should be translated as well. At the moment whether I use the Search API field for language or the Drupal field for language my language name (is this what you call "label"?) doesn't get translated. Interestingly, "Language neutral" does get translated to "Indépendant de la langue".
Unless I'm missing something could this be part of facetapi_i18n? I'm happy to give it a try if you were to accept a patch here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miiimooo’s picture

Status: Active » Needs review
FileSize
555 bytes

Attached please find my (trivial) patch. Not sure thsi is teh right way of doing this but it works nicely and uses the existing facetapi_map_language callback provided by facetapi

cpliakas’s picture

Title: Translate language labels » Language facets are not translated
Project: Facet API Translation » Search API
Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Component: Code » Facets
Category: feature » bug
Status: Needs review » Needs work

Hi miiimooo.

Thanks for the post. I actually think this belongs in the Search API module. The facets are defined by the implementing module, and the map callbacks are set in the facet definitions. This is consistent with Facet API's default facets (which are used by Faceted Navigation for Search) as well as Apache Solr Search Integration's facet definitions. To me, Search API should know which field contains the language data and set the map callback accordingly.

Thanks again,
Chris

gilsbert’s picture

Issue summary: View changes

Hi.

I have the same need.
Did you find a solution on how to translate the facet for a language field?

Regards,
Gilsberty

drunken monkey’s picture

Project: Search API » Entity API
Component: Facets » Core integration
Status: Needs work » Needs review
FileSize
451 bytes

The label mapping we are using for language fields is entity_metadata_language_list(), provided by the Entity API for, e.g., the node language. So probably this should be fixed there, if this is really the right way to do it.
Patch attached, to be applied to the Entity API module. Please see whether it fixes the issue!

Otherwise, I guess the best way would be with a short custom hook_facetapi_facet_info_alter() implementation that implements the same change as the patch in #1.

drunken monkey’s picture

Title: Language facets are not translated » Language labels are not translated
gilsbert’s picture

Status: Needs review » Reviewed & tested by the community

Hi Drunken.

Your patch works and fixed the issue.
Thank you very much.

May it be commited to entity project?

Regards,
Gilsberty

The last submitted patch, 1: translate_language_labels-1794378-1.patch, failed testing.

gilsbert’s picture

Hi, I tested the patch in #4 and it works.

I don't know why the testbot tried to use the patch in #1.

Regards,
Gilsberty

drunken monkey’s picture

Thanks for testing the patch, great to hear it works! Now we just have to wait for fago to come round and commit it. ;)
The test bot will always test all untested patches, sometimes this is what you want. However, since the last patch, #4, succeeded, it didn't set the status to "Needs work", I think.

fago’s picture

Status: Reviewed & tested by the community » Fixed

Looks like core runs the language names through t() as well, thus - committed. FYI I've recently committed a similar fix for translated field option label support via i18n field.

gilsbert’s picture

Hi.

This is probably expected but I would like to warn that the patch is not applied on 7.x-1.4 .

Regards,
Gilsberty

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.