Skip to content

Commit 6bd2738

Browse files
authored
DEV: Entirely remove inline translations (#294)
1 parent 79bbc03 commit 6bd2738

23 files changed

+37
-1150
lines changed

assets/javascripts/discourse/components/translated-post.gjs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,29 @@ export default class TranslatedPost extends Component {
3131
return this.post.translatedTitle;
3232
}
3333

34-
get showTranslation() {
35-
return !this.siteSettings.experimental_inline_translation;
36-
}
37-
3834
<template>
3935
<div class="post-translation">
4036
<ConditionalLoadingSpinner
4137
class="post-translation"
4238
@condition={{this.loading}}
4339
@size="small"
4440
>
45-
{{#if this.showTranslation}}
46-
<hr />
47-
{{#if this.translatedTitle}}
48-
<div class="topic-attribution">
49-
{{this.translatedTitle}}
50-
</div>
51-
{{/if}}
52-
<div class="post-attribution">
53-
{{i18n
54-
"translator.translated_from"
55-
language=this.post.detectedLang
56-
translator=this.siteSettings.translator_provider
57-
}}
58-
</div>
59-
<div class="cooked">
60-
{{htmlSafe this.post.translatedText}}
41+
<hr />
42+
{{#if this.translatedTitle}}
43+
<div class="topic-attribution">
44+
{{this.translatedTitle}}
6145
</div>
6246
{{/if}}
47+
<div class="post-attribution">
48+
{{i18n
49+
"translator.translated_from"
50+
language=this.post.detectedLang
51+
translator=this.siteSettings.translator_provider
52+
}}
53+
</div>
54+
<div class="cooked">
55+
{{htmlSafe this.post.translatedText}}
56+
</div>
6357
</ConditionalLoadingSpinner>
6458
</div>
6559
</template>

assets/javascripts/discourse/initializers/extend-for-translate-button.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,6 @@ function initializeTranslation(api) {
2626
);
2727
}
2828

29-
if (
30-
siteSettings.experimental_inline_translation &&
31-
(currentUser || siteSettings.experimental_anon_language_switcher)
32-
) {
33-
api.renderInOutlet("topic-navigation", ShowOriginalContent);
34-
35-
api.registerCustomPostMessageCallback(
36-
"translated_post",
37-
(topicController, data) => {
38-
if (
39-
new URLSearchParams(window.location.search).get("show") === "original"
40-
) {
41-
return;
42-
}
43-
const postStream = topicController.get("model.postStream");
44-
postStream.triggerChangedPost(data.id, data.updated_at).then(() => {
45-
topicController.appEvents.trigger("post-stream:refresh", {
46-
id: data.id,
47-
});
48-
});
49-
}
50-
);
51-
52-
api.includePostAttributes("is_translated", "detected_language");
53-
api.decorateWidget("post-date:before", (dec) => {
54-
if (dec.attrs.is_translated && dec.attrs.detected_language) {
55-
return new RenderGlimmer(
56-
dec.widget,
57-
"div.post-info.post-translated-indicator",
58-
TranslatedPostIndicator,
59-
{ detectedLanguage: dec.attrs.detected_language }
60-
);
61-
}
62-
});
63-
}
64-
6529
customizePostMenu(api);
6630
}
6731

assets/javascripts/discourse/services/translator.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ export default class TranslatorService extends Service {
1515
post.detectedLang = response.detected_lang;
1616
post.translatedText = response.translation;
1717
post.translatedTitle = response.title_translation;
18-
if (this.siteSettings.experimental_inline_translation) {
19-
if (post.post_number === 1) {
20-
post.topic.set("fancy_title", response.title_translation);
21-
this.appEvents.trigger("header:update-topic", post.topic);
22-
this.documentTitle.setTitle(response.title_translation);
23-
}
24-
post.set("cooked", response.translation);
25-
post.set("can_translate", false);
26-
this.appEvents.trigger("post-stream:refresh", { id: post.id });
27-
}
2818
}
2919

3020
clearPostTranslation(post) {

config/locales/server.en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ en:
2121
errors:
2222
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."
2323
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."
24-
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."
2524
automatic_translation_target_languages: "The languages to automatically translate user content (posts, topics) to. If empty, no languages will be automatically translated."
2625
translator:
2726
failed:

config/settings.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ discourse_translator:
126126
default: false
127127
client: true
128128
validator: "DiscourseTranslator::Validators::LanguageSwitcherSettingValidator"
129-
experimental_inline_translation:
130-
default: false
131-
client: true
132129
experimental_content_translation:
133130
default: false
134131
hidden: true

lib/discourse_translator/extensions/guardian_extension.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,9 @@ def can_translate?(post)
3131
# this prevents the 🌐from appearing and then disappearing if the lang is same as user's lang
3232
return false if post.updated_at > POST_DETECTION_BUFFER.ago && post.detected_locale.blank?
3333

34-
if SiteSetting.experimental_inline_translation
35-
locale = DiscourseTranslator::InlineTranslation.effective_locale
36-
return false if post.locale_matches?(locale)
37-
post.translation_for(locale).nil?
38-
else
39-
return false if post.locale_matches?(I18n.locale)
40-
poster_group_allow_translate?(post)
41-
end
34+
locale = I18n.locale
35+
return false if post.locale_matches?(locale)
36+
poster_group_allow_translate?(post)
4237
end
4338
end
4439
end

lib/discourse_translator/extensions/topic_view_serializer_extension.rb

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/discourse_translator/inline_translation.rb

Lines changed: 0 additions & 100 deletions
This file was deleted.

lib/discourse_translator/locale_matcher.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

lib/discourse_translator/locale_to_language.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)