mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-18 07:53:07 +01:00
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 [------------------------<-\",";
|
static final String CATEGORY_HEADER = "\t\"_\": \"->------------------------] %s [------------------------<-\",";
|
||||||
|
|
||||||
private DataGenerator gen;
|
private DataGenerator gen;
|
||||||
|
private final String modid;
|
||||||
|
private final String displayName;
|
||||||
|
|
||||||
private List<Object> mergedLangData;
|
private List<Object> mergedLangData;
|
||||||
private Map<String, List<Object>> populatedLangData;
|
private Map<String, List<Object>> populatedLangData;
|
||||||
|
@ -47,8 +49,12 @@ public class LangMerger implements DataProvider {
|
||||||
|
|
||||||
private List<String> langIgnore;
|
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.gen = gen;
|
||||||
|
this.modid = modid;
|
||||||
|
this.displayName = displayName;
|
||||||
this.mergedLangData = new ArrayList<>();
|
this.mergedLangData = new ArrayList<>();
|
||||||
this.langIgnore = new ArrayList<>();
|
this.langIgnore = new ArrayList<>();
|
||||||
this.allLocalizedEntries = new HashMap<>();
|
this.allLocalizedEntries = new HashMap<>();
|
||||||
|
@ -78,7 +84,7 @@ public class LangMerger implements DataProvider {
|
||||||
@Override
|
@Override
|
||||||
public void run(HashCache cache) throws IOException {
|
public void run(HashCache cache) throws IOException {
|
||||||
Path path = this.gen.getOutputFolder()
|
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()) {
|
for (Pair<String, JsonElement> pair : getAllLocalizationFiles()) {
|
||||||
if (!pair.getRight()
|
if (!pair.getRight()
|
||||||
|
@ -112,7 +118,7 @@ public class LangMerger implements DataProvider {
|
||||||
for (Entry<String, List<Object>> localization : populatedLangData.entrySet()) {
|
for (Entry<String, List<Object>> localization : populatedLangData.entrySet()) {
|
||||||
String key = localization.getKey();
|
String key = localization.getKey();
|
||||||
Path populatedLangPath = this.gen.getOutputFolder()
|
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)
|
save(cache, localization.getValue(), missingTranslationTally.get(key)
|
||||||
.intValue(), populatedLangPath, "Populating " + key + " with missing entries...");
|
.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
|
// Always put tooltips and ponder scenes in their own paragraphs
|
||||||
if (key.endsWith(".tooltip"))
|
if (key.endsWith(".tooltip"))
|
||||||
return true;
|
return true;
|
||||||
if (key.startsWith("create.ponder") && key.endsWith(PonderScene.TITLE_KEY))
|
if (key.startsWith(modid + ".ponder") && key.endsWith(PonderScene.TITLE_KEY))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
key = key.replaceFirst("\\.", "");
|
key = key.replaceFirst("\\.", "");
|
||||||
|
@ -198,7 +204,7 @@ public class LangMerger implements DataProvider {
|
||||||
private List<Pair<String, JsonElement>> getAllLocalizationFiles() {
|
private List<Pair<String, JsonElement>> getAllLocalizationFiles() {
|
||||||
ArrayList<Pair<String, JsonElement>> list = new ArrayList<>();
|
ArrayList<Pair<String, JsonElement>> list = new ArrayList<>();
|
||||||
|
|
||||||
String filepath = "assets/" + Create.ID + "/lang/";
|
String filepath = "assets/" + modid + "/lang/";
|
||||||
try (InputStream resourceStream = ClassLoader.getSystemResourceAsStream(filepath)) {
|
try (InputStream resourceStream = ClassLoader.getSystemResourceAsStream(filepath)) {
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resourceStream));
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resourceStream));
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -250,7 +256,7 @@ public class LangMerger implements DataProvider {
|
||||||
if (missingKeys != -1)
|
if (missingKeys != -1)
|
||||||
builder.append("\t\"_\": \"Missing Localizations: " + missingKeys + "\",\n");
|
builder.append("\t\"_\": \"Missing Localizations: " + missingKeys + "\",\n");
|
||||||
data.forEach(builder::append);
|
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("}");
|
builder.append("}");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue