Compare commits

..

2 Commits

Author SHA1 Message Date
Peter White e7d5134966 changeset 2026-11-30 23:05:51 +00:00
Peter White f822852b04 Enforce api.TranslationLanguage parity and regional OpenAPI locales 2026-11-30 23:05:50 +00:00
15 changed files with 126 additions and 38 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": minor
---
Let visitors choose their country in a country picker, overriding the detected one, on sites that enable it and declare regions. Countries are grouped by the site's regions, then under "Other".
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Strip the trailing slash from the API URL used by browser site search.
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Use a permanent 308 redirect with a bounded Cache-Control header for trailing-slash GET and HEAD requests.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Advertise the public URL in the MCP OAuth metadata of sites served from a custom subdirectory, so MCP clients accept the connection.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Fix MCP sign-in showing "This authorization link has expired" after login on sites served from a custom subdirectory.
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Coalesce typing-prefix search_type_query events and skip single-character ASCII queries before flushing insights batches.
+6
View File
@@ -0,0 +1,6 @@
---
"@gitbook/react-openapi": patch
"gitbook": patch
---
Enforce `api.TranslationLanguage` parity in site UI translations and support `fr-ca`, `es-mx`, and `es-419` locales in OpenAPI blocks.
+21 -21
View File
@@ -109,7 +109,7 @@
},
"packages/gitbook": {
"name": "gitbook",
"version": "0.30.0",
"version": "0.29.0",
"dependencies": {
"@base-ui/react": "catalog:",
"@cloudflare/workers-types": "^4.20251011.0",
@@ -1025,43 +1025,43 @@
"@oxfmt/binding-win32-x64-msvc": ["@oxfmt/binding-win32-x64-msvc@0.62.0", "", { "os": "win32", "cpu": "x64" }, "sha512-dlI5SY7XYQCiCBafntWagCR6HcAJB/NpsLtdlPx8x08+Osz8Ok1HHz1GZuusegCe/VoJ6pAnF5a4pd5OZAq7qQ=="],
"@oxlint/binding-android-arm-eabi": ["@oxlint/binding-android-arm-eabi@1.96.0", "", { "os": "android", "cpu": "arm" }, "sha512-SCINGNIfxMCeONnTjTQdm27XYY3zWv5olN/RIJmoTbMgphJ8JkZMeivswWqPdjwYpTAuskGNpHbevtECumuIxg=="],
"@oxlint/binding-android-arm-eabi": ["@oxlint/binding-android-arm-eabi@1.95.0", "", { "os": "android", "cpu": "arm" }, "sha512-hJna6w3COWJjfMPxomjZL82klTdrITm56PEpCsfO/xMkzQw/fNtJWauQ/YEwQqVttj0L5vDIa8rCcuhfAE3L4w=="],
"@oxlint/binding-android-arm64": ["@oxlint/binding-android-arm64@1.96.0", "", { "os": "android", "cpu": "arm64" }, "sha512-jmRRp4pThMoYheXzhDrEMOHMU6X0geGSzJznkF2xhE9l0aViXNBvZrWasR5WLc3FXlc0rQAtV/o9mH1wosXZGQ=="],
"@oxlint/binding-android-arm64": ["@oxlint/binding-android-arm64@1.95.0", "", { "os": "android", "cpu": "arm64" }, "sha512-uAIGZQ9uJVUeogeWOSboI3F7twOuM4mNuZcHXD9+LdYLcWp7J6kbtRUXJ6GVqcs5E0Cjb4emmSBK9FNrkGuhqQ=="],
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.96.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-RxRoSJY2xa9/dKRzPv1rLn36OvaCwu7Qg9o+NhrSIP7FkLWackAkfbf+5bcgIC5H1r78sdWUvVAIDJKDdfkXPg=="],
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.95.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Ogh1vfHO5vshKRop/He46r+WqC5BTqonYwhB4fp9e2gvOFvg1Xi6XsHTuM/lBSH85ZcaG+DS99EMAy9GcwDong=="],
"@oxlint/binding-darwin-x64": ["@oxlint/binding-darwin-x64@1.96.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-pokl9aeRHG0ke37GooIG/Jjd5bIFx9TDZ9//JkO0KDROJ3MIGz+KD9/hlq6siE40+auswpyaolZ4xNqzaX1VWw=="],
"@oxlint/binding-darwin-x64": ["@oxlint/binding-darwin-x64@1.95.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-kTrE1xfpQUBMMS50Ws6KY92N8OsJ8LE6JqxKqkHEY3KdsmguQ6kKVGSjzyt1HLwsSi0fQCvNRog8YRBBovD1AA=="],
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.96.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-zV8oqk0kzAFa8hsiBXz431E9DvYZuhIOveTKk7bgKmeYy1KixJ//iwdBMvD6+IGq0HAxxX2eCAbdzecC2Qsrpw=="],
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.95.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-ho7E1VCInK0VnpneRaI1BEpe1ceJE8VjxP2O9THWdReV6bth1Q4+80kYVGGK47mHRyZ2NGztQZ2dWRo6j1lavA=="],
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/binding-linux-arm-gnueabihf@1.96.0", "", { "os": "linux", "cpu": "arm" }, "sha512-hT4CHT09eiWrwIikLjqiQrcjF1lASaRrJR4rGwXhHQcXC8Z5ohkDOy897tV/+UK/RkDvhtX3YOV3LGultcJTxg=="],
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/binding-linux-arm-gnueabihf@1.95.0", "", { "os": "linux", "cpu": "arm" }, "sha512-94afnouMHcnHr/OtRh07gG5LehC9M0GjiSoik3xxTtrmq6cWxXOTAhYlBtxa67u/GlycbnHlDoGJfYlTshcr/w=="],
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.96.0", "", { "os": "linux", "cpu": "arm" }, "sha512-ro+mX13ijz/Z2IIstN3TnPjoOzMZmvvS6xj/RIkyWZJveU/W5WkuFkISb81M7dxVDywHNUUljs9kGXL+ZpCkAA=="],
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.95.0", "", { "os": "linux", "cpu": "arm" }, "sha512-LEeclqV1/fafxPgJWN21Bri6HBBBZpEFluq/ZH7Avvu9HjJh/XOn6WwogJqX9X7pG2aITZ2nRH39+sUKEQt2WA=="],
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.96.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-kpJqgwJ4xCzg0HiZr0IqPumqoskk7z9m+epDKC8cxuC6sS5GeX0u8XpuotC7BKto0htzq+AmpZ6/LPIqOJ2J2w=="],
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.95.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-EpXpEQKmgtkvc6RyU84LM1e3CrVDWQkgghVzf1hMGgwjBzgKAJ/QntHgnzmu5cNeLBfa7GPCY+gGXxEll8Adcg=="],
"@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.96.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-sPqrWFuk8IsDx5ftGQVCaxRfnR95b3aXFQrknHDsb0W6UGYkhmhU6ZcirV/9Etyf44dAYo3ZMyA30bRow1sz5w=="],
"@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.95.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-+96Md8c2BAgFp8nWHrUrpqba87DoU+HVJYIun6qA+QKFoeNd3xAWq1JYE6da4nVli9GgwRpfncfRePcgmQQaIQ=="],
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.96.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-41bcNpgz0TDw2bPseL18MWtiyxrkadp5XVqRPr3TmGSDO2NpXdrHQ3UbXOiSpi5Dko7H22iNg9kcl/q/TZrcWA=="],
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.95.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-6yG99vsXct3Uv536w6Z1s03w2makRKnE0q3eJSmf+W/IwPmO56QLk8XUA6ebu/R5peCbJ67HmcWqACH+kg/6Bg=="],
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.96.0", "", { "os": "linux", "cpu": "none" }, "sha512-XsuYByplvx4CjLwBTDNiWEB3Igk1NVgg0jqndZA9Op59ssCqO9PYZmg8af+GMOfrOtpdiFiGnogi0PfvCihGrg=="],
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.95.0", "", { "os": "linux", "cpu": "none" }, "sha512-Eir0Z4ldh55AsQUqVDlLF4Pw3lSFXIdAl8ZNgU8tp/gTwT9JVCzWY0o3+ys9pCcpTN0vCqBwwuQfAUxzbIgvcQ=="],
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.96.0", "", { "os": "linux", "cpu": "none" }, "sha512-J+JcvoObB6gsi3TxaY8tu0gc2ZEcxYbKz7t0N85RurdEU1ubXHTJqKOe8D5aH3KPSmlT3+8f81UhVI4qF4WoUQ=="],
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.95.0", "", { "os": "linux", "cpu": "none" }, "sha512-ceRx+K2WJ7C3tIv+XjZS28oAoZ7DY29ZcWChPdXG5M100phI72FRDYwGRlWZEeDfmkROnarLTMKnnrQAtsC42Q=="],
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.96.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-wON5n7KlNpVWMhzYt9G3Ew2iuL6hHt0LV69dg51quv78mx7jOWFZp/+2ny2vARWl1542RRSip70hb7DAj2yy+Q=="],
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.95.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-WbD3sM08ZDk2QE6060wK/omihQKbRm+LVzKIg4W5zNTbEhYJChciqX49UZuqW59RGF+wBUxzAup7egUIESTjUA=="],
"@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.96.0", "", { "os": "linux", "cpu": "x64" }, "sha512-AURdLIDjJvUK1XjWtnQI6TJs8F3SAQOFsDeL3QQChNwKAWbCZmT4jjflXMb6hjTY6NS1mnP1Z2sWz/yLI1BvTg=="],
"@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.95.0", "", { "os": "linux", "cpu": "x64" }, "sha512-F4ST2ZkFIiLL9OKyRCyC0KQQpwM5WIv0GTcMiZuYVa6xSRJHR05iVRqst+arOVudEPkhP47EnbuoC9UfVCYDyg=="],
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.96.0", "", { "os": "linux", "cpu": "x64" }, "sha512-4+qtiKtCov+b8psbs4/O3nOtNh40bZN/QYxjjmOgV7OHmcD8rBwJqV4AeeXGZ/pSUCGNYGm1sQtiy4AAhJ5xqQ=="],
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.95.0", "", { "os": "linux", "cpu": "x64" }, "sha512-hEpYDZatpuxLrWlTlkwhHZ1e8QkL02aFS55BPQX1XA9iOd+yUEADGFF1iY6z+xkw6RkpzXFrtnDFe4/JNOLSRA=="],
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.96.0", "", { "os": "none", "cpu": "arm64" }, "sha512-eYZmZlTFgwz3c0+nLlZc+QdFTJJQ9B98vvLSk8LPJm+edhhiuLOe6jIUiLWwc52s95GKz5US05cAsVd8e5BzOA=="],
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.95.0", "", { "os": "none", "cpu": "arm64" }, "sha512-+JwIH9/uLgQXfxBvOAKzvp616m5i0fBR5ELEBHm5D+++fStBZ+74T7YW4xBpX13zNU2blr52Swoe3GTF1JyqRg=="],
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.96.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-elsIvBZeDYDO3swjXGBh8kGrsVrlcDNv6X2+ASA7q02UPuAWjH5F8urTa2d32c+f7l9MFohMokdWZ82pV+oZ9Q=="],
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.95.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-pzJgcp3WkOSchukg5y5pn5mVIQ6P83RDI79YJ9gQZKed1pOgjhrmlc5AMizjuq6/P8VifhxzBsMqYI6LLjO2TA=="],
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.96.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-Sl6tX5MdGZ886jSHmeg71ijhtsELauPl4ii4pfAtrQV3W7uj+v5QF1eAZB74KySWt6sdZuNDyjfhaKGaCf6NWA=="],
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.95.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-54MeQvLRXkJqF1nEFs7wb73SrnurZJQy9fVK4NdEwumNKVwyUUxpGHhvfDMIY2NqJZS7kz0pY9uVty5664Gt1Q=="],
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.96.0", "", { "os": "win32", "cpu": "x64" }, "sha512-gLx6y/CsxfNZdfBfSLbVHB75AHDfV2/XdilDqPgh7oNRL6y72s75TCbMt500km+Mk5izFYNYXX8+LYR6U4n/zA=="],
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.95.0", "", { "os": "win32", "cpu": "x64" }, "sha512-I/Fn+Fed1qzb1k2uRjMe2VRtRN1+ZObyU+E76B6v/Ul3Z6JdeAW5zBHSe0n5d8a0ZyU4iorzVy0Rw9LYgo3MSQ=="],
"@panzoom/panzoom": ["@panzoom/panzoom@4.6.1", "", {}, "sha512-ogf/KhHHjj+DYAvHfaf3TXMQ8OE36pJtKpabLlx1OmpjcgtpCvkUoCiNONA8kuVRPGJdLiqMf0n8LRFXj1OyuA=="],
@@ -2691,7 +2691,7 @@
"oxfmt": ["oxfmt@0.62.0", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.62.0", "@oxfmt/binding-android-arm64": "0.62.0", "@oxfmt/binding-darwin-arm64": "0.62.0", "@oxfmt/binding-darwin-x64": "0.62.0", "@oxfmt/binding-freebsd-x64": "0.62.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.62.0", "@oxfmt/binding-linux-arm-musleabihf": "0.62.0", "@oxfmt/binding-linux-arm64-gnu": "0.62.0", "@oxfmt/binding-linux-arm64-musl": "0.62.0", "@oxfmt/binding-linux-ppc64-gnu": "0.62.0", "@oxfmt/binding-linux-riscv64-gnu": "0.62.0", "@oxfmt/binding-linux-riscv64-musl": "0.62.0", "@oxfmt/binding-linux-s390x-gnu": "0.62.0", "@oxfmt/binding-linux-x64-gnu": "0.62.0", "@oxfmt/binding-linux-x64-musl": "0.62.0", "@oxfmt/binding-openharmony-arm64": "0.62.0", "@oxfmt/binding-win32-arm64-msvc": "0.62.0", "@oxfmt/binding-win32-ia32-msvc": "0.62.0", "@oxfmt/binding-win32-x64-msvc": "0.62.0" }, "peerDependencies": { "svelte": "^5.0.0", "vite-plus": "*" }, "optionalPeers": ["svelte", "vite-plus"], "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-vxgGHTmnDU9j4CX7dDBLzxgmHxfda/yPcgJkGCMUSCwRmz+euo/V08xXLNgXTeqAB9Fhf3Pe2nO1RNKLCVgphQ=="],
"oxlint": ["oxlint@1.96.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.96.0", "@oxlint/binding-android-arm64": "1.96.0", "@oxlint/binding-darwin-arm64": "1.96.0", "@oxlint/binding-darwin-x64": "1.96.0", "@oxlint/binding-freebsd-x64": "1.96.0", "@oxlint/binding-linux-arm-gnueabihf": "1.96.0", "@oxlint/binding-linux-arm-musleabihf": "1.96.0", "@oxlint/binding-linux-arm64-gnu": "1.96.0", "@oxlint/binding-linux-arm64-musl": "1.96.0", "@oxlint/binding-linux-ppc64-gnu": "1.96.0", "@oxlint/binding-linux-riscv64-gnu": "1.96.0", "@oxlint/binding-linux-riscv64-musl": "1.96.0", "@oxlint/binding-linux-s390x-gnu": "1.96.0", "@oxlint/binding-linux-x64-gnu": "1.96.0", "@oxlint/binding-linux-x64-musl": "1.96.0", "@oxlint/binding-openharmony-arm64": "1.96.0", "@oxlint/binding-win32-arm64-msvc": "1.96.0", "@oxlint/binding-win32-ia32-msvc": "1.96.0", "@oxlint/binding-win32-x64-msvc": "1.96.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2008", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-jyiSvUjzM6GPHNbNQSk9ov63KDusn7FJaIX4LqxJYN/VnRrEgwMplyZaoAfmVclfzxCmVhaIXLixnRJ2IAa0Hw=="],
"oxlint": ["oxlint@1.95.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.95.0", "@oxlint/binding-android-arm64": "1.95.0", "@oxlint/binding-darwin-arm64": "1.95.0", "@oxlint/binding-darwin-x64": "1.95.0", "@oxlint/binding-freebsd-x64": "1.95.0", "@oxlint/binding-linux-arm-gnueabihf": "1.95.0", "@oxlint/binding-linux-arm-musleabihf": "1.95.0", "@oxlint/binding-linux-arm64-gnu": "1.95.0", "@oxlint/binding-linux-arm64-musl": "1.95.0", "@oxlint/binding-linux-ppc64-gnu": "1.95.0", "@oxlint/binding-linux-riscv64-gnu": "1.95.0", "@oxlint/binding-linux-riscv64-musl": "1.95.0", "@oxlint/binding-linux-s390x-gnu": "1.95.0", "@oxlint/binding-linux-x64-gnu": "1.95.0", "@oxlint/binding-linux-x64-musl": "1.95.0", "@oxlint/binding-openharmony-arm64": "1.95.0", "@oxlint/binding-win32-arm64-msvc": "1.95.0", "@oxlint/binding-win32-ia32-msvc": "1.95.0", "@oxlint/binding-win32-x64-msvc": "1.95.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2008", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-eNzjFjm1TU02/+ohAJjOB7aekRQgTXhOWxMGscEm8VJMokNnnix+PCZn7kqIuGIqxAoBnHxatqlN3Chz3N6PKA=="],
"p-filter": ["p-filter@2.1.0", "", { "dependencies": { "p-map": "^2.0.0" } }, "sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw=="],
+1 -1
View File
@@ -7,7 +7,7 @@
"devDependencies": {
"@changesets/cli": "^2.31.1",
"oxfmt": "^0.62.0",
"oxlint": "^1.96.0",
"oxlint": "^1.95.0",
"turbo": "^2.11.13",
"vercel": "50.37.3"
},
-14
View File
@@ -1,19 +1,5 @@
# gitbook
## 0.30.0
### Minor Changes
- 0f7ca03: Let visitors choose their country in a country picker, overriding the detected one, on sites that enable it and declare regions. Countries are grouped by the site's regions, then under "Other".
### Patch Changes
- 1c8da29: Strip the trailing slash from the API URL used by browser site search.
- 5b326bf: Use a permanent 308 redirect with a bounded Cache-Control header for trailing-slash GET and HEAD requests.
- d51605f: Advertise the public URL in the MCP OAuth metadata of sites served from a custom subdirectory, so MCP clients accept the connection.
- c2daee4: Fix MCP sign-in showing "This authorization link has expired" after login on sites served from a custom subdirectory.
- 348a04d: Coalesce typing-prefix search_type_query events and skip single-character ASCII queries before flushing insights batches.
## 0.29.0
### Minor Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "0.30.0",
"version": "0.29.0",
"private": true,
"dependencies": {
"@base-ui/react": "catalog:",
@@ -1,9 +1,41 @@
import { describe, expect, it } from 'bun:test';
import { TRANSLATION_LANGUAGE_ENUM } from '@gitbook/api';
import { checkIsValidLocale } from '@gitbook/react-openapi';
import { es } from './es';
import { fr } from './fr';
import { isAvailableLanguage, languages, loadLanguage } from './index';
describe('API translation language parity', () => {
it('loads a valid translation bundle for every API translation language', async () => {
for (const locale of TRANSLATION_LANGUAGE_ENUM) {
expect(isAvailableLanguage(locale)).toBe(true);
const language = await loadLanguage(locale);
expect(language).not.toBeNull();
expect(language.locale).toBe(locale);
expect(language.language).toBe(languages[locale].language);
expect(language.flag).toBe(languages[locale].flag);
}
});
it('accepts every regional API translation language whose base language exists in react-openapi', () => {
for (const locale of TRANSLATION_LANGUAGE_ENUM) {
const baseLocale = locale.split('-')[0];
// zh-tw is Traditional Chinese, whereas react-openapi's zh is Simplified Chinese.
if (
baseLocale &&
baseLocale !== locale &&
locale !== 'zh-tw' &&
checkIsValidLocale(baseLocale)
) {
expect(checkIsValidLocale(locale)).toBe(true);
}
}
});
});
describe('regional language variants', () => {
it.each([
['fr-ca', fr],
@@ -1,3 +1,5 @@
import type { TranslationLanguage as APITranslationLanguage } from '@gitbook/api';
import { en } from './en';
import type { TranslationLanguage } from './types';
@@ -185,7 +187,8 @@ const languageDefinitions = {
metadata: { locale: 'sl', language: 'Slovenščina', flag: '🇸🇮' },
load: () => import('./sl').then((module) => module.sl),
},
} satisfies Record<string, LanguageDefinition>;
// Require every API translation language while still allowing locales added ahead of @gitbook/api.
} satisfies Record<APITranslationLanguage, LanguageDefinition> & Record<string, LanguageDefinition>;
export type TranslationLocale = keyof typeof languageDefinitions;
@@ -0,0 +1,28 @@
import { describe, expect, it } from 'bun:test';
import { resolveOpenAPIContext } from '../context';
import { es } from './es';
import { fr } from './fr';
import { checkIsValidLocale } from './index';
describe('regional language variants', () => {
it.each([
['fr-ca', fr],
['es-mx', es],
['es-419', es],
] as const)('accepts %s and resolves its base translation', (locale, expected) => {
expect(checkIsValidLocale(locale)).toBe(true);
const resolved = resolveOpenAPIContext({
locale,
specUrl: null,
scalarRuntimeURL: '',
icons: {} as Parameters<typeof resolveOpenAPIContext>[0]['icons'],
renderCodeBlock: () => null,
renderHeading: () => null,
renderDocument: () => null,
});
expect(resolved.translation).toBe(expected);
});
});
@@ -15,7 +15,10 @@ export const translations = {
en,
de,
es,
'es-mx': es,
'es-419': es,
fr,
'fr-ca': fr,
ja,
nl,
no,