fix: locale handling in assistant.rb (#705)
This commit is contained in:
parent
d555f18c6f
commit
4ebbdc043e
|
@ -29,7 +29,9 @@ module DiscourseAi
|
||||||
prompts.map do |prompt|
|
prompts.map do |prompt|
|
||||||
if prompt.name == "translate"
|
if prompt.name == "translate"
|
||||||
locale = user.effective_locale
|
locale = user.effective_locale
|
||||||
locale_hash = LocaleSiteSetting.language_names[locale]
|
locale_hash =
|
||||||
|
LocaleSiteSetting.language_names[locale] ||
|
||||||
|
LocaleSiteSetting.language_names[locale.split("_")[0]]
|
||||||
translation =
|
translation =
|
||||||
I18n.t(
|
I18n.t(
|
||||||
"discourse_ai.ai_helper.prompts.translate",
|
"discourse_ai.ai_helper.prompts.translate",
|
||||||
|
|
|
@ -59,6 +59,11 @@ RSpec.describe DiscourseAi::AiHelper::Assistant do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not raise an error when effective_locale does not exactly match keys in LocaleSiteSetting" do
|
||||||
|
SiteSetting.default_locale = "zh_CN"
|
||||||
|
expect { subject.available_prompts(user) }.not_to raise_error
|
||||||
|
end
|
||||||
|
|
||||||
context "when illustrate post model is enabled" do
|
context "when illustrate post model is enabled" do
|
||||||
before do
|
before do
|
||||||
SiteSetting.ai_helper_illustrate_post_model = "stable_diffusion_xl"
|
SiteSetting.ai_helper_illustrate_post_model = "stable_diffusion_xl"
|
||||||
|
|
Loading…
Reference in New Issue