Discourse 翻译器

||||
-|-|
:discourse2: | 摘要 | Discourse Translator 使用 Microsoft、Google 或 Yandex 翻译 API 来翻译 Discourse 中的帖子。
:hammer_and_wrench: | 仓库链接 | https://github.com/discourse/discourse-translator
:open_book: | 安装指南 | 如何在 Discourse 中安装插件

功能

  • 每个帖子在每个区域设置下仅翻译一次,从而为您节省 :moneybag:
    • 请注意,语言检测也是针对每个帖子运行一次的。在旧的大型论坛启用此功能时要小心。
  • Access Token 在服务器端缓存,以实现更快的翻译。
  • 默认情况下,翻译速率限制为每分钟 3 次(管理员可以配置此值)

支持的翻译服务

配置步骤

Microsoft
  1. 按照 Azure 上的 Microsoft Translator API 中的步骤获取订阅密钥。您可以从任何可用的订阅优惠中选择。

  2. 在您的 Discourse 中,进入 管理员 > 设置 > 插件,输入您从上述步骤中获得的订阅密钥。

  1. 在您的 Discourse 中,进入 管理员 > 设置 > 基本设置,启用允许用户区域设置。
Google Translator
  1. 前往 https://console.developers.google.com

  2. 点击我的项目

  1. 点击 :heavy_plus_sign: 以创建新项目

  1. 输入项目名称并点击创建

  2. 选择 启用 API 并搜索 Google Cloud Translator API。找到 启用 按钮并点击它来启用该 API。请注意,Google Translator API 没有免费套餐,因此系统可能会提示您启用计费。

  3. 完成后,点击左侧菜单中的凭据

  1. 点击 创建凭据 并选择 API 密钥。复制 API 密钥并将其粘贴到 Discourse 中的 translator google api key 站点设置中。

  2. 在 Discourse 中,进入 管理员 > 设置 > 基本设置,启用允许用户区域设置。

设置

名称 描述
translator enabled 允许帖子的内联翻译。
translator 翻译服务的提供商。
translator azure subscription key Azure 订阅密钥
translator azure region Azure 区域
translator azure custom subdomain 如果使用 Azure Cognitive Services 的虚拟网络或防火墙,则需要此项。注意:仅输入自定义子域名,不要输入完整的自定义端点。
translator aws region AWS 区域
translator aws key id AWS 密钥 ID
translator aws secret access AWS 秘密访问密钥
translator aws iam role AWS IAM 角色
translator google api key Google API 密钥
translator yandex api key Yandex API 密钥
translator libretranslate endpoint LibreTranslate 端点
translator libretranslate api key LibreTranslate API 密钥
max translations per minute 普通用户每分钟可执行的翻译次数。
restrict translation by group 仅允许白名单中的组进行翻译
restrict translation by poster group 仅允许翻译白名单中用户发布的帖子

已知问题

  • 不翻译由 discourse-poll 插件生成的投票中的文本。
  • 翻译时图片会被放大。

:discourse2: 由我们托管? 此插件在我们的企业计划中可用。

103 个赞
Advice for bilingual communities
Inline translation of posts into another language
Language Translation
Can we have have one post with two different language
Plugin for signatures?
Translate plugin installed, but no translate button
LibreTranslate Plugin -- Free and Open Source Translation API
Discourse Translator plugin is not showing for non-logged in users
What exactly are the effects of "allow user locale"
DeepL integration for Translator plugin
How do you use Discourse AI? Tell us and make it even better!
How do I get the forum here in German
Is Google translate really so expensive?
Anyone migrated to version 3 of Microsoft Translator API yet?
Moving up the translator icon
Image zoom is not working
Translating text in polls
Yandex Translation Service
Anyone Using Discourse Translator Plugin on small forum, Cost/month?
FYI, Full translation of Discourse including posts is possible
Mute ALL other languages
How to install a plugin on Discourse-hosted-Discourse?
Make a multi-language forum
How to handle users that don't really read the answers they get?
Localized email templates
Translates to user's local language
DeepL integration for Translator plugin
Javascript pop up block help
No errors, instance not coming back up after rebuild
DeepL support for Discourse Translator
Getting user profile custom field via JS
Google Translate shows "blank" page
What exactly are the effects of "allow user locale"
Virtual Keyboard hides critical editor buttons for 3.3.0-beta
Translation from Lugandan yields uncaught 500 error (in a different Discourse)
Is Automatic Translation for Most Content Now Official?
Everything is translated, help!
Virtual Keyboard hides critical editor buttons for 3.3.0-beta
Translation support about the topic content
Translates to user's local language
Structuring a multilingual community
Translate email notifications and digests into user preferred locale language
Implementing In-House Translation Features on Discourse
Include translated posts in search?
Translate email notifications and digests into user preferred locale language
Changing default language will not change the site TITLE or DESCRIPTION!
Yandex Translation Service
Simple idea for translator-assisted bilingual forum
MKJ's Opinionated Discourse Deployment Configuration
Help which plugin is in the screenshot
Übersetzung wie hier auf Meta

帖子已拆分为新主题:我正在寻找这样的解决方案,以使用 LLM 翻译我论坛的热门帖子

一个帖子被拆分到一个新主题:为语言检测服务添加单独的配置选项

帖子已拆分为新主题:由 Discourse 托管的论坛是否使用 LibreTranslate 的本地实例?

我正在使用自托管的 LibreTranslate,它过去运行良好,但现在我收到了很多重复的“Job exception: The translator service is currently not available”(作业异常:翻译服务当前不可用)错误。我已检查 URL,它过去一直正常工作。如果我访问该 URL,LibreTranslate 网页会显示。由于我的 LibreTranslate 实例是私有的,没有互联网访问权限,因此不需要 API/令牌。

回溯显示:

Message (548 copies reported)

Job exception: The translator service is currently not available.

Backtrace

/var/www/discourse/plugins/discourse-translator/services/discourse_translator/libretranslate.rb:168:in `result'
/var/www/discourse/plugins/discourse-translator/services/discourse_translator/libretranslate.rb:85:in `detect'
/var/www/discourse/plugins/discourse-translator/plugin.rb:120:in `block in execute'
/var/www/discourse/lib/distributed_mutex.rb:53:in `block in synchronize'
/var/www/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:34:in `synchronize'
/var/www/discourse/plugins/discourse-translator/plugin.rb:119:in `execute'
/var/www/discourse/app/jobs/base.rb:305:in `block (2 levels) in perform'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management.rb:21:in `with_connection'
/var/www/discourse/app/jobs/base.rb:292:in `block in perform'
/var/www/discourse/app/jobs/base.rb:288:in `each'
/var/www/discourse/app/jobs/base.rb:288:in `perform'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:202:in `execute_job'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:170:in `block (2 levels) in process'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/middleware/chain.rb:177:in `block in invoke'
/var/www/discourse/lib/sidekiq/pausable.rb:132:in `call'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/middleware/chain.rb:179:in `block in invoke'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/middleware/chain.rb:182:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:169:in `block in process'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:136:in `block (6 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_retry.rb:113:in `local'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:135:in `block (5 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq.rb:44:in `block in <module:Sidekiq>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:131:in `block (4 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:263:in `stats'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:126:in `block (3 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_logger.rb:13:in `call'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:125:in `block (2 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_retry.rb:80:in `global'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:124:in `block in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_logger.rb:39:in `prepare'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:123:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:168:in `process'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:78:in `process_one'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:68:in `run'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/component.rb:8:in `watchdog'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/component.rb:17:in `block in safe_thread'

有什么想法可以解决这个问题吗?

2 个赞

‘Discourse’ 中尚无 ‘Hindi’ 区域设置选项。但 ‘Hindi’ 翻译可通过不同服务获得(我正在使用 ‘Microsoft Azure’)。

那么,如何在 Discourse 界面保持为英文的情况下,设置将所有/任何非 Hindi 帖子翻译成 ‘Hindi’ 呢?这是否可行?

1 个赞

我也尝试将此问题交叉发布到他们的 discourse 论坛。

3 个赞

我想考虑将此翻译器添加到我们的论坛。但我有两个主要顾虑:

1. 是否可以修改翻译?
我希望确保某些术语以特定方式翻译。为此,我需要能够查看可用翻译,并在必要时进行更改。

2. 帖子何时会被“重新翻译”?
一些论坛帖子会经常编辑。我该如何确保每一次修正的拼写错误都不会导致高昂的翻译费用?此外,我该如何确保新的更改能够准确地更新到翻译中?

3 个赞

我认为这可能不可行,因为您需要修改供应商(Microsoft/Google)的级别。除非翻译的内容受到单词替换功能的影响,否则您可以使用它。

不过,这里有一个功能请求

  1. 如果第一篇帖子不是英文,则自动将其翻译成英文。
  2. 提供一个按钮,可以一次性翻译整个帖子。
  3. 在用户级别为整个论坛启用自动翻译功能。也就是说,如果用户在其个人资料中选择他们只说罗马尼亚语,那么所有内容都将翻译成罗马尼亚语。如果他们选择说多种语言,则仅在帖子不是用这些语言撰写时才进行翻译。
2 个赞

作为网站管理员,我看到这个感到很惊讶:

这个隐藏的设置在哪里? :smiling_face_with_sunglasses:

1 个赞
./launcher enter app
rails c
SiteSetting.automatic_translation_backfill_rate = <wanted value>
exit
exit

但我认为在更新的版本中,它可能已经不存在了。

2 个赞

你是怎么学会这些的? :sweat_smile: 好的,谢谢!我会等团队的答复,以确保。

1 个赞

两种方式:使用搜索和 ask.discourse.com

3 个赞
3 个赞

标题为“已翻译主题”的通知似乎未在通知栏中翻译:

1 个赞

我的帖子也被错误地翻译成了另一种语言,通过一个链接?


在编辑器中查看,这是我实际写的内容:

我注意到翻译时 oneboxing 也不起作用。

1 个赞

您截图中的通知使用了您帖子主题的原始标题,因此目前它是“正确”的。我们将在未来确保通知(主题标题)被翻译。

至于上面的帖子,我们的机器翻译出现了问题,它被错误地检测为“西班牙语 (es)”,并且随后出现了错误的翻译。现在已经纠正。我们正在通过更好的翻译提示进行迭代。

2 个赞

我在安装 discourse-translator 插件时遇到了此错误。我的 discourse 版本是 3.5.0.beta1。

I, [2025-04-24T01:33:20.510994 #1]  INFO -- : cd /var/www/discourse & su discourse -c 'bundle exec rake db:migrate'
        82: from /usr/local/bin/bundle:25:in `<main>'
        81: from /usr/local/bin/bundle:25:in `load'
        80: from /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/exe/bundle:20:in `<top (required)>'
     ....
        10: from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
        9: from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/lazy_load_hooks.rb:94:in `block in execute_hook'
        8: from /var/www/discourse/config/application.rb:249:in `block in <class:Application>'
        7: from /var/www/discourse/lib/plugin.rb:6:in `initialization_guard'
        6: from /var/www/discourse/config/application.rb:249:in `block (2 levels) in <class:Application>'
        5: from /var/www/discourse/config/application.rb:249:in `each'
        4: from /var/www/discourse/lib/plugin/instance.rb:629:in `notify_after_initialize'
        3: from /var/www/discourse/lib/plugin/instance.rb:629:in `each'
        2: from /var/www/discourse/lib/plugin/instance.rb:631:in `block in notify_after_initialize'
        1: from /var/www/discourse/plugins/discourse-translator/plugin.rb:40:in `block in activate!'
/var/www/discourse/plugins/discourse-translator/lib/discourse_translator/inline_translation.rb:86:in `inject': protected method `register_topic_preloader_associations' called for an instance of Plugin::Instance (NoMethodError)

如何修复?

1 个赞

您好,可以通过在安装插件前先更新Discourse来减轻错误。

方法register_topic_preloader_associations已从受保护状态提升为公共状态。

4 个赞

谢谢,升级 Discourse 到最新版本后我成功安装了。

2 个赞