Problem/Motivation
The search protocol accepts a parameter named lr that allows to restrict search results by language.
e.g. When searching content from a Chinese interface, it allows to display only Chinese results.
Currently the google_appliance module does not seem to support such language filter. It could be nice, for instance on multillingual sites.
Proposed resolution
This can be implemented by altering queries sent to the GSA -- we just have to set the lr parameter appropriately.
Administrators would still have the option not to use language filtering.
Attached is a patch suggestion to provide such feature.
Remaining tasks
- Opinions welcome.
- The patch can be reviewed.
Interface changes
See screenshot -- new options provided on admin/config/search/google_appliance/settings.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | google_appliance_language_filtering-4.patch | 5.81 KB | fengtan |
| #2 | google_appliance_language_filtering-2.patch | 5.31 KB | fengtan |
| google_appliance_language_filtering_admin_ui.png | 70.22 KB | fengtan | |
| google_appliance_language_filtering.patch | 4.18 KB | fengtan |
Comments
Comment #1
iamEAP commentedThanks @Fengtan! This is definitely something I'd love to support in the module. Your patch looks pretty good, but I've found a few small issues in reviewing the code, found below.
Once those are taken care of, I'd like to manually test against my instance and provide further feedback and/or integrate the patch.
Small nitpick: Maybe just "Restrict searches to specified languages."
I believe strings within t() functions should avoid using escape characters for the purposes of integration with localize.drupal.org.
Should probably just wrap this in double quotes.
Although antiquated... It'd be best to integrate these configurations into the _google_appliance_get_settings() system that's in place, rather than calling variable_get() directly.
Comment #2
fengtanAwesome. Thanks for the review.
Here is a new patch that should take the feedback into consideration.
Note that one variable uses array values, which cannot be used as PHP constants. I did this as a workaround:
Comment #3
iamEAP commentedThanks! You work quickly.
Changes look good and manual review went well. Just a couple more notes, after looking at the patch holistically, and I think it'll be ready to commit.
Comment #4
fengtanRight, that makes sense. Here is a new patch.
Comment #6
iamEAP commentedThanks for your contribution, @Fengtan! Committed and pushed to dev (as noted above).