Skip to content

Commit

Permalink
feat(FgForrest#3): add Deepl automation integration - default lang
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepan Kamenik committed Feb 29, 2024
1 parent 9152e3a commit b9403fb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/main/java/one/edee/babylon/MainService.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ public void startTranslation(Action action, TranslationConfiguration configurati
switch (action) {
case EXPORT:
log.info("Babylon starting...");
exporter.walkPathsAndWriteSheets(configuration.getPath(), configuration.getMutations(), spreadsheetId, configuration.getSnapshotPath(), configuration.getLockedCellEditors(), combineSheets, deeplApiKey);
exporter.walkPathsAndWriteSheets(
configuration.getPath(),
configuration.getMutations(),
spreadsheetId,
configuration.getSnapshotPath(),
configuration.getLockedCellEditors(),
combineSheets,
deeplApiKey,
configuration.getDefaultLang());
break;
case IMPORT:
importProcessor.doImport(spreadsheetId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public class TranslationConfiguration implements Serializable {

private List<String> lockedCellEditors = new ArrayList<>();

/**
* Default language of project properties.
*/
@NonNull
private String defaultLang;

@JsonIgnore
public Path getSnapshotPath() {
return Paths.get(dataFileName);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/one/edee/babylon/export/Exporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void walkPathsAndWriteSheets(List<String> patternPaths,
Path snapshotPath,
boolean combineSheets,
String deeplApiKey) {
walkPathsAndWriteSheets(patternPaths, translationLangs, spreadsheetId, snapshotPath, Collections.emptyList(), combineSheets, deeplApiKey);
walkPathsAndWriteSheets(patternPaths, translationLangs, spreadsheetId, snapshotPath, Collections.emptyList(), combineSheets, deeplApiKey, null);
}

/**
Expand All @@ -76,7 +76,8 @@ public void walkPathsAndWriteSheets(List<String> patternPaths,
Path snapshotPath,
List<String> lockedCellEditors,
boolean combineSheets,
String deeplApiKey) {
String deeplApiKey,
String defaultLang) {
warnDuplicatePaths(patternPaths);

List<ASheet> prevSheets = listAllSheets(spreadsheetId);
Expand Down Expand Up @@ -135,7 +136,7 @@ public void walkPathsAndWriteSheets(List<String> patternPaths,
}

if (StringUtils.hasText(original)) {
TextResult translatedText = translator.translateText(original, null, lang);
TextResult translatedText = translator.translateText(original, defaultLang, lang);
toChange.put(l, translatedText.getText());

changed
Expand Down

0 comments on commit b9403fb

Please sign in to comment.