discourse-translator/assets/javascripts/discourse/components/translated-post.gjs
Natalie Tay 95a5cfe304
DEV: Cleanup terms (#232)
Doing some cleanup
- `experimental_topic_translation` becomes `experimental_inline_translation`
- `translator` becomes `translator_provider`
- DualText translation is now Parallel Translation (the feature where translation is appended to the post, rather than shown inline)
- Unused `translate_posts_to_languages` removed
2025-02-27 17:40:56 +08:00

66 lines
1.6 KiB
Text

import Component from "@glimmer/component";
import { service } from "@ember/service";
import { htmlSafe } from "@ember/template";
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
import { i18n } from "discourse-i18n";
export default class TranslatedPost extends Component {
static shouldRender(args) {
return args.post.isTranslated || args.post.isTranslating;
}
@service siteSettings;
get loading() {
return this.post.isTranslating;
}
get isTranslated() {
return this.post.isTranslated;
}
get post() {
return this.args.outletArgs.post;
}
get translatedText() {
return this.post.translatedText;
}
get translatedTitle() {
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}}
</div>
{{/if}}
</ConditionalLoadingSpinner>
</div>
</template>
}