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_name = ShortTextTranslator.new(text: category.name, target_locale:).translate
|
||||||
translated_description =
|
translated_description =
|
||||||
if category.description.present?
|
if category.description_excerpt.present?
|
||||||
PostRawTranslator.new(text: category.description, target_locale:).translate
|
PostRawTranslator.new(text: category.description_excerpt, target_locale:).translate
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ describe DiscourseAi::Translation::CategoryLocalizer do
|
|||||||
end
|
end
|
||||||
|
|
||||||
fab!(:category) do
|
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
|
end
|
||||||
|
|
||||||
describe ".localize" do
|
describe ".localize" do
|
||||||
@ -42,7 +42,7 @@ describe DiscourseAi::Translation::CategoryLocalizer do
|
|||||||
)
|
)
|
||||||
post_raw_translator_stub(
|
post_raw_translator_stub(
|
||||||
{
|
{
|
||||||
text: category.description,
|
text: category.description_excerpt,
|
||||||
target_locale: target_locale,
|
target_locale: target_locale,
|
||||||
translated: translated_cat_desc,
|
translated: translated_cat_desc,
|
||||||
},
|
},
|
||||||
@ -61,7 +61,7 @@ describe DiscourseAi::Translation::CategoryLocalizer do
|
|||||||
{ text: category.name, target_locale:, translated: translated_cat_name },
|
{ text: category.name, target_locale:, translated: translated_cat_name },
|
||||||
)
|
)
|
||||||
post_raw_translator_stub(
|
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)
|
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 },
|
{ text: category.name, target_locale: "es", translated: translated_cat_name },
|
||||||
)
|
)
|
||||||
post_raw_translator_stub(
|
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)
|
res = localizer.localize(category)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user