Add spelling suggestions

Created on 28 August 2014, over 10 years ago
Updated 29 April 2023, over 1 year ago

I took the liberty to create a patch for google spelling suggestions for both searches with and without results

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇱🇹Lithuania prat

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * The spelling suggestion
    +   * @var array
    +   */
    +  private $suggestion = NULL;

    Since that property is initialized to NULL, its type should also include that.

    +   * Get Spelling Suggestion.
    +   *
    +   * @return array The extra parameters to CSE.

    The return value description goes to a new line.

    +    // save spelling suggetion
    +    $this->suggestion = (string)$results->Spelling->Suggestion;
    +

    Comments are sentences: They start with a capitalized word and end with a period.
    suggetion is misspelled.

    +    if(!empty($spelling_suggestion) && is_string($spelling_suggestion) ) {
    +      $html .= '<span>' . t("Did you mean ") . l($spelling_suggestion, 'search/gss/'.$spelling_suggestion)  . '</span><ul>';
    +    }

    There must be a space after if.
    There is an extraneous space between the closing parentheses.
    Strings passed to t() needs to use placeholders.
    I am not sure it is necessary to use l() in this case.

    I would also leave fixing any coding standards issue to a different issue. This is about implementing a feature and it should be limited to that. At least, the patch would still be valid even when the coding standards are fixed.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    I am not sure the maintainers will add this feature, though. The project page says:

    We discourage use this module, since Google decided to discontinue Google Site Search as a paid service.

    If Google Site Search has been discontinued, new features cannot be used.

Production build 0.71.5 2024