diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-05-23 12:33:15 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-05-23 12:33:15 -0300 |
commit | 3ba2440f7b405b0f2556957ad827defe25873c4d (patch) | |
tree | 9cd0024876f0cf7f29445e4c7e97ed31b5c81940 | |
parent | 71eb6ecb8e9b2e4bf0a34fb0726a75d638da50d0 (diff) |
hidden language support
-rw-r--r-- | src/data/things.js | 10 | ||||
-rw-r--r-- | src/misc-templates.js | 2 | ||||
-rwxr-xr-x | src/upd8.js | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/data/things.js b/src/data/things.js index b4737510..daec610c 100644 --- a/src/data/things.js +++ b/src/data/things.js @@ -1466,6 +1466,16 @@ Language.propertyDescriptors = { } }, + // Flag which represents whether or not to hide a language from general + // access. If a language is hidden, its portion of the website will still + // be built (with all strings localized to the language), but it won't be + // included in controls for switching languages or the <link rel=alternate> + // tags used for search engine optimization. This flag is intended for use + // with languages that are currently in development and not ready for + // formal release, or which are just kept hidden as "experimental zones" + // for wiki development or content testing. + hidden: Thing.common.flag(false), + // Mapping of translation keys to values (strings). Generally, don't // access this object directly - use methods instead. strings: { diff --git a/src/misc-templates.js b/src/misc-templates.js index d3817500..f40229d1 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -479,7 +479,7 @@ export function getFooterLocalizationLinks(pathname, { const toArgs = toPath.slice(1); const links = Object.entries(languages) - .filter(([ code ]) => code !== 'default') + .filter(([ code, language ]) => code !== 'default' && !language.hidden) .map(([ code, language ]) => language) .sort(({ name: a }, { name: b }) => a < b ? -1 : a > b ? 1 : 0) .map(language => html.tag('span', html.tag('a', { diff --git a/src/upd8.js b/src/upd8.js index b2f5aa0b..4d51d7f7 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -1332,6 +1332,9 @@ async function processLanguageFile(file) { } delete json['meta.languageName']; + const hidden = json['meta.hidden'] ?? false; + delete json['meta.hidden']; + if (json['meta.baseDirectory']) { logWarn`(${code}) Language JSON still has unused meta.baseDirectory`; delete json['meta.baseDirectory']; @@ -1341,6 +1344,7 @@ async function processLanguageFile(file) { language.code = code; language.intlCode = intlCode; language.name = name; + language.hidden = hidden; language.escapeHTML = string => he.encode(string, {useNamedReferences: true}); language.strings = json; return language; @@ -1972,7 +1976,7 @@ async function main() { const directory = path[1]; const localizedPaths = Object.fromEntries(Object.entries(languages) - .filter(([ key ]) => key !== 'default') + .filter(([ key, language ]) => key !== 'default' && !language.hidden) .map(([ key, language ]) => [language.code, writePage.paths( (language === finalDefaultLanguage ? '' : language.code), 'localized.' + pageSubKey, |