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
34 changes: 14 additions & 20 deletions assets/javascripts/discourse/components/translated-post.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,29 @@ export default class TranslatedPost extends Component {
return this.post.translatedTitle;
}

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

<template>
<div class="post-translation">
<ConditionalLoadingSpinner
class="post-translation"
@condition={{this.loading}}
@size="small"
>
{{#if this.showTranslation}}
<hr />
{{#if this.translatedTitle}}
<div class="topic-attribution">
{{this.translatedTitle}}
</div>
{{/if}}
<div class="post-attribution">
{{i18n
"translator.translated_from"
language=this.post.detectedLang
translator=this.siteSettings.translator_provider
}}
</div>
<div class="cooked">
{{htmlSafe this.post.translatedText}}
<hr />
{{#if this.translatedTitle}}
<div class="topic-attribution">
{{this.translatedTitle}}
</div>
{{/if}}
<div class="post-attribution">
{{i18n
"translator.translated_from"
language=this.post.detectedLang
translator=this.siteSettings.translator_provider
}}
</div>
<div class="cooked">
{{htmlSafe this.post.translatedText}}
</div>
</ConditionalLoadingSpinner>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,6 @@ function initializeTranslation(api) {
);
}

if (
siteSettings.experimental_inline_translation &&
(currentUser || siteSettings.experimental_anon_language_switcher)
) {
api.renderInOutlet("topic-navigation", ShowOriginalContent);

api.registerCustomPostMessageCallback(
"translated_post",
(topicController, data) => {
if (
new URLSearchParams(window.location.search).get("show") === "original"
) {
return;
}
const postStream = topicController.get("model.postStream");
postStream.triggerChangedPost(data.id, data.updated_at).then(() => {
topicController.appEvents.trigger("post-stream:refresh", {
id: data.id,
});
});
}
);

api.includePostAttributes("is_translated", "detected_language");
api.decorateWidget("post-date:before", (dec) => {
if (dec.attrs.is_translated && dec.attrs.detected_language) {
return new RenderGlimmer(
dec.widget,
"div.post-info.post-translated-indicator",
TranslatedPostIndicator,
{ detectedLanguage: dec.attrs.detected_language }
);
}
});
}

customizePostMenu(api);
}

Expand Down
10 changes: 0 additions & 10 deletions assets/javascripts/discourse/services/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ export default class TranslatorService extends Service {
post.detectedLang = response.detected_lang;
post.translatedText = response.translation;
post.translatedTitle = response.title_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);
this.documentTitle.setTitle(response.title_translation);
}
post.set("cooked", response.translation);
post.set("can_translate", false);
this.appEvents.trigger("post-stream:refresh", { id: post.id });
}
}

clearPostTranslation(post) {
Expand Down
1 change: 0 additions & 1 deletion config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ en:
errors:
needs_nonzero_backfill: "Automatic language translation requires the 'automatic_translation_backfill_rate' hidden setting to be a non-zero value. Please approach your site administrator to increase this limit."
experimental_anon_language_switcher_requirements: "The experimental language switcher requires the `set locale from cookie` site setting to be enabled, and the `automatic translation target languages` to have at least one language."
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:
Expand Down
3 changes: 0 additions & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ discourse_translator:
default: false
client: true
validator: "DiscourseTranslator::Validators::LanguageSwitcherSettingValidator"
experimental_inline_translation:
default: false
client: true
experimental_content_translation:
default: false
hidden: true
Expand Down
11 changes: 3 additions & 8 deletions lib/discourse_translator/extensions/guardian_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@ def can_translate?(post)
# this prevents the 🌐from appearing and then disappearing if the lang is same as user's lang
return false if post.updated_at > POST_DETECTION_BUFFER.ago && post.detected_locale.blank?

if SiteSetting.experimental_inline_translation
locale = DiscourseTranslator::InlineTranslation.effective_locale
return false if post.locale_matches?(locale)
post.translation_for(locale).nil?
else
return false if post.locale_matches?(I18n.locale)
poster_group_allow_translate?(post)
end
locale = I18n.locale
return false if post.locale_matches?(locale)
poster_group_allow_translate?(post)
end
end
end
Expand Down

This file was deleted.

100 changes: 0 additions & 100 deletions lib/discourse_translator/inline_translation.rb

This file was deleted.

15 changes: 0 additions & 15 deletions lib/discourse_translator/locale_matcher.rb

This file was deleted.

9 changes: 0 additions & 9 deletions lib/discourse_translator/locale_to_language.rb

This file was deleted.

3 changes: 0 additions & 3 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@ module ::DiscourseTranslator
Guardian.prepend(DiscourseTranslator::Extensions::GuardianExtension)
Post.prepend(DiscourseTranslator::Extensions::PostExtension)
Topic.prepend(DiscourseTranslator::Extensions::TopicExtension)
TopicViewSerializer.prepend(DiscourseTranslator::Extensions::TopicViewSerializerExtension)
end

add_to_serializer :post, :can_translate do
scope.can_translate?(object)
end

DiscourseTranslator::ParallelTextTranslation.new.inject(self)
DiscourseTranslator::InlineTranslation.new.inject(self)

DiscourseTranslator::AutomaticTranslations.new.inject(self)
end
Loading
Loading