Skip to content

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
nattsw added a commit that referenced this pull request Apr 30, 2025
Earlier on in #282 we introduced a setting for categories only. That is quite short-sighted so the setting is now for all user generated content `experimental_content_translation`.

This will be used in the next commit that translates posts and topics.
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.

4 participants