Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importTranslation option into spreadsheet from config #463

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -308,6 +307,7 @@ private ImportOptions buildImportOptions(java.io.File sourceFile, FileBean fileB
SpreadsheetFileImportOptions importOptions = new SpreadsheetFileImportOptions();
importOptions.setFirstLineContainsHeader(fileBean.getFirstLineContainsHeader());
importOptions.setScheme(PropertiesBeanUtils.getSchemeObject(fileBean.getScheme()));
importOptions.setImportTranslations(fileBean.getImportTranslations());
return importOptions;
} else if (isXml(sourceFile)) {
XmlFileImportOptions importOptions = new XmlFileImportOptions();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/crowdin/cli/properties/FileBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import static com.crowdin.cli.properties.PropertiesBuilder.TRANSLATION_REPLACE;
import static com.crowdin.cli.properties.PropertiesBuilder.TYPE;
import static com.crowdin.cli.properties.PropertiesBuilder.UPDATE_OPTION;
import static com.crowdin.cli.properties.PropertiesBuilder.IMPORT_TRANSLATIONS;
import static com.crowdin.cli.properties.PropertiesBuilder.checkForDoubleAsterisks;
import static com.crowdin.cli.properties.PropertiesBuilder.hasRelativePaths;

Expand Down Expand Up @@ -65,6 +66,7 @@ public class FileBean {
private List<String> labels;
private List<String> excludedTargetLanguages;
private String customSegmentation;
private Boolean importTranslations;

static class FileBeanConfigurator implements BeanConfigurator<FileBean> {

Expand Down Expand Up @@ -98,6 +100,7 @@ public FileBean buildFromMap(Map<String, Object> map) {
PropertiesBuilder.setPropertyIfExists(fileBean::setLabels, map, LABELS, List.class);
PropertiesBuilder.setPropertyIfExists(fileBean::setExcludedTargetLanguages, map, EXCLUDED_TARGET_LANGUAGES, List.class);
PropertiesBuilder.setPropertyIfExists(fileBean::setCustomSegmentation, map, CUSTOM_SEGMENTATION, String.class);
PropertiesBuilder.setBooleanPropertyIfExists(fileBean::setImportTranslations, map, IMPORT_TRANSLATIONS);
return fileBean;
}

Expand Down Expand Up @@ -149,6 +152,10 @@ public void populateWithDefaultValues(FileBean bean) {
if (bean.getCustomSegmentation() != null) {
bean.setCustomSegmentation(Utils.normalizePath(bean.getCustomSegmentation()));
}

if (bean.getImportTranslations() == null) {
bean.setImportTranslations(Boolean.FALSE);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public abstract class PropertiesBuilder<T extends Properties, P extends Params>

public static final String CONFIG_FILE_PATH = "config_file_path";

public static final String IMPORT_TRANSLATIONS = "import_translations";

private Outputter out;
private Map<String, Object> configFileParams;
private Map<String, Object> identityFileParams;
Expand Down