File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
projects/packages/text-transformer Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -2434,7 +2434,7 @@ https://github.com/Avivbens/alfredo</string>
24342434 </dict >
24352435 </array >
24362436 <key >version </key >
2437- <string >5.4.0 </string >
2437+ <string >5.4.1 </string >
24382438 <key >webaddress </key >
24392439 <string >https://github.com/Avivbens/alfredo </string >
24402440 </dict >
Original file line number Diff line number Diff line change @@ -22,13 +22,16 @@ interface ParsedTranslationInput {
2222function parseLanguageFromInput ( input : string ) : ParsedTranslationInput {
2323 const trimmedInput = input . trim ( ) ;
2424
25- const pattern = new RegExp ( `^([^ ${ LANGUAGE_DELIMITER } ]+) ${ LANGUAGE_DELIMITER } \\s*(.*)$` ) ;
26- const match = trimmedInput . match ( pattern ) ;
25+ const hasDelimiter = trimmedInput . includes ( LANGUAGE_DELIMITER ) ;
26+ const [ targetLanguage , ... textParts ] = trimmedInput . split ( LANGUAGE_DELIMITER ) ;
2727
28- if ( match && match [ 1 ] && match [ 2 ] ) {
28+ /**
29+ * If delimiter is found and target language is specified
30+ */
31+ if ( hasDelimiter && targetLanguage ) {
2932 return {
30- targetLanguage : match [ 1 ] . trim ( ) ,
31- textToTranslate : match [ 2 ] ,
33+ targetLanguage : targetLanguage . trim ( ) ,
34+ textToTranslate : textParts . join ( LANGUAGE_DELIMITER ) . trim ( ) ,
3235 } ;
3336 }
3437
@@ -78,6 +81,8 @@ function parseLanguageFromInput(input: string): ParsedTranslationInput {
7881 // Parse the input to extract target language and text
7982 const { targetLanguage, textToTranslate } = parseLanguageFromInput ( input ) ;
8083
84+ alfredClient . log ( `Translating to: ${ targetLanguage } ` ) ;
85+
8186 const system = await TRANSLATE_SYSTEM_PROMPT ( useApplicationContext ) . format ( {
8287 applicationContext,
8388 targetLanguage,
You can’t perform that action at this time.
0 commit comments