diff --git a/client/src/document/index.scss b/client/src/document/index.scss index 3547a1478b0a..c6dcf2a12e91 100644 --- a/client/src/document/index.scss +++ b/client/src/document/index.scss @@ -30,6 +30,12 @@ } } +.only-in-en-us { + span { + font-size: $small-font-size; + } +} + .article { padding: ($base-spacing / 2) $base-spacing $base-spacing; diff --git a/kumascript/src/api/web.js b/kumascript/src/api/web.js index eafefd4f9687..71e3c86c9e9a 100644 --- a/kumascript/src/api/web.js +++ b/kumascript/src/api/web.js @@ -83,6 +83,27 @@ module.exports = { page.url + hrefhash }"${titleAttribute}${flawAttribute}>${content}`; } + if (!href.toLowerCase().startsWith("/en-us/")) { + // Before flagging this as a broken-link flaw, see if it's possible to + // change it to the en-US URL instead. + const hrefSplit = href.split("/"); + hrefSplit[1] = "en-US"; + const enUSPage = this.info.getPageByURL(hrefSplit.join("/")); + if (enUSPage.url) { + // But it's still a flaw. Record it so that translators can write a + // translated document to "fill the hole". + flaw = this.env.recordNonFatalError( + "broken-link", + `${hrefpath} does not exist but fallbacked on ${enUSPage.url}` + ); + flawAttribute = ` data-flaw-src="${util.htmlEscape(flaw.macroSource)}"`; + return ( + '${content} (en-US)` + ); + } + } flaw = this.env.recordNonFatalError( "broken-link", `${hrefpath} does not exist`