1- import { tracked } from "@glimmer/tracking" ;
21import { ajax } from "discourse/lib/ajax" ;
32import { popupAjaxError } from "discourse/lib/ajax-error" ;
43import { withPluginApi } from "discourse/lib/plugin-api" ;
54import { withSilencedDeprecations } from "discourse-common/lib/deprecated" ;
6- import I18n from "I18n " ;
5+ import { i18n } from "discourse-i18n " ;
76import ToggleTranslationButton from "../components/post-menu/toggle-translation-button" ;
87import TranslatedPost from "../components/translated-post" ;
98
@@ -27,19 +26,13 @@ function customizePostMenu(api, container) {
2726 ) ;
2827
2928 if ( transformerRegistered ) {
30- // the plugin outlet is not updated when the post instance is modified unless we extend it to add the tracking to
31- // the new properties
32- api . modifyClass (
33- "model:post" ,
34- ( Superclass ) =>
35- class extends Superclass {
36- @tracked detectedLang ;
37- @tracked isTranslating ;
38- @tracked isTranslated ;
39- @tracked translatedText ;
40- @tracked translatedTitle ;
41- }
42- ) ;
29+ // the plugin outlet is not updated when the post instance is modified unless we register the new properties as
30+ // tracked
31+ api . addTrackedPostProperty ( "detectedLang" ) ;
32+ api . addTrackedPostProperty ( "isTranslating" ) ;
33+ api . addTrackedPostProperty ( "isTranslated" ) ;
34+ api . addTrackedPostProperty ( "translatedText" ) ;
35+ api . addTrackedPostProperty ( "translatedTitle" ) ;
4336
4437 api . renderBeforeWrapperOutlet ( "post-menu" , TranslatedPost ) ;
4538 }
@@ -86,7 +79,7 @@ function customizeWidgetPostMenu(api) {
8679 ...titleElements ,
8780 dec . h (
8881 "div.post-attribution" ,
89- I18n . t ( "translator.translated_from" , { language, translator } )
82+ i18n ( "translator.translated_from" , { language, translator } )
9083 ) ,
9184 dec . cooked ( dec . attrs . translated_text ) ,
9285 ] ) ;
0 commit comments