Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-16835 Non-TC locales and extended locales remain open longer #3795

Merged
merged 10 commits into from
Jun 13, 2024
20 changes: 11 additions & 9 deletions tools/cldr-apps/js/src/esm/cldrStatus.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ function updateAll(status) {
if (status.phase) {
setPhase(status.phase);
}
if (status.ddlPhase) {
setDdlPhase(status.ddlPhase);
if (status.extendedPhase) {
setExtendedPhase(status.extendedPhase);
}
if (status.specialHeader) {
setSpecialHeader(status.specialHeader);
Expand Down Expand Up @@ -303,16 +303,18 @@ function getPhase() {
return phase;
}

let ddlPhase = "";
function setPhase(p) {
phase = p;
}
function getDdlPhase() {
return ddlPhase;

let extendedPhase = "";

function getExtendedPhase() {
return extendedPhase;
}

function setDdlPhase(p) {
ddlPhase = p;
function setExtendedPhase(p) {
extendedPhase = p;
}

/**
Expand Down Expand Up @@ -490,12 +492,12 @@ export {
getCurrentPage,
getCurrentSection,
getCurrentSpecial,
getExtendedPhase,
getIsPhaseBeta,
getIsUnofficial,
getNewVersion,
getOrganizationName,
getPermissions,
getDdlPhase,
getPhase,
getRunningStamp,
getSessionId,
Expand All @@ -517,14 +519,14 @@ export {
setCurrentPage,
setCurrentSection,
setCurrentSpecial,
setExtendedPhase,
setIsDisconnected,
setIsPhaseBeta,
setIsUnofficial,
setNewVersion,
setOrganizationName,
setPermissions,
setPhase,
setDdlPhase,
setSessionId,
setSessionMessage,
setSpecialHeader,
Expand Down
24 changes: 9 additions & 15 deletions tools/cldr-apps/js/src/views/MainHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<li>
{{ stVersion }} {{ stPhase }}
<span
class="ddlException"
v-if="ddlException"
title="Note: As a non-TC DDL locale, this phase has been extended."
class="extendedException"
v-if="extendedException"
title="Note: This phase has been extended for this locale."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If TC locales are in Vetting mode, and DDL locales are still in Submission mode, then if a DDL locale is selected, will this show "Vetting (extended)" or "Submission (extended)"? I'm guessing the latter but not quite sure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter. And it doesn't have to be a DDL locale, it could be one on the extended list.

>
(extended)
</span>
Expand Down Expand Up @@ -111,7 +111,7 @@ export default {
stPhase: null,
stVersion: null,
tcLocale: true,
ddlException: false,
extendedException: false,
unreadAnnouncementCount: 0,
userName: null,
voteCountMenu: null,
Expand Down Expand Up @@ -176,17 +176,11 @@ export default {
this.sessionMessage = cldrStatus.getSessionMessage();
this.specialHeader = cldrStatus.getSpecialHeader();
this.stVersion = "Survey Tool " + cldrStatus.getNewVersion();
this.tcLocale = cldrLoad?.getLocaleInfo(loc)?.tc;
if (!loc || this.tcLocale) {
this.extendedException = cldrLoad.getLocaleInfo(loc)?.extended;
if (!loc || !this.extendedException) {
this.stPhase = cldrStatus.getPhase();
this.ddlException = false;
} else {
this.stPhase = cldrStatus.getDdlPhase();
if (cldrStatus.getDdlPhase() != cldrStatus.getPhase()) {
this.ddlException = true;
} else {
this.ddlException = false;
}
} else if (this.extendedException) {
this.stPhase = cldrStatus.getExtendedPhase();
}
cldrAnnounce.getUnreadCount(this.setUnreadCount);
},
Expand Down Expand Up @@ -290,7 +284,7 @@ label {
width: 16ch;
}

.ddlException {
.extendedException {
background-color: yellow;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ public CheckCLDR.Phase getPhase() {
}

@Override
public CheckCLDR.Phase getDDLPhase() {
return SurveyMain.getOverallDDLPhase().toCheckCLDRPhase();
public CheckCLDR.Phase getExtendedPhase() {
return SurveyMain.getOverallExtendedPhase().toCheckCLDRPhase();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ private static JSONObject createJSONLocMap(SurveyMain sm) throws JSONException {
locale.put("dcParent", dcParent);
locale.put("dcChild", dcChild);
locale.put("tc", SubmissionLocales.isTcLocale(loc));
locale.put("extended", SubmissionLocales.isOpenForExtendedSubmission(loc));
locale.put(
"type",
Factory.getSourceTreeType(disk.getSourceDirectoryForLocale(loc.getBaseName())));
Expand Down
39 changes: 22 additions & 17 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public String display() {

// ===== Configuration state
private static Phase currentPhase = Phase.VETTING;
private static Phase currentDdlPhase = Phase.VETTING;
private static Phase currentExtendedPhase = Phase.VETTING;
/** set by CLDR_PHASE property. * */
private static String oldVersion = "OLDVERSION";

Expand Down Expand Up @@ -2825,30 +2825,35 @@ private void doStartup() {
+ phaseString);
}
currentPhase = newPhase;
String ddlPhaseString = survprops.getProperty("CLDR_DDL_PHASE", null);
Phase ddlPhase = null;
String extendedPhaseString = survprops.getProperty("CLDR_EXTENDED_PHASE", null);
Phase extendedPhase = null;
try {
if (ddlPhaseString != null && !ddlPhaseString.isEmpty()) {
if (extendedPhaseString != null && !extendedPhaseString.isEmpty()) {
if (currentPhase == Phase.READONLY) {
busted(
"Error: Cannot have a CLDR_DDL_PHASE when CLDR_PHASE=READONLY. Remove the CLDR_DDL_PHASE.");
"Error: Cannot have a CLDR_EXTENDED_PHASE when CLDR_PHASE=READONLY. Remove the CLDR_EXTENDED_PHASE.");
}
ddlPhase = (Phase.valueOf(ddlPhaseString));
extendedPhase = (Phase.valueOf(extendedPhaseString));
}
} catch (IllegalArgumentException iae) {
logger.warning("Error trying to parse CLDR_DDL_PHASE: " + iae);
logger.warning("Error trying to parse CLDR_EXTENDED_PHASE: " + iae);
}
if (ddlPhase == null) {
ddlPhase = newPhase;
logger.warning("CLDR_DDL_PHASE matches main phase " + ddlPhase);
if (extendedPhase == null) {
extendedPhase = newPhase;
logger.warning("CLDR_EXTENDED_PHASE unset, so will use main phase " + newPhase);
}
currentDdlPhase = ddlPhase;
currentExtendedPhase = extendedPhase;
}
logger.info(
"Phase: "
+ getOverallSurveyPhase()
+ ", CheckCLDR Phase: "
+ getOverallSurveyPhase().toCheckCLDRPhase());
+ getOverallSurveyPhase().toCheckCLDRPhase()
+ ", Extended Phase: "
+ currentExtendedPhase);
logger.info(
"CLDR_EXTENDED_SUBMISSION="
+ String.join(" ", SubmissionLocales.ADDITIONAL_EXTENDED_SUBMISSION));
progress.update("Setup props..");
newVersion = survprops.getProperty(CLDR_NEWVERSION, CLDR_NEWVERSION);
oldVersion = survprops.getProperty(CLDR_OLDVERSION, CLDR_OLDVERSION);
Expand Down Expand Up @@ -3601,7 +3606,7 @@ public static Phase getOverallSurveyPhase() {
public static Phase surveyPhase(CLDRLocale locale) {
return (SubmissionLocales.isTcLocale(locale)
? getOverallSurveyPhase()
: getOverallDDLPhase());
: getOverallExtendedPhase());
}

/**
Expand All @@ -3615,8 +3620,8 @@ public static CheckCLDR.Phase checkCLDRPhase(CLDRLocale loc) {
* the DDL (non-TC) overall phase. It is preferred to use one of the phase functions which takes
* a locale.
*/
public static Phase getOverallDDLPhase() {
return currentDdlPhase;
public static Phase getOverallExtendedPhase() {
return currentExtendedPhase;
}

public static String getOldVersion() {
Expand Down Expand Up @@ -3691,7 +3696,7 @@ private class StatusForFrontEnd implements JSONString {
private final int pages = SurveyMain.pages;
private Object permissions = null;
private final Phase phase = getOverallSurveyPhase();
private final Phase ddlPhase = getOverallDDLPhase();
private final Phase extendedPhase = getOverallExtendedPhase();
private String sessionId = null;
private final String specialHeader = getSpecialHeaderText();
private final long surveyRunningStamp = SurveyMain.surveyRunningStamp.current();
Expand Down Expand Up @@ -3725,7 +3730,7 @@ private JSONObject toJSONObject() throws JSONException {
.put("pages", pages)
.put("permissions", permissions)
.put("phase", phase)
.put("ddlPhase", ddlPhase)
.put("extendedPhase", extendedPhase)
.put("sessionId", sessionId)
.put("sessionMessage", sessionMessage)
.put("specialHeader", specialHeader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.unicode.cldr.util.CLDRConfig;
import org.unicode.cldr.util.CLDRLocale;
import org.unicode.cldr.util.GrammarInfo;
import org.unicode.cldr.util.Level;
Expand Down Expand Up @@ -70,6 +71,16 @@ public final class SubmissionLocales {
/** Subset of CLDR_LOCALES, minus special which are only those which are TC orgs */
public static final Set<String> TC_ORG_LOCALES;

/** Space-separated list of TC locales to extend submission */
public static final String DEFAULT_EXTENDED_SUBMISSION = "";

/** Additional TC locales which have extended submission. Do not add non-tc locales here. */
public static final Set<String> ADDITIONAL_EXTENDED_SUBMISSION =
ImmutableSet.copyOf(
CLDRConfig.getInstance()
.getProperty("CLDR_EXTENDED_SUBMISSION", "")
.split(" "));

/**
* Set to true iff ONLY grammar locales should be limited submission {@link
* GrammarInfo#getGrammarLocales()}
Expand Down Expand Up @@ -250,6 +261,10 @@ public static Set<ReportId> getReportsAvailableInLimited() {
return LIMITED_SUBMISSION_REPORTS;
}

/**
* @returns true if the locale or its parent is considered a TC Org Locale. Returns true for
* ROOT.
*/
public static boolean isTcLocale(CLDRLocale loc) {
if (loc == CLDRLocale.ROOT
|| SubmissionLocales.TC_ORG_LOCALES.contains(loc.getBaseName())) {
Expand All @@ -262,4 +277,26 @@ public static boolean isTcLocale(CLDRLocale loc) {
return isTcLocale(loc.getParent());
}
}

/**
* @returns true if the locale or its parent is considered a TC Org Locale. Returns true for
* ROOT.
*/
public static boolean isOpenForExtendedSubmission(CLDRLocale loc) {
if (loc == CLDRLocale.ROOT) {
return false; // root is never open
} else if (SubmissionLocales.ADDITIONAL_EXTENDED_SUBMISSION.contains(loc.getBaseName())) {
// explicitly listed locale is a open for additional
return true;
} else if (SubmissionLocales.TC_ORG_LOCALES.contains(loc.getBaseName())) {
// TC locale but not listed as extended - NOT open for extended submission.
return false;
} else if (loc.isParentRoot()) {
// Not a TC locale, so it's open.
return true;
} else {
// child locale of an open locale is open
return isOpenForExtendedSubmission(loc.getParent());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,10 @@ public synchronized Phase getPhase() {
}

/**
* @returns the phase for DDL (non-TC) locales. Defaults to same as main phase.
* @returns the phase for extended submission locales. Defaults to same as main phase. {@link
* SubmissionLocales#isOpenForExtendedSubmission}
*/
public Phase getDDLPhase() {
public Phase getExtendedPhase() {
// by default, same as main phase.
return getPhase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
Expand Down Expand Up @@ -80,14 +82,58 @@ public static final boolean bool(final String s) {
"de, true",
"de_IT, true",
"csw, false",
"csw_CA, false",
"cho_US, false",
"zh, true",
"zh_Hant_MO, true",
"smj, false",
"smj_NO, false",
"smj_SE, false",
})
public void testIsTcLocale(final String loc, final String tf) {
final CLDRLocale l = CLDRLocale.getInstance(loc);
assertNotNull(l, loc);
final Boolean isCldr = Boolean.parseBoolean(tf);
assertEquals(isCldr, SubmissionLocales.isTcLocale(l));
}

@ParameterizedTest
@CsvSource({
// loc, isTc
"root, true",
"de, true",
"de_IT, true",
"csw, false",
"csw_CA, false",
"cho_US, false",
"zh, true",
"zh_Hant_MO, true",
"smj, false",
"smj_NO, false",
"smj_SE, false",
})
public void testIsExtendedSubmissionLocale(final String loc, final String tf) {
final CLDRLocale l = CLDRLocale.getInstance(loc);
assertNotNull(l, loc);
final Boolean isExtendedSubmission = Boolean.parseBoolean(tf);
assertEquals(isExtendedSubmission, SubmissionLocales.isOpenForExtendedSubmission(l));
}

@Test
public void textAdditionalVsTcLocale() {
final List<CLDRLocale> extendedSubmissionButNotTcLocales =
SubmissionLocales.ADDITIONAL_EXTENDED_SUBMISSION.stream()
.map(l -> CLDRLocale.getInstance(l))
.filter(l -> !SubmissionLocales.isTcLocale(l))
.collect(Collectors.toList());
assertTrue(
extendedSubmissionButNotTcLocales.isEmpty(),
() ->
"Locales in SubmissionLocales.ADDITIONAL_EXTENDED_SUBMISSION that should be removed as they are not TC locales: "
+ String.join(
" ",
extendedSubmissionButNotTcLocales.stream()
.map(l -> l.getBaseName())
.collect(Collectors.toList())));
}
}
Loading