diff --git a/tools/cldr-apps/js/src/esm/cldrErrorSubtypes.mjs b/tools/cldr-apps/js/src/esm/cldrErrorSubtypes.mjs index b244f27914d..4e5f21d3a2e 100644 --- a/tools/cldr-apps/js/src/esm/cldrErrorSubtypes.mjs +++ b/tools/cldr-apps/js/src/esm/cldrErrorSubtypes.mjs @@ -5,6 +5,7 @@ import * as cldrAjax from "./cldrAjax.mjs"; import * as cldrLoad from "./cldrLoad.mjs"; import * as cldrStatus from "./cldrStatus.mjs"; import * as cldrSurvey from "./cldrSurvey.mjs"; +import * as cldrDom from "./cldrDom.mjs"; const instructions = "

\n" + @@ -141,10 +142,14 @@ function reloadMapHandler(json) { } } else { html += "

" + json.status + "

"; + html += redirectSoon; + window.setTimeout(load, coupleSeconds); } - html += redirectSoon; el.innerHTML = html; - window.setTimeout(load, coupleSeconds); + if (json.err) { + const b = cldrDom.createLinkToFn('special_error_subtypes', load, 'button'); + el.appendChild(b); + } } function setOnClicks() { diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/ErrorSubtypes.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/ErrorSubtypes.java index 249e30e0836..8f529570738 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/ErrorSubtypes.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/ErrorSubtypes.java @@ -78,10 +78,12 @@ private static void getRecheck(SurveyJSONWrapper r, String recheck) throws MalformedURLException { if (recheck.startsWith("MAP")) { try { - SubtypeToURLMap map = SubtypeToURLMap.reload(); + // load directly to make sure there are no errors + SubtypeToURLMap map = SubtypeToURLMap.makeDefaultInstance(); if (map == null) { r.put("err", "FAILED. Check for errors."); } else { + SubtypeToURLMap.setDefaultInstance(map); r.put("status", "SUCCESS!"); } } catch (Throwable t) { diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SubtypeToURLMap.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SubtypeToURLMap.java index 325c7f0776a..e122defc49b 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SubtypeToURLMap.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SubtypeToURLMap.java @@ -36,6 +36,7 @@ import org.unicode.cldr.test.CheckCLDR.CheckStatus.Subtype; import org.unicode.cldr.test.CheckCLDR.SubtypeToURLProvider; import org.unicode.cldr.util.CLDRCacheDir; +import org.unicode.cldr.util.CLDRConfig; import org.unicode.cldr.util.CLDRTool; @CLDRTool( @@ -53,7 +54,8 @@ public class SubtypeToURLMap implements SubtypeToURLProvider { public static void main(String args[]) throws FileNotFoundException, IOException { if (args.length == 0) { System.err.println( - "Usage: SubtypeToURLMap (url or file path). The default map is " + DEFAULT_URL); + "Usage: SubtypeToURLMap (url or file path). The default map is " + + getDefaultUrl()); return; } else { int problems = 0; @@ -447,7 +449,7 @@ static SubtypeToURLMap make() { } } try { - map = SubtypeToURLMap.getInstance(new URL(getDefaultUrl())); + map = makeDefaultInstance(); logger.info("Read new map from " + getDefaultUrl()); // now, write out the cache writeToCache(map); @@ -492,7 +494,7 @@ private static void writeToCache(SubtypeToURLMap map) { * @return */ public static String getDefaultUrl() { - return DEFAULT_URL; + return CLDRConfig.getInstance().getProperty("CLDR_SUBTYPE_URL", DEFAULT_URL); } /** * Get the default instance. @@ -511,6 +513,17 @@ public static String forSubtype(Subtype subtype) { public static SubtypeToURLMap reload() { return (SubtypeToURLMapHelper.INSTANCE = SubtypeToURLMapHelper.make()); } + + /** call this to propagate loading */ + public static SubtypeToURLMap makeDefaultInstance() + throws IOException, URISyntaxException, MalformedURLException { + return SubtypeToURLMap.getInstance(new URL(getDefaultUrl())); + } + + public static void setDefaultInstance(SubtypeToURLMap m) { + SubtypeToURLMapHelper.INSTANCE = m; + } + @Override public String apply(Subtype t) { return forSubtype(t);