توطين المحتوى - يدوي وتلقائي مع Discourse AI

In this topic, we will walk you through the Content Localization features and how to enable them. The features are split into two parts: What is available by default in Discourse; and Discourse AI for automatic translations. For quick access to the relevant sections, use the wiki headings :backhand_index_pointing_right:t2:

Localizing Your Community’s Content

An updated version of Discourse (3.5.0.beta7-dev) gives you access to several localization features available for configuration at:

  • <your-site-url>/admin/site_settings/category/content_localization
New Content Localization in Site Settings 📸

Getting information on your users

Firstly, it is good to get some information on your community. The following data explorer query can give you an idea of how many users may have set their locale in /my/preferences/interface

SELECT locale, count(*) as count
FROM users
WHERE (locale IS NOT null AND locale <> '')
GROUP BY locale
ORDER BY count DESC
Sample results from Data Explorer

Setting locales that your community supports

With the information above, we are now more informed about which locales your community should support.

In <your-site-url>/admin/site_settings/category/content_localization, you can select locales to support.

  • Content localization enabled - turns on the feature that replaces original written user content with localized content. Read on for auto and manual modes of localizing.
  • Content localization supported locales - the list of languages your site supports
  • Content localization anon language switcher - covered just below
List of locales in Site Settings 📸

Enabling the subsequent setting Content localization anon language switcher also allows you to make your community more accessible to non-logged-in users by showing the list of languages you’ve chosen in the list of supported locales:


Language switcher at the top right of the page

Viewing localized content


Localized welcome topic on meta.discourse.org

For viewers of localized content (all site visitors), they may cursor over the indicator next to the post’s date to view the original language of the post. This indicator only shows up if the post is not in their language.

If a user wishes to only see original content, they may use the toggle above the topic timeline to disable localizations for the whole site.

Automatic translations with Discourse AI :sparkles:

Discourse AI are the vitamins essential for the localization feature, and takes away the need to do manual translations.

As an admin, you’d want to head to our new AI features section for Translation.

Discourse AI Features in Admin Settings 📸

Scroll down in /admin/plugins/discourse-ai/ai-features

To cover some important settings and recommendations:

  • AI translation backfill hourly rate - this setting is hidden in the UI and defaults to 0. :warning: Automatic translation will not begin if this value is 0. Assuming the rate is 50, your site will translate 50 posts, 50 topics, and 50 categories per hour, to the locales you have set in Content localization supported locales. Keep this to a low number when starting out.
  • AI translation backfill max age days - defaults to 5. This means topics and posts older than 5 days will not be translated. You may increase this to a large number to translate all topics and posts.
  • AI translation backfill limit to public content - defaults to true. This prevents PMs and content in private categories from being sent to the LLM. When set to false, group PMs, and private categories will be included in translations. PMs between individuals will not be translated.
  • AI translation max post length - defaults to 10000. This is a safeguard and prevents posts above a certain length from being translated.
  • AI translation post raw translator persona (and other personas) - In more formal communities, admins may choose to create their own persona. This allows you to set a prompt that is more fine-tuned to the language or vocabulary you prefer.

You can refer to AI bot - Personas on how to configure suitable personas and fine-tune prompts for each function.

Translation Progress

You may find more information about how automatic translations are progressing in the Translation Progress chart on /admin/plugins/discourse-ai/ai-translations

This chart will show up if

  • all translator personas have a valid LLM
  • discourse ai enabled :check_mark:
  • ai translation enabled :check_mark:
  • content localization supported locales is filled
  • ai translation backfill max age days is more than 0
  • ai translation backfill hourly rate is more than 0

Manual localization

As localization is a core feature in Discourse, we provide the ability for you to fill in and edit localizations manually in the event automatic translations with Discourse AI is not available.

By default, admins and moderators are set up to edit localizations.

Localization allowed groups in Site Settings 📸


Admin Site Setting for Content Localization

Currently, we have post content, topic title, and category name and category description localizations. Tags are not supported yet, but will be in the near future. Subsequent sections below will show you how they work.

Category localization

Localized categories are visible in the following areas, with both category name and description localized:

Places where categories are localized 📸
  1. Homepage, sidebar, and category dropdown
  1. Categories page
  1. A specific category with subcategories

As an admin, you should be able to access category settings as usual, and find the new “Localizations” nav item on the left.

Editing category localizations in Category Settings 📸

Topic and Post localization

From the screenshots above in Category localization, you may have noticed topic titles and excerpts being localized.

There are some pre-requisite settings

  • Ensure your user is in content localization allowed groups
  • Add addTranslation in site setting for post menu. This allows the :globe_with_meridians: to show up in the post menu for users in content localization allowed groups
2 Site Settings 📸


:backhand_index_pointing_down:t2:

Once again, the list of localizable languages is in the Content localization supported locales setting mentioned above.

Editing a localized post

In the event the user might be viewing a localized post, and wants to edit the post, a dialog will appear to ask which version they would prefer to edit:

The appropriate composer will appear after deciding.

Deleting a post’s translation for a certain locale

If you’ve followed instructions above regarding the post menu setting correctly, you should be able to do the following if you’re in the content_localization_allowed_groups:

FAQ

I’ve set things up, but automatic translation is still not working for me
Confirm if you’ve these set up

  • Content localization supported locales has at least one language
  • Content localization enabled is :check_mark:
  • Ai translation enabled is :check_mark:
  • Ai translation max age days is not 0
  • Ai translation backfill hourly rate is more than 12. This is a hidden site setting which requires console access.
  • You must have a working LLM set for each translation persona

If all else fails, you can enable SiteSetting.ai_translation_verbose_logs.

Is every post getting translated?
If AI translation backfill limit to public content is :check_mark: , all posts in public categories except for Bot (user id < 0) posts will be translated.

Are the automatic translations saved, or is it being sent to the LLM each time someone views a topic?
The translations are saved, each post is only sent once per language and the translations are reused.

If my forum supports English and Japanese (via Content localization supported locales), and someone writes in Spanish, will their post be translated?
Yes. All topics and posts will be translated to English and Japanese, regardless of the written language.

If the original post is edited, is it re-translated?
Yes – with a maximum of 2 times per day. When a post is edited, it gets sent to re-translation 5 minutes later (or the SiteSetting.editing_grace_period) to account for ninja edits.

Will translations be deleted if I change the Persona or LLM?
No, translations will typically persist across settings changes unless explicitly deleted using the post menu item or the translation composer.


21 إعجابًا

هل هناك أي توصيات للقيام بذلك بشكل جماعي للفئات الموجودة؟ في أسوأ الأحوال، ربما عبر واجهة برمجة التطبيقات؟

إعجابَين (2)

سؤال رائع. سأحرص على تحديث وثائق واجهة برمجة التطبيقات لنقطة نهاية تحديث الفئة. :memo:

4 إعجابات

هل سيكون هناك دعم لمشرف لكل لغة؟ أفكر في الميتا – حيث قد أتطوع لفحص المشاركات بلغة معينة وتحديثها يدويًا. خاصة الوثائق التي قد ترحب ببعض اللمسات البشرية. لكنك تقول أن المشرفين فقط يمكنهم فعل ذلك وهو ما لن أكونه على الأرجح أبدًا.

إعجابَين (2)

اقتراح جيد. أعتقد أنه يمكن القيام بذلك ولكن سنحتاج إلى التفكير في التفاصيل حول كيفية إعداده.

إعجابَين (2)

كيف يمكنني الوصول إليه؟ هل يمكنك تقديم أمر من فضلك؟

هل لدى Sidekiq أي مهمة مرتبطة؟ هل من الممكن تشغيلها يدويًا؟

إعجاب واحد (1)
إعجابَين (2)

لإضافة إلى منشور Moin أعلاه، إنه فقط SiteSetting. ai_translation_backfill_hourly_rate بمجرد وصولك إلى وحدة التحكم. تعمل المهمة كل خمس دقائق وتحد من المعدل وفقًا لذلك.

إعجابَين (2)

أرى أن التوطين أصبح متاحًا الآن في المستندات. شكرًا @nat!

3 إعجابات

هذا رائع، تهانينا للفريق! أنا أختبره الآن وسأشارك أفكاري وتجربتي العامة.

نحن نفتقد لغة الإسبرانتو في القائمة؛ هل يمكن إضافة هذه اللغة “ببساطة” أم يجب بناؤها أولاً في discourse-languages؟

رائع، أنت متابع جيد – كنت على وشك الإبلاغ عن ذلك هنا. :laughing:

نعم، نوعًا ما. نريد تجربة توطين كاملة حيث يتم ترجمة عناصر التحكم (الأزرار، التسميات، إلخ) بشكل صحيح وكافٍ (70٪ ستكون جيدة حقًا) عبر Crowdin (انظر Translations - Discourse Meta)، ومع ذلك يمكننا تقديم الدعم للغة.

إعجاب واحد (1)

هل يعمل توطين المحتوى مع فئات الوثائق؟ يبدو لي أن محتوى الشريط الجانبي لا تتم ترجمته على الرغم من أنني أقوم بتوطين موضوع الفهرس.

لاحظت أيضًا سلوكًا غريبًا. عندما أرى موضوعًا موطنًا باللغة الأصلية وأقوم بتحديثه، فإنه يتحول إلى النسخة الموطنة. يجب علي التبديل مرة أخرى إلى النسخة الأصلية يدويًا.

إعجابَين (2)

يا لها من ملاحظة رائعة، نعم إنها لا تعمل بعد، ولكن هناك شيء سيتتبعه @nat!

أتساءل عما إذا كان هذا محفزًا للتوصل إلى تجريد أفضل / نموذج بيانات لروابط مستندات الشريط الجانبي.

إعجاب واحد (1)

نعم هذا صحيح – هناك العديد من الأماكن في Discourse التي ستحتاج إلى ترجمة صريحة، لذا أقوم بتسجيلها عند ظهورها. في الآونة الأخيرة، قمنا أيضًا بترجمة الإشعارات لعناوين المواضيع. هذا مثال لموضوع ميزة قمت بإنشائه - Show translated user bios.

سأقوم بإنشاء موضوع جديد وسأقوم بالإشارة إليك حتى نتأكد من تغطية جميع الجوانب في الشريط الجانبي.

تعديل: تمت تغطية tvavrda هنا - Translate sidebar documentation links. يرجى إلقاء نظرة ومعرفة ما إذا كان ذلك منطقيًا.

ماذا تقصد بـ “التبديل مرة أخرى”؟

هل تمانع في مشاركة تسجيل فيديو (يتضمن شريط العنوان) في المرة القادمة التي يحدث فيها ذلك؟ :folded_hands:t2: لا تتردد في إرسال رسالة خاصة لي في هذه الحالة إذا كان المحتوى غير مناسب للنشر العام. أيضًا، هل كنت مسجلاً الدخول؟ من الناحية الفنية، يتم تتبع هذه الأشياء بواسطة ملفات تعريف الارتباط لذا فهي محيرة بعض الشيء بالنسبة لي.

إعجاب واحد (1)

أرسلت لك مقطع فيديو.

ملاحظة أخرى - لا يمكنني رؤية الفروقات في المحتوى المترجم، صحيح؟ قد يكون ذلك مفيدًا إذا كانت هناك تحديثات له. ليس مهمًا للغاية ولكنه منطقي، على ما أعتقد.

وأخرى - الروابط الخلفية تحت الموضوع لا تعرض اسم موضوع مترجم.

وسؤال: ما الهدف من ترجمة أوصاف الفئات في إعدادات الفئة؟ يجب أن يأتي وصف الفئة من النسخة المترجمة لموضوع “حول”، أليس كذلك؟ النسخة المترجمة لا تدعم تنسيق ماركداون، لذلك لا يمكنني استخدام رابط، وهو ما أود فعله.

إعجاب واحد (1)

حسناً… المكون القديم GitHub - discourse/discourse-docs-sidebar يحترم الترجمة بالفعل :slight_smile: لقد تحولت إليه مؤقتًا.

نعم، هذا غير مدعوم حاليًا وسيكون مجهودًا كبيرًا.

لدينا مؤشر صغير ملون بشكل خاص (مشابه لمؤشر تعديلات المنشور بجانبه) عندما قد يكون الترجمة قديمة لأن إصدار المنشور قد تغير.

إعجاب واحد (1)

أرى أيضًا محتوى غير مترجم في ملخصات المواضيع المثبتة. لذا أرى قائمة مواضيع باللغة المترجمة ولكن ملخص الموضوع المثبت يظهر الأصلي.

إعجاب واحد (1)

هل يمكننا تشغيل عمليات الترجمة يدويًا، ولكن هل يمكننا تشغيل بناء الترجمات يدويًا؟ نوع من المهام عند الطلب.

ما أفكر فيه هو أنني سمحت بالترجمة للمواضيع التي يعود تاريخها إلى عام. ولكن إذا تم حساب هذه السنة من التاريخ الحالي، فإن هذا الحد سيتحرك باستمرار نحو المحتوى المترجم بالفعل. ولكن أكبر طلب هو المحتوى القيم القديم الذي أود الوصول إليه بسرعة وبدون إجراءات جماعية بطيئة للغاية.

لدي فضول، هل لدى أي شخص أي أرقام تكلفة بعد تفعيل الترجمات؟ موقعنا موجود منذ فترة، وبينما أود ترجمة الموقع بالكامل إن أمكن، فإن التكلفة تمثل بالتأكيد مصدر قلق. لذا، إذا كان لدى شخص ما فكرة تقريبية عن التكلفة من تجربته، على سبيل المثال، 1000 منشور ينتج عنها تكلفة 1 دولار، فسيكون ذلك مفيدًا للغاية للحصول على فكرة تقريبية للتكلفة.

هل يتم إجراء تحديد موقع المحتوى مرة واحدة ثم تخزينه في مكان ما، أي ليس عند الطلب؟ إذا كان الأمر كذلك، فهل هناك أي شيء يمنعني من تشغيل Ollama وبعض نماذج LLM مفتوحة المصدر على جهازي المكتبي مثل Llama 3 أو Deepseek 3 والسماح للمهمة بالتشغيل حتى تنتهي؟

تعديل: أعتقد أنه قد يعمل على خفض تكلفة الترجمة الأولية، ولكنه لن يعمل للمنشورات الأحدث ما لم يقرر المرء إبقاء نموذج LLM المحلي قيد التشغيل بشكل دائم.