Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions tools/cldr-apps/js/src/esm/cldrDeferHelp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ function subloadAbstract(resource) {
).then(
({ results }) => {
let seeAlso = resource;
if (
results.bindings[0].primaryTopic &&
results.bindings[0].primaryTopic.value
) {
if (results?.bindings[0]?.primaryTopic?.value) {
seeAlso = results.bindings[0].primaryTopic.value;
absContent.text(results.bindings[0].abstract.value);
}
absContent.text(results.bindings[0].abstract.value);
absDiv.append(
$("<a/>", {
text: "(more)",
Expand Down
67 changes: 22 additions & 45 deletions tools/cldr-apps/js/src/esm/cldrInfo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function addSelectedItem(theRow) {
const { language, direction } = getLanguageAndDirection();
selectedItemWrapper.setLanguageAndDirection(language, direction);

const description = getItemDescription(item?.pClass, theRow);
const description = getItemDescription(item?.status, theRow);
selectedItemWrapper.setDescription(description);

const { linkUrl, linkText } = getLinkUrlAndText(theRow, item);
Expand All @@ -355,7 +355,7 @@ function getValueAndClass(theRow, item) {
if (!displayValue) {
displayValue = ""; // not "undefined"
}
const valueClass = item?.pClass || "value";
const valueClass = item?.status || "value";
return { displayValue, valueClass };
}

Expand All @@ -370,16 +370,7 @@ function getLanguageAndDirection() {

/**
* Add a link in the Info Panel for "Jump to Original" (cldrText.get('followAlias')),
* if theRow.inheritedLocale or theRow.inheritedXpid is defined.
*
* Normally at least one of theRow.inheritedLocale and theRow.inheritedXpid should be
* defined whenever we have an INHERITANCE_MARKER item. Otherwise an error is reported
* by checkRowConsistency.
*
* An alternative would be for the server to send the link, instead of inheritedLocale
* and inheritedXpid, to the client, avoiding the need for the client to know so much,
* including the need to replace 'code-fallback' with 'root' or when to use cldrStatus.getCurrentLocale()
* in place of inheritedLocale or use xpstrid in place of inheritedXpid.
* if appropriate.
*
* @param {Object} theRow the row
* @param {Object} item the candidate item
Expand All @@ -389,26 +380,11 @@ function getLinkUrlAndText(theRow, item) {
let linkText = null;
if (
item?.value === cldrSurvey.INHERITANCE_MARKER &&
(theRow?.inheritedLocale || theRow?.inheritedXpid)
item?.status !== "constructed" &&
theRow?.inheritedUrl
) {
let loc = theRow.inheritedLocale;
let xpstrid = theRow.inheritedXpid || theRow.xpstrid;
if (!loc) {
loc = cldrStatus.getCurrentLocale();
} else if (loc === "code-fallback") {
/*
* Never use 'code-fallback' in the link, use 'root' instead.
* On the server, 'code-fallback' sometimes goes by the name XMLSource.CODE_FALLBACK_ID.
*/
loc = "root";
}
if (xpstrid === theRow.xpstrid && loc === cldrStatus.getCurrentLocale()) {
// following the alias would come back to the current item; no link
// and no link text either
} else {
linkText = cldrText.get("followAlias");
linkUrl = "#/" + loc + "//" + xpstrid;
}
linkText = cldrText.get("followAlias");
linkUrl = theRow.inheritedUrl;
}
return { linkUrl, linkText };
}
Expand Down Expand Up @@ -562,8 +538,8 @@ function updateRowVoteInfo(tr, theRow) {
var isectionIsUsed = false;

/*
* Note: we can't just check for item.pClass === "winner" here, since, for example, the winning value may
* have value = cldrSurvey.INHERITANCE_MARKER and item.pClass = "alias".
* Note: we can't just check for item.status === "winner" here, since, for example, the winning value may
* have value = cldrSurvey.INHERITANCE_MARKER and item.status = "alias".
*/
if (value === theRow.winningValue) {
const statusClass = cldrTable.getRowApprovalStatusClass(theRow);
Expand All @@ -589,7 +565,7 @@ function updateRowVoteInfo(tr, theRow) {
* theRow.inheritedValue can be undefined here; then do not append
*/
if (theRow.inheritedValue) {
cldrVote.appendItem(valdiv, theRow.inheritedDisplayValue, item.pClass);
cldrVote.appendItem(valdiv, theRow.inheritedDisplayValue, item.status);
valdiv.appendChild(
cldrDom.createChunk(cldrText.get("voteInfo_votesForInheritance"), "p")
);
Expand Down Expand Up @@ -674,30 +650,31 @@ function makeVoteExplainerDiv(voteTranscript) {
return voteExplainerDiv;
}

function getItemDescription(itemClass, theRow) {
function getItemDescription(candidateStatus, theRow) {
if (!candidateStatus) {
return "";
}
/*
* itemClass may be "winner, "alias", "fallback", "fallback_code", "fallback_root", or "loser".
* See getPClass in DataPage.java.*
* candidateStatus may be "winner, "alias", "constructed", "fallback", "fallback_code", "fallback_root", or "loser".
* See DataPage.DataRow.CandidateItem.getCandidateStatus in DataPage.java
*/
const inheritedLocale = theRow?.inheritedLocale;
if (itemClass === "fallback") {
if (candidateStatus === "fallback") {
const locName = cldrLoad.getLocaleName(inheritedLocale);
return cldrText.sub("item_description_fallback", [locName]);
} else if (itemClass === "alias") {
} else if (candidateStatus === "alias") {
if (inheritedLocale === cldrStatus.getCurrentLocale()) {
return cldrText.get(
theRow.inheritedXpid
? "item_description_alias_same_locale"
: "noFollowAlias"
);
return cldrText.get("item_description_alias_same_locale");
} else {
const locName = cldrLoad.getLocaleName(inheritedLocale);
return cldrText.sub("item_description_alias_diff_locale", [locName]);
}
} else if (candidateStatus === "constructed") {
return cldrText.get("noFollowAlias");
} else {
// Strings produced here, used as keys for cldrText.get(), may include:
// "item_description_winner", "item_description_fallback_code", "item_description_fallback_root", "item_description_loser".
return cldrText.get("item_description_" + itemClass);
return cldrText.get("item_description_" + candidateStatus);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/cldr-apps/js/src/esm/cldrSideways.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as cldrLoad from "./cldrLoad.mjs";
import * as cldrStatus from "./cldrStatus.mjs";
import * as cldrSurvey from "./cldrSurvey.mjs";

const SIDEWAYS_DEBUG = true;
const SIDEWAYS_DEBUG = false;
/** If true only load when clicked */
const LOAD_ON_DEMAND = true;

Expand Down
12 changes: 5 additions & 7 deletions tools/cldr-apps/js/src/esm/cldrTable.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -636,17 +636,15 @@ function checkRowConsistency(theRow) {
" - there is INHERITANCE_MARKER without inheritedValue"
);
}
} else if (!theRow.inheritedLocale && !theRow.inheritedXpid) {
} else if (!theRow.inheritedUrl) {
/*
* It is probably a bug if item.value === cldrSurvey.INHERITANCE_MARKER but theRow.inheritedLocale and
* theRow.inheritedXpid are both undefined (null on server).
* This happens with "example C" in
* https://unicode.org/cldr/trac/ticket/11299#comment:15
* It is probably a bug if item.value === cldrSurvey.INHERITANCE_MARKER but theRow.inheritedUrl is
* undefined (null on server).
*/
console.log(
"For " +
theRow.xpstrid +
" - there is INHERITANCE_MARKER without inheritedLocale or inheritedXpid"
" - there is INHERITANCE_MARKER without inheritedUrl"
);
}
}
Expand Down Expand Up @@ -931,7 +929,7 @@ function addVitem(td, tr, theRow, item, newButton) {
}
const subSpan = document.createElement("span");
subSpan.className = "subSpan";
cldrVote.appendItem(subSpan, displayValue, item.pClass);
cldrVote.appendItem(subSpan, displayValue, item.status);
choiceField.appendChild(subSpan);
if (item.isBaselineValue == true) {
cldrDom.appendIcon(
Expand Down
3 changes: 1 addition & 2 deletions tools/cldr-apps/js/src/esm/cldrText.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const strings = {
info_panel_selected:
"Description of the currently selected candidate item, including any errors, warnings, or examples",

// pClass ( see DataPage.java)
// Status of candidate item (see CandidateStatus in DataPage.java)
item_description_winner: "This item is currently winning.",
item_description_alias_same_locale:
"This item is inherited from another field in this locale.",
Expand All @@ -175,7 +175,6 @@ const strings = {
"This item is inherited from the root locale.",
item_description_loser: "This item is currently losing.",
item_description_fallback: "This item is inherited from the ${0} locale.",
pClassExplain_desc: "This area shows the item's status.",
followAlias: "Jump to Original ⇒",
noFollowAlias: "This item is constructed from other values.",

Expand Down
8 changes: 4 additions & 4 deletions tools/cldr-apps/js/src/esm/cldrVote.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -410,18 +410,18 @@ function wrapRadio(button) {
*
* @param div {DOM} div to append to
* @param value {String} string value
* @param pClass {String} html class for the voting item
* @param status {String} html class for the voting item
* @return {DOM} the new span
*/
function appendItem(div, value, pClass) {
function appendItem(div, value, status) {
if (!value) {
return;
}
var text = document.createTextNode(value);
var span = document.createElement("span");
span.appendChild(text);
if (pClass) {
span.className = pClass;
if (status) {
span.className = status;
} else {
span.className = "value";
}
Expand Down
2 changes: 1 addition & 1 deletion tools/cldr-apps/js/src/esm/cldrVoteTable.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function add(containerEl, votingResults, item, value, totalVoteCount) {
* background of the candidate value: "alias", "fallback", "fallback_root", etc.
*/
const baileyClass =
item.rawValue === cldrSurvey.INHERITANCE_MARKER ? item.pClass : "";
item.rawValue === cldrSurvey.INHERITANCE_MARKER ? item.status : "";
const wrapper = cldrVue.mount(InfoVoting, containerEl);
wrapper.setData({
totalVoteCount: totalVoteCount,
Expand Down
4 changes: 2 additions & 2 deletions tools/cldr-apps/js/test/TestCldrChecksum.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ const sLong =
'"items":{"4oaR4oaR4oaR":{"tests":[],' +
'"rawValue":"↑↑↑",' +
'"valueHash":"4oaR4oaR4oaR",' +
'"pClass":"fallback",' +
'"status":"fallback",' +
'"isBaselineValue":false,' +
'"value":"↑↑↑",' +
'"example":"<div class=\'cldr_example\'>Chinesisch (Traditionell)"},' +
'"Q2hpbmVzaXNjaCAodHJhZGl0aW9uZWxsKQ":{"tests":[],' +
'"rawValue":"Chinesisch (traditionell)",' +
'"valueHash":"Q2hpbmVzaXNjaCAodHJhZGl0aW9uZWxsKQ",' +
'"pClass":"winner",' +
'"status":"winner",' +
'"isBaselineValue":true,' +
'"votes":{"1442":{"org":"microsoft",' +
'"level":"vetter",' +
Expand Down
Loading
Loading