@@ -29,11 +29,36 @@ export function registerShortcuts(app: App) {
2929 multiline : true ,
3030 placeholder : {
3131 type : "plain_text" ,
32- text : "Enter text to translate to English ..." ,
32+ text : "Enter text to translate..." ,
3333 } ,
3434 } ,
3535 label : { type : "plain_text" , text : "Text" } ,
3636 } ,
37+ {
38+ type : "input" ,
39+ block_id : "language_selection_block" ,
40+ element : {
41+ type : "static_select" ,
42+ action_id : "language_selection" ,
43+ initial_option : {
44+ text : { type : "plain_text" , text : "English" } ,
45+ value : "English" ,
46+ } ,
47+ options : [
48+ { text : { type : "plain_text" , text : "English" } , value : "English" } ,
49+ { text : { type : "plain_text" , text : "Spanish" } , value : "Spanish" } ,
50+ { text : { type : "plain_text" , text : "French" } , value : "French" } ,
51+ { text : { type : "plain_text" , text : "German" } , value : "German" } ,
52+ { text : { type : "plain_text" , text : "Chinese" } , value : "Chinese" } ,
53+ { text : { type : "plain_text" , text : "Japanese" } , value : "Japanese" } ,
54+ { text : { type : "plain_text" , text : "Korean" } , value : "Korean" } ,
55+ { text : { type : "plain_text" , text : "Portuguese" } , value : "Portuguese" } ,
56+ { text : { type : "plain_text" , text : "Italian" } , value : "Italian" } ,
57+ { text : { type : "plain_text" , text : "Russian" } , value : "Russian" } ,
58+ ] ,
59+ } ,
60+ label : { type : "plain_text" , text : "Target Language" } ,
61+ } ,
3762 ] ,
3863 } ,
3964 } ) ;
@@ -69,11 +94,36 @@ export function registerShortcuts(app: App) {
6994 initial_value : messageText ,
7095 placeholder : {
7196 type : "plain_text" ,
72- text : "Enter text to translate to English ..." ,
97+ text : "Enter text to translate..." ,
7398 } ,
7499 } ,
75100 label : { type : "plain_text" , text : "Text" } ,
76101 } ,
102+ {
103+ type : "input" ,
104+ block_id : "language_selection_block" ,
105+ element : {
106+ type : "static_select" ,
107+ action_id : "language_selection" ,
108+ initial_option : {
109+ text : { type : "plain_text" , text : "English" } ,
110+ value : "English" ,
111+ } ,
112+ options : [
113+ { text : { type : "plain_text" , text : "English" } , value : "English" } ,
114+ { text : { type : "plain_text" , text : "Spanish" } , value : "Spanish" } ,
115+ { text : { type : "plain_text" , text : "French" } , value : "French" } ,
116+ { text : { type : "plain_text" , text : "German" } , value : "German" } ,
117+ { text : { type : "plain_text" , text : "Chinese" } , value : "Chinese" } ,
118+ { text : { type : "plain_text" , text : "Japanese" } , value : "Japanese" } ,
119+ { text : { type : "plain_text" , text : "Korean" } , value : "Korean" } ,
120+ { text : { type : "plain_text" , text : "Portuguese" } , value : "Portuguese" } ,
121+ { text : { type : "plain_text" , text : "Italian" } , value : "Italian" } ,
122+ { text : { type : "plain_text" , text : "Russian" } , value : "Russian" } ,
123+ ] ,
124+ } ,
125+ label : { type : "plain_text" , text : "Target Language" } ,
126+ } ,
77127 ] ,
78128 } ,
79129 } ) ;
@@ -82,6 +132,8 @@ export function registerShortcuts(app: App) {
82132 app . view ( "rosetta_translate_modal" , async ( { ack, view, client, body } ) => {
83133 const input =
84134 view . state . values ?. [ "translate_input_block" ] ?. [ "translate_input" ] ?. value ?? "" ;
135+ const targetLanguage =
136+ view . state . values ?. [ "language_selection_block" ] ?. [ "language_selection" ] ?. selected_option ?. value ?? "English" ;
85137
86138 const { channelId, threadTs } = JSON . parse ( view . private_metadata || "{}" ) ;
87139
@@ -97,7 +149,7 @@ export function registerShortcuts(app: App) {
97149
98150 await ack ( ) ;
99151
100- const translated = await translate ( input ) ;
152+ const translated = await translate ( input , targetLanguage ) ;
101153
102154 try {
103155 await client . chat . postMessage ( {
0 commit comments