Skip to content

Commit e368bf6

Browse files
committed
Add notice string for users
1 parent 01c3fd8 commit e368bf6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/main/java/org/maxgamer/quickshop/util/language/text/distributions/crowdin/CrowdinOTA.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ public String getFile(String fileCrowdinPath, String crowdinLocale, boolean forc
9696
File metadataFile = new File(Util.getCacheFolder(), "i18n.metadata");
9797
YamlConfiguration cacheMetadata = YamlConfiguration.loadConfiguration(metadataFile);
9898
long localeTimestamp = cacheMetadata.getLong(pathHash + ".timestamp");
99-
String data = Util.readToString(new File(Util.getCacheFolder(), pathHash));
99+
File cachedDataFile = new File(Util.getCacheFolder(), pathHash);
100+
String data = null;
101+
if(cachedDataFile.exists()){
102+
data = Util.readToString(cachedDataFile);
103+
}
100104
// invalidate cache, flush it
101-
if (localeTimestamp != manifest.getTimestamp() || forceFlush) {
105+
if (forceFlush || data == null ||localeTimestamp != manifest.getTimestamp()) {
102106
String url = CROWDIN_OTA_HOST + "content/" + fileCrowdinPath.replace("%locale%", postProcessingPath);
103107
data = requestWithCache(url);
104108
if (data == null)
@@ -107,11 +111,11 @@ public String getFile(String fileCrowdinPath, String crowdinLocale, boolean forc
107111
cacheMetadata.set(pathHash + ".timestamp", manifest.getTimestamp());
108112
cacheMetadata.save(metadataFile);
109113
}
110-
if (data == null) {
111-
cacheMetadata.set(pathHash, null);
112-
cacheMetadata.save(metadataFile);
113-
throw new IOException("Couldn't read translation from local cache, please try again");
114-
}
114+
// if (data == null) {
115+
// cacheMetadata.set(pathHash, null);
116+
// cacheMetadata.save(metadataFile);
117+
// throw new IOException("Couldn't read translation from local cache, please try again");
118+
// }
115119
return data;
116120
}
117121
}

src/main/resources/lang-original/messages.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,5 +331,7 @@
331331
"require-restart": "&aReload completed. &e(Some changes require server restart to affect)",
332332
"failed": "&cReload failed, check the server console",
333333
"scheduled": "&aReload completed. &7(Some changes required a while to affect)"
334-
}
334+
},
335+
"client-language-changed": "&aQuickShop detected your client language setting has been changed, we're now using {0} locale for you.",
336+
"client-language-unsupported": "&eQuickShop doesn't support your client language, we're fallback to {0} locale now."
335337
}

0 commit comments

Comments
 (0)