Skip to content

Commit a7f1144

Browse files
Say hello to CrowdinOTA again
Change crowdin requesting behavior to use timestamp querying files and not caching when querying manifest
1 parent 4c0c7f5 commit a7f1144

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
public class CrowdinOTA implements Distribution {
4949
private static final String localManifest = "{\"files\":[\"\\/master\\/crowdin\\/lang\\/%locale%\\/messages.json\"],\"languages\":[\"af\",\"ar\",\"bg\",\"ca\",\"zh-CN\",\"zh-TW\",\"zh-HK\",\"cs\",\"da\",\"nl\",\"en\",\"fi\",\"fr\",\"de\",\"el\",\"he\",\"hi\",\"hu\",\"it\",\"ja\",\"ko\",\"lt\",\"no\",\"pl\",\"pt-PT\",\"pt-BR\",\"ro\",\"ru\",\"sr\",\"es-ES\",\"sv-SE\",\"th\",\"tr\",\"uk\",\"vi\"],\"language_mapping\":{\"ro\":{\"locale\":\"ro-RO\"},\"fr\":{\"locale\":\"fr-FR\"},\"es-ES\":{\"locale\":\"es-ES\"},\"af\":{\"locale\":\"af-ZA\"},\"ar\":{\"locale\":\"ar-SA\"},\"bg\":{\"locale\":\"bg-BG\"},\"ca\":{\"locale\":\"ca-ES\"},\"cs\":{\"locale\":\"cs-CZ\"},\"da\":{\"locale\":\"da-DK\"},\"de\":{\"locale\":\"de-DE\"},\"el\":{\"locale\":\"el-GR\"},\"fi\":{\"locale\":\"fi-FI\"},\"he\":{\"locale\":\"he-IL\"},\"hu\":{\"locale\":\"hu-HU\"},\"it\":{\"locale\":\"it-IT\"},\"ja\":{\"locale\":\"ja-JP\"},\"ko\":{\"locale\":\"ko-KR\"},\"lt\":{\"locale\":\"lt-LT\"},\"nl\":{\"locale\":\"nl-NL\"},\"no\":{\"locale\":\"no-NO\"},\"pl\":{\"locale\":\"pl-PL\"},\"pt-PT\":{\"locale\":\"pt-PT\"},\"ru\":{\"locale\":\"ru-RU\"},\"sr\":{\"locale\":\"sr-SP\"},\"sv-SE\":{\"locale\":\"sv-SE\"},\"tr\":{\"locale\":\"tr-TR\"},\"uk\":{\"locale\":\"uk-UA\"},\"zh-CN\":{\"locale\":\"zh-CN\"},\"zh-TW\":{\"locale\":\"zh-TW\"},\"en\":{\"locale\":\"en-US\"},\"vi\":{\"locale\":\"vi-VN\"},\"pt-BR\":{\"locale\":\"pt-BR\"},\"th\":{\"locale\":\"th-TH\"},\"hi\":{\"locale\":\"hi-IN\"},\"zh-HK\":{\"locale\":\"zh-HK\"}},\"custom_languages\":[],\"timestamp\":1671608400,\"content\":{\"af\":[\"\\/content\\/master\\/crowdin\\/lang\\/af-ZA\\/messages.json\"],\"ar\":[\"\\/content\\/master\\/crowdin\\/lang\\/ar-SA\\/messages.json\"],\"bg\":[\"\\/content\\/master\\/crowdin\\/lang\\/bg-BG\\/messages.json\"],\"ca\":[\"\\/content\\/master\\/crowdin\\/lang\\/ca-ES\\/messages.json\"],\"zh-CN\":[\"\\/content\\/master\\/crowdin\\/lang\\/zh-CN\\/messages.json\"],\"zh-TW\":[\"\\/content\\/master\\/crowdin\\/lang\\/zh-TW\\/messages.json\"],\"zh-HK\":[\"\\/content\\/master\\/crowdin\\/lang\\/zh-HK\\/messages.json\"],\"cs\":[\"\\/content\\/master\\/crowdin\\/lang\\/cs-CZ\\/messages.json\"],\"da\":[\"\\/content\\/master\\/crowdin\\/lang\\/da-DK\\/messages.json\"],\"nl\":[\"\\/content\\/master\\/crowdin\\/lang\\/nl-NL\\/messages.json\"],\"en\":[\"\\/content\\/master\\/crowdin\\/lang\\/en-US\\/messages.json\"],\"fi\":[\"\\/content\\/master\\/crowdin\\/lang\\/fi-FI\\/messages.json\"],\"fr\":[\"\\/content\\/master\\/crowdin\\/lang\\/fr-FR\\/messages.json\"],\"de\":[\"\\/content\\/master\\/crowdin\\/lang\\/de-DE\\/messages.json\"],\"el\":[\"\\/content\\/master\\/crowdin\\/lang\\/el-GR\\/messages.json\"],\"he\":[\"\\/content\\/master\\/crowdin\\/lang\\/he-IL\\/messages.json\"],\"hi\":[\"\\/content\\/master\\/crowdin\\/lang\\/hi-IN\\/messages.json\"],\"hu\":[\"\\/content\\/master\\/crowdin\\/lang\\/hu-HU\\/messages.json\"],\"it\":[\"\\/content\\/master\\/crowdin\\/lang\\/it-IT\\/messages.json\"],\"ja\":[\"\\/content\\/master\\/crowdin\\/lang\\/ja-JP\\/messages.json\"],\"ko\":[\"\\/content\\/master\\/crowdin\\/lang\\/ko-KR\\/messages.json\"],\"lt\":[\"\\/content\\/master\\/crowdin\\/lang\\/lt-LT\\/messages.json\"],\"no\":[\"\\/content\\/master\\/crowdin\\/lang\\/no-NO\\/messages.json\"],\"pl\":[\"\\/content\\/master\\/crowdin\\/lang\\/pl-PL\\/messages.json\"],\"pt-PT\":[\"\\/content\\/master\\/crowdin\\/lang\\/pt-PT\\/messages.json\"],\"pt-BR\":[\"\\/content\\/master\\/crowdin\\/lang\\/pt-BR\\/messages.json\"],\"ro\":[\"\\/content\\/master\\/crowdin\\/lang\\/ro-RO\\/messages.json\"],\"ru\":[\"\\/content\\/master\\/crowdin\\/lang\\/ru-RU\\/messages.json\"],\"sr\":[\"\\/content\\/master\\/crowdin\\/lang\\/sr-SP\\/messages.json\"],\"es-ES\":[\"\\/content\\/master\\/crowdin\\/lang\\/es-ES\\/messages.json\"],\"sv-SE\":[\"\\/content\\/master\\/crowdin\\/lang\\/sv-SE\\/messages.json\"],\"th\":[\"\\/content\\/master\\/crowdin\\/lang\\/th-TH\\/messages.json\"],\"tr\":[\"\\/content\\/master\\/crowdin\\/lang\\/tr-TR\\/messages.json\"],\"uk\":[\"\\/content\\/master\\/crowdin\\/lang\\/uk-UA\\/messages.json\"],\"vi\":[\"\\/content\\/master\\/crowdin\\/lang\\/vi-VN\\/messages.json\"]},\"mapping\":[\"\\/mapping\\/master\\/crowdin\\/lang\\/en-US\\/messages.json\"],\"local\":true}";
5050
//DO NOT final it! Unit-test needs to change it to prevent network flow
51-
protected static String CROWDIN_OTA_HOST = "";
51+
protected static String CROWDIN_OTA_HOST = "https://crowdinota.reremake.r2.quickshop-powered.top/";
5252
private final QuickShop plugin;
5353
private final OTACacheControl otaCacheControl = new OTACacheControl();
5454

@@ -76,10 +76,8 @@ public Manifest getManifest() {
7676
*/
7777
@NotNull
7878
public String getManifestJson() {
79-
//Comment for disable OTA
80-
//String url = CROWDIN_OTA_HOST + "manifest.json";
81-
//HttpUtil.createGet(url, localManifest);
82-
return localManifest;
79+
String url = CROWDIN_OTA_HOST + "manifest.json";
80+
return HttpUtil.createGet(url, localManifest, false);
8381
}
8482

8583
/**
@@ -173,7 +171,7 @@ public String getFile(String fileCrowdinPath, String crowdinLocale, boolean forc
173171
Util.debugLog("Manifest timestamp check failed " + postProcessingPath + " excepted:" + otaCacheControl.readManifestTimestamp() + " actual: " + getManifest().getTimestamp() + " forceUpdate: " + forceFlush);
174172
}
175173
// Out of the cache
176-
String url = CROWDIN_OTA_HOST + "content" + fileCrowdinPath.replace("%locale%", crowdinLocale);
174+
String url = CROWDIN_OTA_HOST + "content" + fileCrowdinPath.replace("%locale%", crowdinLocale) + "?timestamp=" + manifestTimestamp;
177175
plugin.getLogger().info("Updating translation " + crowdinLocale + " from: " + url);
178176
String data = HttpUtil.createGet(url, forceFlush);
179177
if (data == null) {

src/main/java/org/maxgamer/quickshop/util/HttpUtil.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ public static Response makeGet(@NotNull String url) throws IOException {
5151
}
5252

5353
@NotNull
54-
public static String createGet(@NotNull String url, String def) {
54+
public static String createGet(@NotNull String url, String def, boolean caching) {
5555
String result = createGet(url, false);
5656
if (result == null) {
5757
result = def;
5858
}
59-
requestCachePool.put(url, result);
59+
if (caching) {
60+
requestCachePool.put(url, result);
61+
}
6062
return result;
6163
}
6264

65+
@NotNull
66+
public static String createGet(@NotNull String url, String def) {
67+
return createGet(url, def, true);
68+
}
69+
6370
@Nullable
6471
public static String createGet(@NotNull String url) {
6572
return createGet(url, false);

0 commit comments

Comments
 (0)