1
0
mirror of synced 2026-08-05 15:26:55 +00:00

fix: locale handling in assistant.rb (#705)

This commit is contained in:
PangBo
2024-07-05 17:16:09 +08:00
committed by GitHub
parent d555f18c6f
commit 4ebbdc043e
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -29,7 +29,9 @@ module DiscourseAi
prompts.map do |prompt|
if prompt.name == "translate"
locale = user.effective_locale
locale_hash = LocaleSiteSetting.language_names[locale]
locale_hash =
LocaleSiteSetting.language_names[locale] ||
LocaleSiteSetting.language_names[locale.split("_")[0]]
translation =
I18n.t(
"discourse_ai.ai_helper.prompts.translate",
@@ -59,6 +59,11 @@ RSpec.describe DiscourseAi::AiHelper::Assistant do
)
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
before do
SiteSetting.ai_helper_illustrate_post_model = "stable_diffusion_xl"