mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 16:35:32 +08:00
FIX: Update mapping between locales and Postgres dictionaries. (#7606)
This commit is contained in:
parent
395f0ca126
commit
6bd082feab
@ -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
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
|
Loading…
x
Reference in New Issue
Block a user