Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented May 7, 2025

Requires discourse/discourse#32619. A compat file already exists
Related: #287

This PR adds the functionality to translate topics using the selected provider. We are keeping the topic translation feature separate from the post translation on purpose, despite many things being the same. This allows easy modification per model and less coupling.

image

@nattsw nattsw force-pushed the topic-localization branch 2 times, most recently from 72b898d to 80f0bad Compare May 7, 2025 15:28
@nattsw nattsw force-pushed the topic-localization branch from 80f0bad to aea45e7 Compare May 7, 2025 15:32
translator = DiscourseTranslator::Provider::TranslatorProvider.get
detected_locale = translator.detect!(topic)
locale = LocaleNormalizer.normalize_to_i18n(detected_locale)
topic.update!(locale:)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax here is equivalent to locale: locale?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

@nattsw nattsw merged commit d7ae611 into main May 8, 2025
6 checks passed
@nattsw nattsw deleted the topic-localization branch May 8, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants