@@ -21,22 +21,21 @@ export const translateJobHandler = async (params: z.infer<typeof translateJobSch
2121 region : process . env . AWS_REGION || 'ap-northeast-1' ,
2222 } ) ;
2323
24- // Translate the title from English to Japanese
25- const translateParams : TranslateTextCommandInput = {
26- Text : todoItem . title ,
27- SourceLanguageCode : 'auto' ,
28- TargetLanguageCode : 'ja' ,
29- } ;
30-
31- const translateCommand = new TranslateTextCommand ( translateParams ) ;
32- const translateResult = await translateClient . send ( translateCommand ) ;
24+ const targetLanguage = 'ja' ;
25+ const translateResult = await translateClient . send (
26+ new TranslateTextCommand ( {
27+ Text : todoItem . title ,
28+ SourceLanguageCode : 'auto' ,
29+ TargetLanguageCode : targetLanguage ,
30+ } ) ,
31+ ) ;
3332
3433 if ( translateResult . TranslatedText ) {
3534 // Create a new todo item with the translated title
3635 const translatedTodoItem = await prisma . todoItem . create ( {
3736 data : {
3837 title : translateResult . TranslatedText ,
39- description : `Translated from: ${ todoItem . title } (detected language: ${ translateResult . SourceLanguageCode } )` ,
38+ description : `Translated from: ${ todoItem . title } (from ${ translateResult . SourceLanguageCode } to ${ targetLanguage } )` ,
4039 userId : params . userId ,
4140 status : todoItem . status ,
4241 } ,
@@ -45,5 +44,5 @@ export const translateJobHandler = async (params: z.infer<typeof translateJobSch
4544 console . log ( `Created translated todo item: ${ translatedTodoItem . id } ` ) ;
4645 }
4746
48- await sendEvent ( `${ params . userId } /jobs` , { type : 'completed' } ) ;
47+ await sendEvent ( `user/ ${ params . userId } /jobs` , { type : 'completed' } ) ;
4948} ;
0 commit comments