package com.crowdin.cli.commands.functionality;

import com.crowdin.cli.properties.PropertiesBean;
import com.crowdin.cli.utils.CommandUtils;
import com.crowdin.cli.utils.PlaceholderUtil;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.util.List;
import java.util.stream.Collectors;

public class DryrunTranslations extends Dryrun {

    private PropertiesBean pb;
    private PlaceholderUtil placeholderUtil;

    public DryrunTranslations(PropertiesBean pb, PlaceholderUtil placeholderUtil) {
        this.pb = pb;
        this.placeholderUtil = placeholderUtil;
    }

    @Override
    protected List<String> getFiles() {
        return pb.getFiles()
            .stream()
            .flatMap(file -> CommandUtils.getFileSourcesWithoutIgnores(file, pb.getBasePath(), placeholderUtil)
                .stream()
                .map(source -> placeholderUtil.replaceFileDependentPlaceholders(file.getTranslation(), source))
                .flatMap(translation -> ((file.getLanguagesMapping() != null)
                    ? placeholderUtil.replaceLanguageDependentPlaceholders(translation, file.getLanguagesMapping())
                    : placeholderUtil.replaceLanguageDependentPlaceholders(translation)).stream()))
            .map(source -> StringUtils.removeStart(source, pb.getBasePath()))
            .collect(Collectors.toList());
    }
}

@@ -181,16 +181,52 @@
 erUtil;%0A
+import com.crowdin.cli.utils.Utils;%0A
 import o
@@ -279,15 +279,24 @@
 ava.
-io.File
+util.Collections
 ;%0Aim
@@ -1288,16 +1288,501 @@
 tream())
+%0A                .map(translation -%3E (file.getTranslationReplace() != null ? file.getTranslationReplace() : Collections.%3CString, String%3EemptyMap())%0A                    .keySet()%0A                    .stream()%0A                    .reduce(translation, (trans, k) -%3E StringUtils.replace(%0A                        trans,%0A                        k.replaceAll(%22%5B%5C%5C%5C%5C/%5D+%22, Utils.PATH_SEPARATOR_REGEX),%0A                        file.getTranslationReplace().get(k)))%0A                )%0A            
 )%0A      

Fix translation_replace for translations dryrun