diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-06-04 02:41:02 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-06-04 02:41:02 -0400 |
commit | bf9829352b85e358f33061e65ece5d5515780840 (patch) | |
tree | 68256b5e58c93753c06e847de044adff76cd5380 /IkiWiki | |
parent | 47b5417ac0f3df81dcde5693deee4ff62c45b5f0 (diff) | |
download | ikiwiki-bf9829352b85e358f33061e65ece5d5515780840.tar ikiwiki-bf9829352b85e358f33061e65ece5d5515780840.tar.gz |
have the xapian stemmer use a language based on LANG
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/search.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 5e1d98a72..14bdb8dbc 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -54,6 +54,7 @@ sub pagetemplate (@) { #{{{ } #}}} my $scrubber; +my $stemmer; sub index (@) { #{{{ my %params=@_; @@ -105,7 +106,15 @@ sub index (@) { #{{{ ); my $tg = Search::Xapian::TermGenerator->new(); - $tg->set_stemmer(new Search::Xapian::Stem("english")); + if (! $stemmer) { + my $langcode=$ENV{LANG} || "en"; + $langcode=~s/_.*//; + eval { $stemmer=Search::Xapian::Stem->new($langcode) }; + if ($@) { + $stemmer=Search::Xapian::Stem->new("english"); + } + } + $tg->set_stemmer($stemmer); $tg->set_document($doc); $tg->index_text($params{page}, 2); $tg->index_text($title, 2); |