Skip to content

FEATURE: Translate categories with selected provider #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 24, 2025
Merged

FEATURE: Translate categories with selected provider #282

merged 5 commits into from
Apr 24, 2025

Conversation

nattsw
Copy link
Contributor

@nattsw nattsw commented Apr 23, 2025

This feature introduces the ability to translate categories on core's CategoryLocalization from discourse/discourse#32380. This includes

Anyone can manually translate all categories using

Jobs.enqueue(:translate_categories)

translated_name = translator.translate_text!(category.name, target_locale_sym)
translated_description = translator.translate_text!(category.description, target_locale_sym)

category.update!(name: translated_name, description: translated_description)
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that in a job we loop through locale, translate and then update name and description column. So if we have SiteSetting.automatic_translation_target_languages = "en|pl|de", only last locale translation will be saved.

Is it expected?

Copy link
Contributor Author

@nattsw nattsw Apr 23, 2025

Choose a reason for hiding this comment

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

My understanding is that in a job we loop through locale

In the job it loops category and locale:

      categories.each do |category|
          locales.each do |locale|
            # invoke this translation method
          end
      end

Then this .translate method translates for the specific category and 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.

You are right, fixed here #283

@nattsw nattsw merged commit 926197c into main Apr 24, 2025
6 checks passed
@nattsw nattsw deleted the cat-job branch April 24, 2025 02:39
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