From 44ab1c531d1aca7bf5223ad011b7a1e848a291b7 Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Mon, 2 Apr 2012 15:27:49 +0200 Subject: [PATCH] Bug 7445 - Clicking on a tag gives "Language ... does not exist" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To test: - Syspref QueryStemming = Try - Install Norwegian bokmål: cd misc/translator/ perl translate install nb-NO - Go to Home › Administration › System Preferences > I18N/L10N and enable "Norsk bokmål(nb-NO)" for opaclanguages as well as setting opaclanguagesdisplay = Allow - Make sure you have selected "Norsk bokmål" as the active language in the OPAC - Find a record that has a tag (which does not contain any digits) - Click on the tag and see that you get the error in the title of this bug - Apply the patch - Click on the tag again and the error should be gone Signed-off-by: Katrin Fischer Easy to test with a great test plan. Works nicely. Signed-off-by: Paul Poulain --- C4/Search.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C4/Search.pm b/C4/Search.pm index 56468b5098..33a1d169b1 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -733,6 +733,13 @@ sub _build_stemmed_operand { # FIXME: the locale should be set based on the user's language and/or search choice #warn "$lang"; + # Make sure we only use the first two letters from the language code + $lang = lc(substr($lang, 0, 2)); + # The language codes for the two variants of Norwegian will now be "nb" and "nn", + # none of which Lingua::Stem::Snowball can use, so we need to "translate" them + if ($lang eq 'nb' || $lang eq 'nn') { + $lang = 'no'; + } my $stemmer = Lingua::Stem::Snowball->new( lang => $lang, encoding => "UTF-8" ); -- 2.39.5