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,18 +26,14 @@ 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- }
29+ // the plugin outlet is not updated when the post instance is modified unless we register the new properties as
30+ // tracked
31+ api . addTrackedPostProperties (
32+ "detectedLang" ,
33+ "isTranslating" ,
34+ "isTranslated" ,
35+ "translatedText" ,
36+ "translatedTitle"
4237 ) ;
4338
4439 api . renderBeforeWrapperOutlet ( "post-menu" , TranslatedPost ) ;
@@ -86,7 +81,7 @@ function customizeWidgetPostMenu(api) {
8681 ...titleElements ,
8782 dec . h (
8883 "div.post-attribution" ,
89- I18n . t ( "translator.translated_from" , { language, translator } )
84+ i18n ( "translator.translated_from" , { language, translator } )
9085 ) ,
9186 dec . cooked ( dec . attrs . translated_text ) ,
9287 ] ) ;
@@ -151,6 +146,6 @@ function customizeWidgetPostMenu(api) {
151146export default {
152147 name : "extend-for-translate-button" ,
153148 initialize ( ) {
154- withPluginApi ( "1.34.0 " , ( api ) => initializeTranslation ( api ) ) ;
149+ withPluginApi ( "1.39.2 " , ( api ) => initializeTranslation ( api ) ) ;
155150 } ,
156151} ;
0 commit comments