diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 047e0eb18..5cf64e005 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -43,6 +43,9 @@ export default defineVersionedConfig(__dirname, { ...loadLocales(__dirname) }, + // Prevent dead links from being reported as errors - allows partially translated pages to be built. + ignoreDeadLinks: true, + srcExclude: [ "README.md", "LICENSE.md", diff --git a/.vitepress/i18n.ts b/.vitepress/i18n.ts index 9f5c9ddbd..bf18b02f8 100644 --- a/.vitepress/i18n.ts +++ b/.vitepress/i18n.ts @@ -1,8 +1,7 @@ -import { readdirSync, readFileSync } from "fs"; +import { existsSync, readdirSync, readFileSync } from "fs"; import { resolve } from "path/posix"; import { ExtendedSidebarItem } from "./sidebars/utils"; -import { DefaultTheme, LocaleConfig, LocaleSpecificConfig } from "vitepress"; -import inter from "inter"; +import { DefaultTheme, LocaleConfig } from "vitepress"; export function applyTranslations(translationSource: { [key: string]: string; }, fallbackSource: { [key: string]: string }, sidebar: ExtendedSidebarItem[]): ExtendedSidebarItem[] { const sidebarCopy = JSON.parse(JSON.stringify(sidebar)); @@ -45,7 +44,19 @@ export function generateTranslatedSidebars(_rootDir: string, sidebars: { [url: s .map(dirent => dirent.name); for (const folder of translatedFolders) { - const translations: { [key: string]: string; } = JSON.parse(readFileSync(resolve(translatedFolder, folder, "sidebar_translations.json"), "utf-8")); + const sidebarPath = resolve(translatedFolder, folder, "sidebar_translations.json") + + // If sidebar translations dont exist, use english fallback. + if (!existsSync(sidebarPath)) { + for (const sidebarPair of Object.entries(sidebars)) { + const [url, sidebar] = sidebarPair; + sidebarResult[`/${folder}${url}`] = sidebarResult[url]; + } + + continue; + } + + const translations: { [key: string]: string; } = JSON.parse(readFileSync(sidebarPath, "utf-8")); for (const sidebarPair of Object.entries(sidebars)) { const [url, sidebar] = sidebarPair; @@ -71,13 +82,10 @@ export function loadLocales(_rootDir: string): LocaleConfig let firstHalf: string = folder.slice(0, 2); let secondHalf: string = folder.slice(3, 5); - let localeName: string = ""; - if (firstHalf == secondHalf) { - localeName = inter.load(folder).getLanguage(folder.slice(0, 2)).displayName; - } else { - localeName = inter.load(folder).getLanguage(folder).displayName; - } + let locale = new Intl.DisplayNames([`${firstHalf}-${secondHalf.toUpperCase()}`], { type: 'language' }); + let localeName = locale?.of(`${firstHalf}-${secondHalf.toUpperCase()}`)!; + // Capitalize the first letter of the locale name localeName = localeName.charAt(0).toUpperCase() + localeName.slice(1); locales[folder] = { diff --git a/package-lock.json b/package-lock.json index 00c5a24e5..a5840b6e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "packages": { "": { "dependencies": { - "inter": "^2.1.0", "markdown-it-mathjax3": "^4.3.2", "markdown-it-vuepress-code-snippet-enhanced": "github:IMB11/md-it-enhanced-snippets#dfb9fa2", "vitepress": "^1.0.0-rc.33", @@ -1142,35 +1141,11 @@ "node": ">=6" } }, - "node_modules/async": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz", - "integrity": "sha512-XQJ3MipmCHAIBBMFfu2jaSetneOrXbSyyqeU3Nod867oNOpS+i9FEms5PWgjMxSgBybRf2IVVLtr1YfrDO+okg==" - }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" }, - "node_modules/camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha512-wzLkDa4K/mzI1OSITC+DUyjgIl/ETNHE9QvYgy6J6Jvqyyz4C0Xfd+lQhb19sX2jMpZV4IssUn0VDVmglV+s4g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/chainsaw": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.0.9.tgz", - "integrity": "sha512-nG8PYH+/4xB+8zkV4G844EtfvZ5tTiLFoX3dZ4nhF4t3OCKIb9UvaFyNmeZO2zOSmRWzBoTD+napN6hiL+EgcA==", - "dependencies": { - "traverse": ">=0.3.0 <0.4" - }, - "engines": { - "node": "*" - } - }, "node_modules/cheerio": { "version": "1.0.0-rc.10", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.10.tgz", @@ -1206,38 +1181,6 @@ "url": "https://github.com/sponsors/fb55" } }, - "node_modules/cldr": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/cldr/-/cldr-3.5.0.tgz", - "integrity": "sha512-4whGBw4tQO6fueovGTiX7xjzio3KnV0n8cS8MxshLvDH3i9mNOQz3MFlXd4DOp7hIVHZEBJi17akgMb/7PR7zw==", - "dependencies": { - "memoizeasync": "0.8.0", - "passerror": "0.0.1", - "pegjs": "0.7.0", - "seq": "0.3.5", - "uglify-js": "1.3.3", - "underscore": "1.3.3", - "unicoderegexp": "0.4.1", - "xmldom": "0.1.19", - "xpath": "0.0.7" - } - }, - "node_modules/cldr/node_modules/passerror": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/passerror/-/passerror-0.0.1.tgz", - "integrity": "sha512-fq8T/YCS8b1EwvhZPJQD2SURSyvVs2nPXk8EfAikcSeGhg+gL5524bcW9VCuz3hlQhXnPZWr02+3GbtTIFzf9A==", - "engines": { - "node": "*" - } - }, - "node_modules/cldr/node_modules/underscore": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.3.3.tgz", - "integrity": "sha512-ddgUaY7xyrznJ0tbSUZgvNdv5qbiF6XcUBTrHgdCOVUrxJYWozD5KyiRjtIwds1reZ7O1iPLv5rIyqnVAcS6gg==", - "engines": { - "node": "*" - } - }, "node_modules/cli-color": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz", @@ -1301,14 +1244,6 @@ "type": "^1.0.1" } }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/dom-serializer": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", @@ -1516,17 +1451,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/hashish": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/hashish/-/hashish-0.0.4.tgz", - "integrity": "sha512-xyD4XgslstNAs72ENaoFvgMwtv8xhiDtC2AtzCG+8yF7W/Knxxm9BX+e2s25mm+HxMKh0rBmXVOEGF3zNImXvA==", - "dependencies": { - "traverse": ">=0.2.4" - }, - "engines": { - "node": "*" - } - }, "node_modules/hookable": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", @@ -1550,25 +1474,6 @@ "entities": "^2.0.0" } }, - "node_modules/inter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/inter/-/inter-2.1.0.tgz", - "integrity": "sha512-8cZSpFu2Kb3dc3jWnBdbJuZIXs7VScaFU1tqxHu/ue6em3oTpCrjAn4+smjWqvliycTb1x8JL5+HsTOeRtLhkA==", - "dependencies": { - "async": "0.9.0", - "cldr": "3.5.0", - "moment-timezone": "^0.5.40", - "passerror": "1.1.0", - "seq": "=0.3.5", - "uglify-js": "1.3.3", - "uglifyast": "0.2.1", - "underscore": "1.8.3", - "yargs": "3.7.2" - }, - "bin": { - "buildInter": "bin/buildInter" - } - }, "node_modules/is-promise": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", @@ -1608,11 +1513,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/lru-cache": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz", - "integrity": "sha512-dVmQmXPBlTgFw77hm60ud//l2bCuDKkqC2on1EBoM7s9Urm9IQDrnujwZ93NFnAq0dVZ0HBXTS7PwEG+YE7+EQ==" - }, "node_modules/lru-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", @@ -1662,23 +1562,6 @@ "speech-rule-engine": "^4.0.6" } }, - "node_modules/memoizeasync": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/memoizeasync/-/memoizeasync-0.8.0.tgz", - "integrity": "sha512-2lqfGQNyxpKPMUrowJKEt/1xPFhEU+pPFYlS9/dyGUSOttMgn4Yh82DfMvXu40nmTjjm++o4glPMJML//eXGIQ==", - "dependencies": { - "lru-cache": "2.5.0", - "passerror": "0.0.2" - } - }, - "node_modules/memoizeasync/node_modules/passerror": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/passerror/-/passerror-0.0.2.tgz", - "integrity": "sha512-vMAu62amXQNrgTZoZagcnj63atr0y/2WNYIhAoRarQOsfEDhu+xYoPT85lK18MEMUnGHpUrIrb+DHMOq8c5HDA==", - "engines": { - "node": "*" - } - }, "node_modules/memoizee": { "version": "0.4.15", "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", @@ -1730,25 +1613,6 @@ "resolved": "https://registry.npmjs.org/mj-context-menu/-/mj-context-menu-0.6.1.tgz", "integrity": "sha512-7NO5s6n10TIV96d4g2uDpG7ZDpIhMh0QNfGdJw/W47JswFcosz457wqz/b5sAKvl12sxINGFCn80NZHKwxQEXA==" }, - "node_modules/moment": { - "version": "2.30.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", - "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", - "engines": { - "node": "*" - } - }, - "node_modules/moment-timezone": { - "version": "0.5.45", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.45.tgz", - "integrity": "sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==", - "dependencies": { - "moment": "^2.29.4" - }, - "engines": { - "node": "*" - } - }, "node_modules/mrmime": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz", @@ -1822,25 +1686,6 @@ "parse5": "^6.0.1" } }, - "node_modules/passerror": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/passerror/-/passerror-1.1.0.tgz", - "integrity": "sha512-0NQONjhhED7/5Uu7V5BX5WFYPXBRpDS/zDDM90mguEizmwrbs3idSs3QhzLx0Kz6ZBLNVAiZEzc+slOaHrN2zQ==", - "engines": { - "node": "*" - } - }, - "node_modules/pegjs": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.7.0.tgz", - "integrity": "sha512-LKb5vROzG2N6FVpITS8zy4BSB8M5z8JgiM0LzgvUVRIdScHys8RYlYvHVSL3WeXMLowF9MZj1hPusuVvTgeq4w==", - "bin": { - "pegjs": "bin/pegjs" - }, - "engines": { - "node": ">= 0.6.6" - } - }, "node_modules/perfect-debounce": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz", @@ -1941,18 +1786,6 @@ "integrity": "sha512-Orrsjf9trHHxFRuo9/rzm0KIWmgzE8RMlZMzuhZOJ01Rnz3D0YBAe+V6473t6/H6c7irs6Lt48brULAiRWb3Vw==", "peer": true }, - "node_modules/seq": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/seq/-/seq-0.3.5.tgz", - "integrity": "sha512-sisY2Ln1fj43KBkRtXkesnRHYNdswIkIibvNe/0UKm2GZxjMbqmccpiatoKr/k2qX5VKiLU8xm+tz/74LAho4g==", - "dependencies": { - "chainsaw": ">=0.0.7 <0.1", - "hashish": ">=0.0.2 <0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/shiki": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.1.1.tgz", @@ -2046,14 +1879,6 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, - "node_modules/traverse": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==", - "engines": { - "node": "*" - } - }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", @@ -2064,52 +1889,12 @@ "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" }, - "node_modules/uglify-js": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-1.3.3.tgz", - "integrity": "sha512-rM1jYODSisv6Ki54DTEec2YvPv11LAdFVLgrY8fqGzwTDrg1tT91Z8nExx0X375TOptjwJh9MSs6KYQez8XCoQ==", - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": "*" - } - }, - "node_modules/uglifyast": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/uglifyast/-/uglifyast-0.2.1.tgz", - "integrity": "sha512-iCjmXhIvNls8IWA0WsperxT3GNTv3tG0m5HcG7ltERWqutbJ7jAQMBD4l47RpQ/qbrQFwhc6LuNzabQEh6e1Sw==", - "dependencies": { - "uglify-js": "=1.3.2" - } - }, - "node_modules/uglifyast/node_modules/uglify-js": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-1.3.2.tgz", - "integrity": "sha512-XYXlIZ36VB2vS/dKULYHhwgCY3zxGE3Ht+eBrzqVbG3I9NTeb3pP82lNSjK/fdkLFw8fYuZER1/urmeI04jWLg==", - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": "*" - } - }, - "node_modules/underscore": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha512-5WsVTFcH1ut/kkhAaHf4PVgI8c7++GiVcpCGxPouI6ZVjsqPnSDf8h/8HtVqc0t4fzRXwnMK70EcZeAs3PIddg==" - }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "devOptional": true }, - "node_modules/unicoderegexp": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/unicoderegexp/-/unicoderegexp-0.4.1.tgz", - "integrity": "sha512-ydh8D5mdd2ldTS25GtZJEgLciuF0Qf2n3rwPhonELk3HioX201ClYGvZMc1bCmx6nblZiADQwbMWekeIqs51qw==" - }, "node_modules/valid-data-url": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/valid-data-url/-/valid-data-url-3.0.1.tgz", @@ -2347,31 +2132,6 @@ "resolved": "https://registry.npmjs.org/wicked-good-xpath/-/wicked-good-xpath-1.3.0.tgz", "integrity": "sha512-Gd9+TUn5nXdwj/hFsPVx5cuHHiF5Bwuc30jZ4+ronF1qHK5O7HD0sgmXWSEgwKquT3ClLoKPVbO6qGwVwLzvAw==" }, - "node_modules/window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha512-1pTPQDKTdd61ozlKGNCjhNRd+KPmgLSGa3mZTHoOliaGcESD8G1PXhh7c1fgiPjVbNVfgy2Faw4BI8/m0cC8Mg==", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/wordwrap": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha512-xSBsCeh+g+dinoBv3GAOWM4LcVVO68wLXRanibtBSdUvkGWQRGeE9P7IwU9EmDDi4jA6L44lz15CGMwdw9N5+Q==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/xmldom": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.19.tgz", - "integrity": "sha512-pDyxjQSFQgNHkU+yjvoF+GXVGJU7e9EnOg/KcGMDihBIKjTsOeDYaECwC/O9bsUWKY+Sd9izfE43JXC46EOHKA==", - "deprecated": "Deprecated due to CVE-2021-21366 resolved in 0.5.0", - "engines": { - "node": ">=0.1" - } - }, "node_modules/xmldom-sre": { "version": "0.1.31", "resolved": "https://registry.npmjs.org/xmldom-sre/-/xmldom-sre-0.1.31.tgz", @@ -2379,25 +2139,6 @@ "engines": { "node": ">=0.1" } - }, - "node_modules/xpath": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.7.tgz", - "integrity": "sha512-wRXmsfZWSMAPpbvNT42NF6gnQsouCzHZlZikbo0V2bgQsrUm/rhPVeQphsywyOLr8xBA2PuC8VIw0A6hQMHN+g==", - "engines": { - "node": ">=0.6.0" - } - }, - "node_modules/yargs": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.7.2.tgz", - "integrity": "sha512-tekp+l+MFb/mdZOWq7fIMugv6kpbrU3Lo1dCdX07teodernEmzw/wzXs+K3oEnbmoyXlGJ9+QpvMI+5//2uz2A==", - "dependencies": { - "camelcase": "^1.0.2", - "decamelize": "^1.0.0", - "window-size": "0.1.0", - "wordwrap": "0.0.2" - } } } } diff --git a/package.json b/package.json index b016b5322..1b7bde403 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "@rollup/rollup-linux-x64-gnu": "4.6.1" }, "dependencies": { - "inter": "^2.1.0", "markdown-it-mathjax3": "^4.3.2", "markdown-it-vuepress-code-snippet-enhanced": "github:IMB11/md-it-enhanced-snippets#dfb9fa2", "vitepress": "^1.0.0-rc.33",