com.github.mathieudebrito.translator.parsers.PlainTextFileParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of file-translator Show documentation
Show all versions of file-translator Show documentation
Library that helps translating files
The newest version!
package com.github.mathieudebrito.translator.parsers;
import com.github.mathieudebrito.translator.Language;
import com.github.mathieudebrito.translator.utils.Files;
import com.github.mathieudebrito.translator.utils.PlayStoreLanguage;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class PlainTextFileParser implements FileParser {
public static final boolean LOG_ENABLED = true;
@Override
public Map readEntries(String path, List fileNamesFrom, Language languageFrom) {
Map entries = new TreeMap();
for (String fileName : fileNamesFrom) {
entries.putAll(readEntries(path, fileName, languageFrom));
}
return entries;
}
private Map readEntries(String path, String fileNameFrom, Language languageFrom) {
Map entries = new TreeMap();
String content = Files.read(getFilename(path, fileNameFrom, languageFrom));
entries.put("content", content);
return entries;
}
@Override
public String decode(String text) {
text = text.replace("\n", "
");
text = text.replace("
", "
");
return text;
}
@Override
public String getFilename(String path, String fileNameFrom, Language language) {
return path + "/" + PlayStoreLanguage.getPreciseLanguage(language) + "/" + fileNameFrom;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy