Send unambiguous inheritance data from server to client (v48)

Original estimate

Description

This is cloned from https://unicode-org.atlassian.net/browse/CLDR-11950 . The original design was that the back end should supply the front end with any URL(s) for linking to the locale(s) and path(s) from which a value is inherited and/or constructed. The design should be reconsidered in light of changes since the old ticket was created. In particular, the “Inheritance Explainer” feature duplicates some of the desired functionality, and the “Jump to original” description/link should be brought into better harmony with the Inheritance Explainer in both content and UI.

What is clear is that this code on the front end (cldrInfo.mjs) still has defects:

/** * 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. * * @param {Object} theRow the row * @param {Object} item the candidate item */ function getLinkUrlAndText(theRow, item) { let linkUrl = null; let linkText = null; if ( item?.value === cldrSurvey.INHERITANCE_MARKER && (theRow?.inheritedLocale || theRow?.inheritedXpid) ) { 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; } } return { linkUrl, linkText }; }

The substitution of "code-fallback" with “root” is something that should be determined on the back end, not the front end. The interpretation that theRow.inheritedXpid being null/undefined (resulting in xpstrid === theRow.xpstrid) implies “This item is constructed from other values” (noFollowAlias ) likewise is too much guesswork on the front end. The back end should make the actual situation unambiguous for constructed values.


Old description (from https://unicode-org.atlassian.net/browse/CLDR-11950 before it was repurposed): the JavaScript function getLinkUrlAndText is the only place inheritedXpid is used on the client. The plan is for the server to send the link URL instead of 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 surveyCurrentLocale in place of inheritedLocale or use xpstrid in place of inheritedXpid.

It’s not clear yet whether inheritedLocale will still be needed on the front end.

Activity

Show:

UnicodeBot 4 days ago

🛬 Merged PR

@btangmu merged a PR to unicode-org/cldr:main

CLDR-18376 Inheritance data: preliminary refactoring on server side (#4529) https://github.com/unicode-org/cldr/pull/4529 https://github.com/unicode-org/cldr/commit/48e72afdcc367b5b764c0448ccdb1d6d383adaf7

Details

Components

Priority

Fix versions

Assignee

Reviewer

Reporter

Time Needed

Hours

Merged

Created March 4, 2025 at 6:32 PM
Updated 4 days ago