mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-08 23:32:45 +00:00
FIX: Localize description excerpts as they have limits (#1490)
This commit is contained in:
parent
7357280e88
commit
56f025cf44
@ -10,8 +10,8 @@ module DiscourseAi
|
||||
|
||||
translated_name = ShortTextTranslator.new(text: category.name, target_locale:).translate
|
||||
translated_description =
|
||||
if category.description.present?
|
||||
PostRawTranslator.new(text: category.description, target_locale:).translate
|
||||
if category.description_excerpt.present?
|
||||
PostRawTranslator.new(text: category.description_excerpt, target_locale:).translate
|
||||
else
|
||||
""
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ describe DiscourseAi::Translation::CategoryLocalizer do
|
||||
end
|
||||
|
||||
fab!(:category) do
|
||||
Fabricate(:category, name: "Test Category", description: "This is a test category")
|
||||
Fabricate(:category, name: "Test Category", description: "This is a test category. " * 50)
|
||||
end
|
||||
|
||||
describe ".localize" do
|
||||
@ -42,7 +42,7 @@ describe DiscourseAi::Translation::CategoryLocalizer do
|
||||
)
|
||||
post_raw_translator_stub(
|
||||
{
|
||||
text: category.description,
|
||||
text: category.description_excerpt,
|
||||
target_locale: target_locale,
|
||||
translated: translated_cat_desc,
|
||||
},
|
||||
@ -61,7 +61,7 @@ describe DiscourseAi::Translation::CategoryLocalizer do
|
||||
{ text: category.name, target_locale:, translated: translated_cat_name },
|
||||
)
|
||||
post_raw_translator_stub(
|
||||
{ text: category.description, target_locale:, translated: translated_cat_desc },
|
||||
{ text: category.description_excerpt, target_locale:, translated: translated_cat_desc },
|
||||
)
|
||||
|
||||
res = localizer.localize(category, target_locale)
|
||||
@ -86,7 +86,11 @@ describe DiscourseAi::Translation::CategoryLocalizer do
|
||||
{ text: category.name, target_locale: "es", translated: translated_cat_name },
|
||||
)
|
||||
post_raw_translator_stub(
|
||||
{ text: category.description, target_locale: "es", translated: translated_cat_desc },
|
||||
{
|
||||
text: category.description_excerpt,
|
||||
target_locale: "es",
|
||||
translated: translated_cat_desc,
|
||||
},
|
||||
)
|
||||
|
||||
res = localizer.localize(category)
|
||||
|
Loading…
x
Reference in New Issue
Block a user