FIX: Update mapping between locales and Postgres dictionaries. ()

This commit is contained in:
Dan Ungureanu 2019-05-27 16:52:09 +03:00 committed by GitHub
parent 395f0ca126
commit 6bd082feab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 13 deletions

@ -41,19 +41,22 @@ class Search
# But it may not appear there based on pg extension configuration.
# base docker config
#
case locale.to_sym
when :da then 'danish'
when :de then 'german'
when :en then 'english'
when :es then 'spanish'
when :fr then 'french'
when :it then 'italian'
when :nl then 'dutch'
when :nb_NO then 'norwegian'
when :pt then 'portuguese'
when :pt_BR then 'portuguese'
when :sv then 'swedish'
when :ru then 'russian'
case locale.split("_")[0].to_sym
when :da then 'danish'
when :nl then 'dutch'
when :en then 'english'
when :fi then 'finnish'
when :fr then 'french'
when :de then 'german'
when :hu then 'hungarian'
when :it then 'italian'
when :nb then 'norwegian'
when :pt then 'portuguese'
when :ro then 'romanian'
when :ru then 'russian'
when :es then 'spanish'
when :sv then 'swedish'
when :tr then 'turkish'
else 'simple' # use the 'simple' stemmer for other languages
end
end

18
spec/lib/search_spec.rb Normal file

@ -0,0 +1,18 @@
# frozen_string_literal: true
require 'rails_helper'
describe Search do
context "#ts_config" do
it "maps locales to correct Postgres dictionaries" do
expect(Search.ts_config).to eq("english")
expect(Search.ts_config("en")).to eq("english")
expect(Search.ts_config("en_US")).to eq("english")
expect(Search.ts_config("pt_BR")).to eq("portuguese")
expect(Search.ts_config("tr")).to eq("turkish")
expect(Search.ts_config("xx")).to eq("simple")
end
end
end