Add support for other mod ids in LangMerger
This commit is contained in:
parent
0c5ccf38ee
commit
f0311f3245
1 changed files with 12 additions and 6 deletions
|
@ -39,6 +39,8 @@ public class LangMerger implements DataProvider {
|
|||
static final String CATEGORY_HEADER = "\t\"_\": \"->------------------------] %s [------------------------<-\",";
|
||||
|
||||
private DataGenerator gen;
|
||||
private final String modid;
|
||||
private final String displayName;
|
||||
|
||||
private List<Object> mergedLangData;
|
||||
private Map<String, List<Object>> populatedLangData;
|
||||
|
@ -47,8 +49,12 @@ public class LangMerger implements DataProvider {
|
|||
|
||||
private List<String> langIgnore;
|
||||
|
||||
public LangMerger(DataGenerator gen) {
|
||||
public LangMerger(DataGenerator gen) { this(gen, Create.ID, "Create"); }
|
||||
|
||||
public LangMerger(DataGenerator gen, String modid, String displayName) {
|
||||
this.gen = gen;
|
||||
this.modid = modid;
|
||||
this.displayName = displayName;
|
||||
this.mergedLangData = new ArrayList<>();
|
||||
this.langIgnore = new ArrayList<>();
|
||||
this.allLocalizedEntries = new HashMap<>();
|
||||
|
@ -78,7 +84,7 @@ public class LangMerger implements DataProvider {
|
|||
@Override
|
||||
public void run(HashCache cache) throws IOException {
|
||||
Path path = this.gen.getOutputFolder()
|
||||
.resolve("assets/" + Create.ID + "/lang/" + "en_us.json");
|
||||
.resolve("assets/" + modid + "/lang/" + "en_us.json");
|
||||
|
||||
for (Pair<String, JsonElement> pair : getAllLocalizationFiles()) {
|
||||
if (!pair.getRight()
|
||||
|
@ -112,7 +118,7 @@ public class LangMerger implements DataProvider {
|
|||
for (Entry<String, List<Object>> localization : populatedLangData.entrySet()) {
|
||||
String key = localization.getKey();
|
||||
Path populatedLangPath = this.gen.getOutputFolder()
|
||||
.resolve("assets/" + Create.ID + "/lang/unfinished/" + key);
|
||||
.resolve("assets/" + modid + "/lang/unfinished/" + key);
|
||||
save(cache, localization.getValue(), missingTranslationTally.get(key)
|
||||
.intValue(), populatedLangPath, "Populating " + key + " with missing entries...");
|
||||
}
|
||||
|
@ -180,7 +186,7 @@ public class LangMerger implements DataProvider {
|
|||
// Always put tooltips and ponder scenes in their own paragraphs
|
||||
if (key.endsWith(".tooltip"))
|
||||
return true;
|
||||
if (key.startsWith("create.ponder") && key.endsWith(PonderScene.TITLE_KEY))
|
||||
if (key.startsWith(modid + ".ponder") && key.endsWith(PonderScene.TITLE_KEY))
|
||||
return true;
|
||||
|
||||
key = key.replaceFirst("\\.", "");
|
||||
|
@ -198,7 +204,7 @@ public class LangMerger implements DataProvider {
|
|||
private List<Pair<String, JsonElement>> getAllLocalizationFiles() {
|
||||
ArrayList<Pair<String, JsonElement>> list = new ArrayList<>();
|
||||
|
||||
String filepath = "assets/" + Create.ID + "/lang/";
|
||||
String filepath = "assets/" + modid + "/lang/";
|
||||
try (InputStream resourceStream = ClassLoader.getSystemResourceAsStream(filepath)) {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resourceStream));
|
||||
while (true) {
|
||||
|
@ -250,7 +256,7 @@ public class LangMerger implements DataProvider {
|
|||
if (missingKeys != -1)
|
||||
builder.append("\t\"_\": \"Missing Localizations: " + missingKeys + "\",\n");
|
||||
data.forEach(builder::append);
|
||||
builder.append("\t\"_\": \"Thank you for translating Create!\"\n\n");
|
||||
builder.append("\t\"_\": \"Thank you for translating ").append(displayName).append("!\"\n\n");
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue