mirror of
https://github.com/discourse/discourse.git
synced 2025-03-31 10:16:42 +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.
|
# But it may not appear there based on pg extension configuration.
|
||||||
# base docker config
|
# base docker config
|
||||||
#
|
#
|
||||||
case locale.to_sym
|
case locale.split("_")[0].to_sym
|
||||||
when :da then 'danish'
|
when :da then 'danish'
|
||||||
when :de then 'german'
|
when :nl then 'dutch'
|
||||||
when :en then 'english'
|
when :en then 'english'
|
||||||
when :es then 'spanish'
|
when :fi then 'finnish'
|
||||||
when :fr then 'french'
|
when :fr then 'french'
|
||||||
when :it then 'italian'
|
when :de then 'german'
|
||||||
when :nl then 'dutch'
|
when :hu then 'hungarian'
|
||||||
when :nb_NO then 'norwegian'
|
when :it then 'italian'
|
||||||
when :pt then 'portuguese'
|
when :nb then 'norwegian'
|
||||||
when :pt_BR then 'portuguese'
|
when :pt then 'portuguese'
|
||||||
when :sv then 'swedish'
|
when :ro then 'romanian'
|
||||||
when :ru then 'russian'
|
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
|
else 'simple' # use the 'simple' stemmer for other languages
|
||||||
end
|
end
|
||||||
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