Skip to content

Commit b9403fb

Browse files
author
Stepan Kamenik
committed
feat(FgForrest#3): add Deepl automation integration - default lang
1 parent 9152e3a commit b9403fb

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/main/java/one/edee/babylon/MainService.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ public void startTranslation(Action action, TranslationConfiguration configurati
3434
switch (action) {
3535
case EXPORT:
3636
log.info("Babylon starting...");
37-
exporter.walkPathsAndWriteSheets(configuration.getPath(), configuration.getMutations(), spreadsheetId, configuration.getSnapshotPath(), configuration.getLockedCellEditors(), combineSheets, deeplApiKey);
37+
exporter.walkPathsAndWriteSheets(
38+
configuration.getPath(),
39+
configuration.getMutations(),
40+
spreadsheetId,
41+
configuration.getSnapshotPath(),
42+
configuration.getLockedCellEditors(),
43+
combineSheets,
44+
deeplApiKey,
45+
configuration.getDefaultLang());
3846
break;
3947
case IMPORT:
4048
importProcessor.doImport(spreadsheetId);

src/main/java/one/edee/babylon/config/TranslationConfiguration.java

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public class TranslationConfiguration implements Serializable {
4343

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

46+
/**
47+
* Default language of project properties.
48+
*/
49+
@NonNull
50+
private String defaultLang;
51+
4652
@JsonIgnore
4753
public Path getSnapshotPath() {
4854
return Paths.get(dataFileName);

src/main/java/one/edee/babylon/export/Exporter.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void walkPathsAndWriteSheets(List<String> patternPaths,
5757
Path snapshotPath,
5858
boolean combineSheets,
5959
String deeplApiKey) {
60-
walkPathsAndWriteSheets(patternPaths, translationLangs, spreadsheetId, snapshotPath, Collections.emptyList(), combineSheets, deeplApiKey);
60+
walkPathsAndWriteSheets(patternPaths, translationLangs, spreadsheetId, snapshotPath, Collections.emptyList(), combineSheets, deeplApiKey, null);
6161
}
6262

6363
/**
@@ -76,7 +76,8 @@ public void walkPathsAndWriteSheets(List<String> patternPaths,
7676
Path snapshotPath,
7777
List<String> lockedCellEditors,
7878
boolean combineSheets,
79-
String deeplApiKey) {
79+
String deeplApiKey,
80+
String defaultLang) {
8081
warnDuplicatePaths(patternPaths);
8182

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

137138
if (StringUtils.hasText(original)) {
138-
TextResult translatedText = translator.translateText(original, null, lang);
139+
TextResult translatedText = translator.translateText(original, defaultLang, lang);
139140
toChange.put(l, translatedText.getText());
140141

141142
changed

0 commit comments

Comments
 (0)