Skip to content

Commit

Permalink
fix: issue in google translator connector whith text contains single …
Browse files Browse the repository at this point in the history
…quote char - EXO-66886 (#52)

Prior to this change, when attempting to translate a text with a simple quote char with google translator, the connector fails due to existing quote char in the text due to the use of signle quotes in the request param.
This prevents this situation by using escaped double quotes in the qurey param.
  • Loading branch information
hakermi authored Oct 19, 2023
1 parent e4af14d commit 74bf3d0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public DeepLTranslateConnector(SettingService settingService) {
super(settingService);
textTranslationOptions = new TextTranslationOptions();
textTranslationOptions.setTagHandling("html");
textTranslationOptions.setPreserveFormatting(true);
textTranslationOptions.setSentenceSplittingMode(SentenceSplittingMode.All);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class GoogleTranslateConnector extends AutomaticTranslationComponentPlugi

private static final String KEY_PARAM = "key";

private static final String DATA_PATTERN = "{'q': '{message}', 'target': '{targetLocale}'}";
private static final String DATA_PATTERN = "{\"q\": \"{message}\", \"target\": \"{targetLocale}\"}";

private static final int DEFAULT_POOL_CONNECTION = 100;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void translate() throws NoSuchFieldException, IllegalAccessException, Dee
// Need real auth-key to have a real result
TextTranslationOptions textTranslationOptions = new TextTranslationOptions();
textTranslationOptions.setTagHandling("html");
textTranslationOptions.setPreserveFormatting(true);
textTranslationOptions.setSentenceSplittingMode(SentenceSplittingMode.All);
TextResult textResult = new TextResult("<h1>Hello</h1>", "fr");
Field textTranslationOptionsField = deepLTranslateConnector.getClass().getDeclaredField("textTranslationOptions");
Expand Down

0 comments on commit 74bf3d0

Please sign in to comment.