Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/discourse_translator/translator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def translate
begin
title_json = {}
detected_lang, translation =
"DiscourseTranslator::#{SiteSetting.translator}".constantize.translate(post)
"DiscourseTranslator::#{SiteSetting.translator_provider}".constantize.translate(post)
if post.is_first_post?
_, title_translation =
"DiscourseTranslator::#{SiteSetting.translator}".constantize.translate(post.topic)
"DiscourseTranslator::#{SiteSetting.translator_provider}".constantize.translate(
post.topic,
)
title_json = { title_translation: title_translation }
end
render json: { translation: translation, detected_lang: detected_lang }.merge(title_json),
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/regular/detect_translatable_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def execute(args)
translatable = args[:type].constantize.find_by(id: args[:translatable_id])
return if translatable.blank?
begin
translator = "DiscourseTranslator::#{SiteSetting.translator}".constantize
translator = "DiscourseTranslator::#{SiteSetting.translator_provider}".constantize
translator.detect(translatable)
rescue ::DiscourseTranslator::ProblemCheckedTranslationError
# problem-checked translation errors gracefully
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/regular/translate_translatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def execute(args)

target_locales = SiteSetting.automatic_translation_target_languages.split("|")
target_locales.each do |target_locale|
"DiscourseTranslator::#{SiteSetting.translator}".constantize.translate(
"DiscourseTranslator::#{SiteSetting.translator_provider}".constantize.translate(
translatable,
target_locale.to_sym,
)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/scheduled/automatic_translation_backfill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def backfill_locales
end

def translator
@translator_klass ||= "DiscourseTranslator::#{SiteSetting.translator}".constantize
@translator_klass ||= "DiscourseTranslator::#{SiteSetting.translator_provider}".constantize
end

def translate_records(type, record_ids)
Expand Down
2 changes: 1 addition & 1 deletion app/services/discourse_translator/discourse_ai.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.translate!(translatable, target_locale_sym = I18n.locale)
private

def self.required_settings_enabled
SiteSetting.translator_enabled && SiteSetting.translator == "DiscourseAi" &&
SiteSetting.translator_enabled && SiteSetting.translator_provider == "DiscourseAi" &&
SiteSetting.discourse_ai_enabled && SiteSetting.ai_helper_enabled
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/services/problem_check/missing_translator_api_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def call

def translation_data
{
provider: SiteSetting.translator,
provider: SiteSetting.translator_provider,
key: I18n.t("site_settings.#{api_key_site_setting_name}"),
key_name: api_key_site_setting_name,
}
end

def api_key_site_setting_name
case SiteSetting.translator
case SiteSetting.translator_provider
when "Google"
"translator_google_api_key"
when "Microsoft"
Expand Down
4 changes: 2 additions & 2 deletions assets/javascripts/discourse/components/translated-post.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class TranslatedPost extends Component {
}

get showTranslation() {
return !this.siteSettings.experimental_topic_translation;
return !this.siteSettings.experimental_inline_translation;
}

<template>
Expand All @@ -53,7 +53,7 @@ export default class TranslatedPost extends Component {
{{i18n
"translator.translated_from"
language=this.post.detectedLang
translator=this.siteSettings.translator
translator=this.siteSettings.translator_provider
}}
</div>
<div class="cooked">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function initializeTranslation(api) {
}

if (
siteSettings.experimental_topic_translation &&
siteSettings.experimental_inline_translation &&
(currentUser || siteSettings.experimental_anon_language_switcher)
) {
api.renderInOutlet("topic-navigation", ShowOriginalContent);
Expand Down Expand Up @@ -83,7 +83,7 @@ function customizeWidgetPostMenu(api) {
}

const language = dec.attrs.detected_lang;
const translator = siteSettings.translator;
const translator = siteSettings.translator_provider;

let titleElements = [];

Expand Down
2 changes: 1 addition & 1 deletion assets/javascripts/discourse/services/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class TranslatorService extends Service {
post.detectedLang = response.detected_lang;
post.translatedText = response.translation;
post.translatedTitle = response.title_translation;
if (this.siteSettings.experimental_topic_translation) {
if (this.siteSettings.experimental_inline_translation) {
if (post.post_number === 1) {
post.topic.set("fancy_title", response.title_translation);
this.appEvents.trigger("header:update-topic", post.topic);
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ar:
site_settings:
translator_enabled: "السماح بالترجمة المضمَّنة للمنشورات."
translator: "مقدِّم خدمة الترجمة."
translator_provider: "مقدِّم خدمة الترجمة."
translator_azure_subscription_key: "مفتاح اشتراك Azure"
translator_azure_region: "منطقة Azure"
translator_google_api_key: "مفتاح واجهة برمجة تطبيقات Google"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cs:
site_settings:
translator_enabled: "Povolit vložený překlad příspěvků."
translator: "Poskytovatel překladatelské služby."
translator_provider: "Poskytovatel překladatelské služby."
translator_azure_subscription_key: "Klíč předplatného Azure"
translator_azure_region: "Azure Region"
translator_google_api_key: "Klíč Google API"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
de:
site_settings:
translator_enabled: "Inline-Übersetzung von Beiträgen erlauben."
translator: "Der Anbieter des Übersetzungsdienstes."
translator_provider: "Der Anbieter des Übersetzungsdienstes."
translator_azure_subscription_key: "Azure-Abonnementschlüssel"
translator_azure_region: "Azure-Region"
translator_google_api_key: "Google-API-Schlüssel"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.el.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
el:
site_settings:
translator_enabled: "Αποδοχή ενσωματωμένης μετάφρασης των αναρτήσεων."
translator: "Ο πάροχος της μεταφραστικής υπηρεσίας."
translator_provider: "Ο πάροχος της μεταφραστικής υπηρεσίας."
translator_azure_subscription_key: "Κλειδί Συνδρομής Azure"
translator_azure_region: "Περιοχή Azure"
translator_google_api_key: "Κλειδί API Google"
Expand Down
6 changes: 3 additions & 3 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
en:
site_settings:
translator_enabled: "Allow inline translation of posts."
translator: "The provider of the translation service."
translator_provider: "The provider of the translation service."
translator_azure_subscription_key: "Azure Subscription Key"
translator_azure_region: "Azure Region"
translator_google_api_key: "Google API Key"
Expand All @@ -18,10 +18,10 @@ en:
restrict_translation_by_group: "Only allowed groups can translate"
restrict_translation_by_poster_group: "Only allow translation of posts made by users in allowed groups. If empty, allow translations of posts from all users."
experimental_anon_language_switcher: "Enable experimental language switcher for anonymous users. This will allow anonymous users to switch between translated versions of Discourse and user-contributed content in topics."
translate_posts_to_languages: "Translate posts to languages"
errors:
set_locale_cookie_requirements: "The experimental language switcher for anonymous users requires the `set locale from cookie` site setting to be enabled."
experimental_topic_translation: "Enable experimental topic translation feature. This replaces existing post in-line translation with a button that allows users to translate the entire topic."
experimental_inline_translation: "Enable experimental inline translation feature. This replaces existing parallel translation, allowing site visitors with a non-default locale to view content in their language."
automatic_translation_target_languages: "The languages to automatically translate user content (posts, topics) to. If empty, no languages will be automatically translated."
translator:
failed: "The translator is unable to translate this content (%{source_locale}) to the default language of this site (%{target_locale})."
not_supported: "This language is not supported by the translator."
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
es:
site_settings:
translator_enabled: "Permitir la traducción en línea de las publicaciones."
translator: "El proveedor del servicio de traducción."
translator_provider: "El proveedor del servicio de traducción."
translator_azure_subscription_key: "Clave de suscripción de Azure"
translator_azure_region: "Región de Azure"
translator_google_api_key: "Clave API de Google"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.fa_IR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
fa_IR:
site_settings:
translator_enabled: "اجازه ترجمه درون خطی نوشته‌ها را بدهید."
translator: "ارائه دهنده خدمات ترجمه"
translator_provider: "ارائه دهنده خدمات ترجمه"
translator_azure_subscription_key: "کلید اشتراک Azure"
translator_azure_region: "منطقه Azure"
translator_google_api_key: "کلید API گوگل"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.fi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
fi:
site_settings:
translator_enabled: "Salli viestien käännökset niiden yhteydessä."
translator: "Käännöspalveluntarjoaja."
translator_provider: "Käännöspalveluntarjoaja."
translator_azure_subscription_key: "Azure Subscription Key -tilaustunniste"
translator_azure_region: "Azure-alue"
translator_google_api_key: "Googlen API-avain"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
fr:
site_settings:
translator_enabled: "Autoriser la traduction en ligne des messages."
translator: "Le fournisseur du service de traduction."
translator_provider: "Le fournisseur du service de traduction."
translator_azure_subscription_key: "Clé d'abonnement Azure"
translator_azure_region: "Région Azure"
translator_google_api_key: "Clé d'API Google"
Expand Down
5 changes: 2 additions & 3 deletions config/locales/server.he.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
he:
site_settings:
translator_enabled: "לאפשר תרגום מוטבע של פוסטים."
translator: "ספק שירות התרגום."
translator_provider: "ספק שירות התרגום."
translator_azure_subscription_key: "מפתח מינוי ל־Azure"
translator_azure_region: "אזור ב־Azure"
translator_google_api_key: "מפתח API של Google"
Expand All @@ -24,10 +24,9 @@ he:
restrict_translation_by_group: "רק קבוצות מורשות יכולות לתרגם"
restrict_translation_by_poster_group: "לאפשר תרגום של פוסטים שנוצרו על ידי משתמשים בקבוצות מורשות בלבד. אם ריק, לאפשר תרגומים של פוסטים מכל המשתמשים."
experimental_anon_language_switcher: "הפעלת בורר שפות ניסיוני למשתמשים אלמוניים. כך יוכלו משתמשים אלמוניים להחליף בין הגרסה המתורגמת של Discourse לבין התוכן שתרמו המשתמשים לנושאים."
translate_posts_to_languages: "תרגום פוסטים לשפות"
errors:
set_locale_cookie_requirements: "בורר השפה הניסיוני למשתמשים אלמוניים דורש שהגדרת האתר `set locale from cookie` (הגדרת השפה מעוגייה) תהיה פעילה."
experimental_topic_translation: "הפעלת יכולת תרגום נושאים ניסיונית. היא מחליפה את התרגום הפנימי של הפוסטים בכפתור שמאפשר למשתמשים לתרגם את הנושא כולו."
experimental_inline_translation: "הפעלת יכולת תרגום נושאים ניסיונית. היא מחליפה את התרגום הפנימי של הפוסטים בכפתור שמאפשר למשתמשים לתרגם את הנושא כולו."
translator:
failed: "המתרגם לא מסוגל לתרגם את התוכן הזה (%{source_locale}) לשפת ברירת המחדל של האתר הזה (%{target_locale})."
not_supported: "שפה זו אינה נתמכת על ידי המתרגם."
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.hu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
hu:
site_settings:
translator_enabled: "Bejegyzések szövegközi fordításának engedélyezése."
translator: "A fordítási szolgáltatás szolgáltatója."
translator_provider: "A fordítási szolgáltatás szolgáltatója."
translator_azure_subscription_key: "Azure előfizetési kulcs"
translator_azure_region: "Azure régió"
translator_google_api_key: "Google API kulcs"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
it:
site_settings:
translator_enabled: "Consenti la traduzione in linea dei messaggi."
translator: "Il fornitore del servizio di traduzione."
translator_provider: "Il fornitore del servizio di traduzione."
translator_azure_subscription_key: "Chiave di sottoscrizione Azure"
translator_azure_region: "Regione Azure"
translator_google_api_key: "Chiave API Google"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ja:
site_settings:
translator_enabled: "投稿のインライン翻訳を許可する。"
translator: "翻訳サービスのプロバイダー。"
translator_provider: "翻訳サービスのプロバイダー。"
translator_azure_subscription_key: "Azure サブスクリプションキー"
translator_azure_region: "Azure リージョン"
translator_google_api_key: "Google API キー"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
nl:
site_settings:
translator_enabled: "Sta inline vertaling van berichten toe."
translator: "De aanbieder van de vertaaldienst."
translator_provider: "De aanbieder van de vertaaldienst."
translator_azure_subscription_key: "Azure-abonnementssleutel"
translator_azure_region: "Azure-regio"
translator_google_api_key: "Google API-sleutel"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.pl_PL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pl_PL:
site_settings:
translator_enabled: "Zezwalaj na wbudowane tłumaczenie postów."
translator: "Dostawca usług tłumaczeniowych."
translator_provider: "Dostawca usług tłumaczeniowych."
translator_azure_subscription_key: "Klucz subskrypcji Azure"
translator_azure_region: "Region Azure"
translator_google_api_key: "Klucz API Google"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.pt_BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pt_BR:
site_settings:
translator_enabled: "Permitir tradução embutida de postagens."
translator: "O provedor do serviço de tradução."
translator_provider: "O provedor do serviço de tradução."
translator_azure_subscription_key: "Chave de Assinatura do Azure"
translator_azure_region: "Região do Azure"
translator_google_api_key: "Chave de API do Google"
Expand Down
5 changes: 2 additions & 3 deletions config/locales/server.ro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ro:
site_settings:
translator_enabled: "Permite traducerea în linie a articolelor."
translator: "Furnizorul serviciului de traducere."
translator_provider: "Furnizorul serviciului de traducere."
translator_azure_subscription_key: "Cheie de abonament Azure"
translator_azure_region: "Regiune Azure"
translator_google_api_key: "Cheie API Google"
Expand All @@ -24,10 +24,9 @@ ro:
restrict_translation_by_group: "Doar grupurile permise pot traduce"
restrict_translation_by_poster_group: "Permite traducerea numai a articolelor făcute de utilizatorii din grupurile permise. Dacă este gol, permite traducerea articolelor de la toți utilizatorii."
experimental_anon_language_switcher: "Activează comutatorul experimental de limbi pentru utilizatorii anonimi. Acest lucru va permite utilizatorilor anonimi să comute între versiunile traduse ale Discourse și conținutul la care au contribuit utilizatorii în subiecte."
translate_posts_to_languages: "Tradu postări în limbi"
errors:
set_locale_cookie_requirements: "Comutatorul experimental de limbă pentru utilizatori anonimi necesită activarea setării site-ului „Setează locală din cookie”."
experimental_topic_translation: "Activează funcționalitatea de traducere experimentală a subiectului. Aceasta înlocuiește traducerea curentă existentă a postării în-linie cu un buton care permite utilizatorilor să traducă întregul subiect."
experimental_inline_translation: "Activează funcționalitatea de traducere experimentală a subiectului. Aceasta înlocuiește traducerea curentă existentă a postării în-linie cu un buton care permite utilizatorilor să traducă întregul subiect."
translator:
failed: "Traducătorul nu este în măsură să traducă acest conținut (%{source_locale}) în limba implicită a acestui site (%{target_locale})."
not_supported: "Această limbă nu este acceptată de traducător."
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ru:
site_settings:
translator_enabled: "Разрешить встроенный перевод записей."
translator: "Поставщик услуг перевода."
translator_provider: "Поставщик услуг перевода."
translator_azure_subscription_key: "Ключ подписки Azure"
translator_azure_region: "Регион Azure"
translator_google_api_key: "Ключ API Google"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sv:
site_settings:
translator_enabled: "Tillåt inbäddad översättning av inlägg."
translator: "Leverantören av översättningstjänsten."
translator_provider: "Leverantören av översättningstjänsten."
translator_azure_subscription_key: "Azure -prenumerationsnyckel"
translator_azure_region: "Azure-region"
translator_google_api_key: "Google API-nyckel"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.tr_TR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tr_TR:
site_settings:
translator_enabled: "Gönderilerin satır içi çevirisine izin verin."
translator: "Çeviri hizmetinin sağlayıcısı."
translator_provider: "Çeviri hizmetinin sağlayıcısı."
translator_azure_subscription_key: "Azure Abonelik Anahtarı"
translator_azure_region: "Azure Region"
translator_google_api_key: "Google API Anahtarı"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.zh_CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
zh_CN:
site_settings:
translator_enabled: "允许帖子内嵌翻译。"
translator: "翻译服务提供商。"
translator_provider: "翻译服务提供商。"
translator_azure_subscription_key: "Azure 订阅密钥"
translator_azure_region: "Azure 区域"
translator_google_api_key: "Google API 密钥"
Expand Down
24 changes: 12 additions & 12 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ discourse_translator:
translator_enabled:
default: false
client: true
translator:
translator_provider:
default: 'Microsoft'
client: true
type: enum
Expand All @@ -14,6 +14,16 @@ discourse_translator:
- Yandex
- LibreTranslate
validator: "DiscourseTranslator::TranslatorSelectionValidator"
automatic_translation_target_languages:
default: ""
type: list
list_type: named
choices: "DiscourseTranslator::TranslatableLanguagesSetting.values"
allow_any: false
automatic_translation_backfill_maximum_translations_per_hour:
default: 0
client: false
hidden: true
translator_azure_subscription_key:
default: ''
translator_azure_region:
Expand Down Expand Up @@ -106,16 +116,6 @@ discourse_translator:
default: false
client: true
validator: "LanguageSwitcherSettingValidator"
experimental_topic_translation:
experimental_inline_translation:
default: false
client: true
automatic_translation_target_languages:
default: ""
type: list
list_type: named
choices: "DiscourseTranslator::TranslatableLanguagesSetting.values"
allow_any: false
automatic_translation_backfill_maximum_translations_per_hour:
default: 0
client: false
hidden: true
Loading
Loading