| 1 | import { docsClaudeCode as enDocsClaudeCode } from "./en/docs-claude-code"; |
| 2 | import { docsClaudeCode as zhDocsClaudeCode } from "./zh/docs-claude-code"; |
| 3 | import { docsSkills as enDocsSkills } from "./en/docs-skills"; |
| 4 | import { docsSkills as zhDocsSkills } from "./zh/docs-skills"; |
| 5 | /** |
| 6 | * Dictionary loader for the website localization layer (#3091, #4934). |
| 7 | * |
| 8 | * Lookup is deterministic: a routed locale with a dictionary gets its own |
| 9 | * copy; every other locale gets the English reference dictionary. There is |
| 10 | * no per-key fallback chain — each shipped/partial dictionary is held to |
| 11 | * exact key parity with English by `web/scripts/check-locales.mjs` and |
| 12 | * `dictionaries.test.ts`, so a missing key is a build-time failure, never |
| 13 | * a runtime "missing marker". |
| 14 | * |
| 15 | * English resolves through the `?? enChrome` / `?? enHome` fallback rather |
| 16 | * than a map entry, which keeps `DICTIONARY_LOCALES` equal to the set of |
| 17 | * non-reference locale directories that `check-locales.mjs` walks. |
| 18 | */ |
| 19 | import type { |
| 20 | ChangelogDict, |
| 21 | ChromeDict, |
| 22 | ContributeDict, |
| 23 | ConstitutionDict, |
| 24 | ComputerUseDict, |
| 25 | DocsAuthDict, |
| 26 | DocsConfigurationDict, |
| 27 | DocsFleetDict, |
| 28 | DocsGuideDict, |
| 29 | DocsHooksDict, |
| 30 | DocsMcpDict, |
| 31 | DocsRuntimeApiDict, |
| 32 | DocsSandboxDict, |
| 33 | DocsShellDict, |
| 34 | DocsModesDict, |
| 35 | DocsReviewDict, |
| 36 | DocsVocabularyDict, |
| 37 | DocsSubagentsDict, |
| 38 | DocsTroubleshootingDict, |
| 39 | DocsTrustDict, |
| 40 | DocsFirstTimeDict, |
| 41 | DocsWebDict, |
| 42 | DocsWorkDict, |
| 43 | DocsPetDict, |
| 44 | HomeDict, |
| 45 | FeaturesDict, |
| 46 | DocsPageDict, |
| 47 | FaqDict, |
| 48 | LegalPrivacyDict, |
| 49 | LegalTermsDict, |
| 50 | StatesDict, |
| 51 | } from "./types"; |
| 52 | import { features as features0 } from "./en/features"; |
| 53 | import { features as features1 } from "./zh/features"; |
| 54 | import { features as features2 } from "./ja/features"; |
| 55 | import { features as features3 } from "./vi/features"; |
| 56 | import { features as features4 } from "./ko/features"; |
| 57 | import { features as features5 } from "./ru/features"; |
| 58 | import { features as features6 } from "./uk/features"; |
| 59 | import { features as features7 } from "./es/features"; |
| 60 | import { features as features8 } from "./pt-BR/features"; |
| 61 | import { features as features9 } from "./fr/features"; |
| 62 | import { features as features10 } from "./de/features"; |
| 63 | import { features as features11 } from "./ca/features"; |
| 64 | import { features as features12 } from "./id/features"; |
| 65 | import { features as features13 } from "./hi/features"; |
| 66 | import { features as features14 } from "./tr/features"; |
| 67 | import { features as features15 } from "./it/features"; |
| 68 | import { features as features16 } from "./pl/features"; |
| 69 | import { features as features17 } from "./ar/features"; |
| 70 | import { chrome as enChrome } from "./en/chrome"; |
| 71 | import { home as enHome } from "./en/home"; |
| 72 | import { docsGuide as enDocsGuide } from "./en/docs-guide"; |
| 73 | import { docsGuide as zhDocsGuide } from "./zh/docs-guide"; |
| 74 | import { docsShell as enDocsShell } from "./en/docs-shell"; |
| 75 | import { docsShell as zhDocsShell } from "./zh/docs-shell"; |
| 76 | import { docsHooks as enDocsHooks } from "./en/docs-hooks"; |
| 77 | import { docsHooks as zhDocsHooks } from "./zh/docs-hooks"; |
| 78 | import { docsTroubleshooting as enDocsTroubleshooting } from "./en/docs-troubleshooting"; |
| 79 | import { docsTroubleshooting as zhDocsTroubleshooting } from "./zh/docs-troubleshooting"; |
| 80 | import { docsConfiguration as enDocsConfiguration } from "./en/docs-configuration"; |
| 81 | import { docsConfiguration as zhDocsConfiguration } from "./zh/docs-configuration"; |
| 82 | import { docsFleet as enDocsFleet } from "./en/docs-fleet"; |
| 83 | import { docsFleet as zhDocsFleet } from "./zh/docs-fleet"; |
| 84 | import { docsMcp as enDocsMcp } from "./en/docs-mcp"; |
| 85 | import { docsMcp as zhDocsMcp } from "./zh/docs-mcp"; |
| 86 | import { docsModes as enDocsModes } from "./en/docs-modes"; |
| 87 | import { docsModes as zhDocsModes } from "./zh/docs-modes"; |
| 88 | import { docsRuntimeApi as enDocsRuntimeApi } from "./en/docs-runtime-api"; |
| 89 | import { docsRuntimeApi as zhDocsRuntimeApi } from "./zh/docs-runtime-api"; |
| 90 | import { docsSandbox as enDocsSandbox } from "./en/docs-sandbox"; |
| 91 | import { docsSandbox as zhDocsSandbox } from "./zh/docs-sandbox"; |
| 92 | import { docsSubagents as enDocsSubagents } from "./en/docs-subagents"; |
| 93 | import { docsSubagents as zhDocsSubagents } from "./zh/docs-subagents"; |
| 94 | import { docsWeb as enDocsWeb } from "./en/docs-web"; |
| 95 | import { docsWeb as zhDocsWeb } from "./zh/docs-web"; |
| 96 | import { docsWork as enDocsWork } from "./en/docs-work"; |
| 97 | import { docsWork as zhDocsWork } from "./zh/docs-work"; |
| 98 | import { docsPet as enDocsPet } from "./en/docs-pet"; |
| 99 | import { docsPet as zhDocsPet } from "./zh/docs-pet"; |
| 100 | import { docsAuth as enDocsAuth } from "./en/docs-auth"; |
| 101 | import { docsAuth as zhDocsAuth } from "./zh/docs-auth"; |
| 102 | import { docsTrust as enDocsTrust } from "./en/docs-trust"; |
| 103 | import { docsTrust as zhDocsTrust } from "./zh/docs-trust"; |
| 104 | import { docsFirstTime as enDocsFirstTime } from "./en/docs-first-time"; |
| 105 | import { docsFirstTime as zhDocsFirstTime } from "./zh/docs-first-time"; |
| 106 | import { docsReview as enDocsReview } from "./en/docs-review"; |
| 107 | import { docsReview as zhDocsReview } from "./zh/docs-review"; |
| 108 | import { docsVocabulary as enDocsVocabulary } from "./en/docs-vocabulary"; |
| 109 | import { docsVocabulary as zhDocsVocabulary } from "./zh/docs-vocabulary"; |
| 110 | import { computerUse as enComputerUse } from "./en/computer-use"; |
| 111 | import { computerUse as zhComputerUse } from "./zh/computer-use"; |
| 112 | import { computerUse as jaComputerUse } from "./ja/computer-use"; |
| 113 | import { computerUse as viComputerUse } from "./vi/computer-use"; |
| 114 | import { computerUse as koComputerUse } from "./ko/computer-use"; |
| 115 | import { computerUse as ruComputerUse } from "./ru/computer-use"; |
| 116 | import { computerUse as ukComputerUse } from "./uk/computer-use"; |
| 117 | import { computerUse as esComputerUse } from "./es/computer-use"; |
| 118 | import { computerUse as frComputerUse } from "./fr/computer-use"; |
| 119 | import { computerUse as deComputerUse } from "./de/computer-use"; |
| 120 | import { computerUse as caComputerUse } from "./ca/computer-use"; |
| 121 | import { computerUse as hiComputerUse } from "./hi/computer-use"; |
| 122 | import { computerUse as trComputerUse } from "./tr/computer-use"; |
| 123 | import { computerUse as itComputerUse } from "./it/computer-use"; |
| 124 | import { computerUse as plComputerUse } from "./pl/computer-use"; |
| 125 | import { computerUse as arComputerUse } from "./ar/computer-use"; |
| 126 | import { computerUse as ptBrComputerUse } from "./pt-BR/computer-use"; |
| 127 | import { computerUse as idComputerUse } from "./id/computer-use"; |
| 128 | import { states as enStates } from "./en/states"; |
| 129 | import { states as zhStates } from "./zh/states"; |
| 130 | import { changelog as enChangelog } from "./en/changelog"; |
| 131 | import { changelog as zhChangelog } from "./zh/changelog"; |
| 132 | import { legalTerms as enLegalTerms } from "./en/legal-terms"; |
| 133 | import { legalTerms as zhLegalTerms } from "./zh/legal-terms"; |
| 134 | import { legalPrivacy as enLegalPrivacy } from "./en/legal-privacy"; |
| 135 | import { legalPrivacy as zhLegalPrivacy } from "./zh/legal-privacy"; |
| 136 | import { faq as enFaq } from "./en/faq"; |
| 137 | import { faq as zhFaq } from "./zh/faq"; |
| 138 | import { contribute as enContribute } from "./en/contribute"; |
| 139 | import { contribute as zhContribute } from "./zh/contribute"; |
| 140 | import { contribute as jaContribute } from "./ja/contribute"; |
| 141 | import { contribute as viContribute } from "./vi/contribute"; |
| 142 | import { contribute as koContribute } from "./ko/contribute"; |
| 143 | import { contribute as ruContribute } from "./ru/contribute"; |
| 144 | import { contribute as ukContribute } from "./uk/contribute"; |
| 145 | import { contribute as esContribute } from "./es/contribute"; |
| 146 | import { contribute as ptBrContribute } from "./pt-BR/contribute"; |
| 147 | import { contribute as frContribute } from "./fr/contribute"; |
| 148 | import { contribute as deContribute } from "./de/contribute"; |
| 149 | import { contribute as caContribute } from "./ca/contribute"; |
| 150 | import { contribute as idContribute } from "./id/contribute"; |
| 151 | import { contribute as hiContribute } from "./hi/contribute"; |
| 152 | import { contribute as trContribute } from "./tr/contribute"; |
| 153 | import { contribute as itContribute } from "./it/contribute"; |
| 154 | import { contribute as plContribute } from "./pl/contribute"; |
| 155 | import { contribute as arContribute } from "./ar/contribute"; |
| 156 | import { constitution as enConstitution } from "./en/constitution"; |
| 157 | import { constitution as zhConstitution } from "./zh/constitution"; |
| 158 | import { chrome as zhChrome } from "./zh/chrome"; |
| 159 | import { home as zhHome } from "./zh/home"; |
| 160 | import { chrome as jaChrome } from "./ja/chrome"; |
| 161 | import { home as jaHome } from "./ja/home"; |
| 162 | import { chrome as viChrome } from "./vi/chrome"; |
| 163 | import { home as viHome } from "./vi/home"; |
| 164 | import { chrome as koChrome } from "./ko/chrome"; |
| 165 | import { home as koHome } from "./ko/home"; |
| 166 | import { chrome as ruChrome } from "./ru/chrome"; |
| 167 | import { home as ruHome } from "./ru/home"; |
| 168 | import { chrome as ukChrome } from "./uk/chrome"; |
| 169 | import { home as ukHome } from "./uk/home"; |
| 170 | import { chrome as esChrome } from "./es/chrome"; |
| 171 | import { home as esHome } from "./es/home"; |
| 172 | import { chrome as frChrome } from "./fr/chrome"; |
| 173 | import { home as frHome } from "./fr/home"; |
| 174 | import { docsGuide as frDocsGuide } from "./fr/docs-guide"; |
| 175 | import { chrome as deChrome } from "./de/chrome"; |
| 176 | import { home as deHome } from "./de/home"; |
| 177 | import { docsGuide as deDocsGuide } from "./de/docs-guide"; |
| 178 | import { chrome as caChrome } from "./ca/chrome"; |
| 179 | import { home as caHome } from "./ca/home"; |
| 180 | import { docsGuide as caDocsGuide } from "./ca/docs-guide"; |
| 181 | import { chrome as hiChrome } from "./hi/chrome"; |
| 182 | import { home as hiHome } from "./hi/home"; |
| 183 | import { docsGuide as hiDocsGuide } from "./hi/docs-guide"; |
| 184 | import { chrome as trChrome } from "./tr/chrome"; |
| 185 | import { home as trHome } from "./tr/home"; |
| 186 | import { docsGuide as trDocsGuide } from "./tr/docs-guide"; |
| 187 | import { chrome as itChrome } from "./it/chrome"; |
| 188 | import { home as itHome } from "./it/home"; |
| 189 | import { docsGuide as itDocsGuide } from "./it/docs-guide"; |
| 190 | import { chrome as plChrome } from "./pl/chrome"; |
| 191 | import { home as plHome } from "./pl/home"; |
| 192 | import { docsGuide as plDocsGuide } from "./pl/docs-guide"; |
| 193 | import { chrome as arChrome } from "./ar/chrome"; |
| 194 | import { home as arHome } from "./ar/home"; |
| 195 | import { docsGuide as arDocsGuide } from "./ar/docs-guide"; |
| 196 | import { chrome as ptBrChrome } from "./pt-BR/chrome"; |
| 197 | import { home as ptBrHome } from "./pt-BR/home"; |
| 198 | import { chrome as idChrome } from "./id/chrome"; |
| 199 | import { home as idHome } from "./id/home"; |
| 200 | |
| 201 | const CHROME: Record<string, ChromeDict> = { |
| 202 | zh: zhChrome, |
| 203 | ja: jaChrome, |
| 204 | vi: viChrome, |
| 205 | ko: koChrome, |
| 206 | ru: ruChrome, |
| 207 | uk: ukChrome, |
| 208 | es: esChrome, |
| 209 | fr: frChrome, |
| 210 | de: deChrome, |
| 211 | ca: caChrome, |
| 212 | hi: hiChrome, |
| 213 | tr: trChrome, |
| 214 | it: itChrome, |
| 215 | pl: plChrome, |
| 216 | ar: arChrome, |
| 217 | "pt-BR": ptBrChrome, |
| 218 | id: idChrome, |
| 219 | }; |
| 220 | |
| 221 | const HOME: Record<string, HomeDict> = { |
| 222 | zh: zhHome, |
| 223 | ja: jaHome, |
| 224 | vi: viHome, |
| 225 | ko: koHome, |
| 226 | ru: ruHome, |
| 227 | uk: ukHome, |
| 228 | es: esHome, |
| 229 | fr: frHome, |
| 230 | de: deHome, |
| 231 | ca: caHome, |
| 232 | hi: hiHome, |
| 233 | tr: trHome, |
| 234 | it: itHome, |
| 235 | pl: plHome, |
| 236 | ar: arHome, |
| 237 | "pt-BR": ptBrHome, |
| 238 | id: idHome, |
| 239 | }; |
| 240 | |
| 241 | /** Locales with their own dictionary directory (English is the reference). */ |
| 242 | export const DICTIONARY_LOCALES = Object.keys(CHROME) as readonly string[]; |
| 243 | |
| 244 | /** |
| 245 | * Per-page dictionaries (#5337). Unlike chrome/home, a page dictionary is |
| 246 | * optional per locale: English is the required reference, any locale that |
| 247 | * ships the file is held to exact key parity, and everyone else falls back |
| 248 | * to English here — the same behavior page bodies already had for partial |
| 249 | * locales, now expressed through one lookup instead of an `isZh` ternary. |
| 250 | */ |
| 251 | const DOCS_GUIDE: Record<string, DocsGuideDict> = { |
| 252 | zh: zhDocsGuide, |
| 253 | fr: frDocsGuide, |
| 254 | de: deDocsGuide, |
| 255 | ca: caDocsGuide, |
| 256 | hi: hiDocsGuide, |
| 257 | tr: trDocsGuide, |
| 258 | it: itDocsGuide, |
| 259 | pl: plDocsGuide, |
| 260 | ar: arDocsGuide, |
| 261 | }; |
| 262 | |
| 263 | const DOCS_SHELL: Record<string, DocsShellDict> = { |
| 264 | zh: zhDocsShell, |
| 265 | }; |
| 266 | |
| 267 | const DOCS_HOOKS: Record<string, DocsHooksDict> = { |
| 268 | zh: zhDocsHooks, |
| 269 | }; |
| 270 | |
| 271 | const DOCS_TROUBLESHOOTING: Record<string, DocsTroubleshootingDict> = { |
| 272 | zh: zhDocsTroubleshooting, |
| 273 | }; |
| 274 | |
| 275 | const DOCS_CONFIGURATION: Record<string, DocsConfigurationDict> = { |
| 276 | zh: zhDocsConfiguration, |
| 277 | }; |
| 278 | |
| 279 | const DOCS_FLEET: Record<string, DocsFleetDict> = { |
| 280 | zh: zhDocsFleet, |
| 281 | }; |
| 282 | |
| 283 | const DOCS_MCP: Record<string, DocsMcpDict> = { |
| 284 | zh: zhDocsMcp, |
| 285 | }; |
| 286 | |
| 287 | const DOCS_MODES: Record<string, DocsModesDict> = { |
| 288 | zh: zhDocsModes, |
| 289 | }; |
| 290 | |
| 291 | const DOCS_RUNTIME_API: Record<string, DocsRuntimeApiDict> = { |
| 292 | zh: zhDocsRuntimeApi, |
| 293 | }; |
| 294 | |
| 295 | const DOCS_SANDBOX: Record<string, DocsSandboxDict> = { |
| 296 | zh: zhDocsSandbox, |
| 297 | }; |
| 298 | |
| 299 | const DOCS_SUBAGENTS: Record<string, DocsSubagentsDict> = { |
| 300 | zh: zhDocsSubagents, |
| 301 | }; |
| 302 | |
| 303 | const DOCS_WEB: Record<string, DocsWebDict> = { |
| 304 | zh: zhDocsWeb, |
| 305 | }; |
| 306 | |
| 307 | const DOCS_WORK: Record<string, DocsWorkDict> = { |
| 308 | zh: zhDocsWork, |
| 309 | }; |
| 310 | |
| 311 | const DOCS_PET: Record<string, DocsPetDict> = { |
| 312 | zh: zhDocsPet, |
| 313 | }; |
| 314 | |
| 315 | const DOCS_AUTH: Record<string, DocsAuthDict> = { |
| 316 | zh: zhDocsAuth, |
| 317 | }; |
| 318 | |
| 319 | const COMPUTER_USE: Record<string, ComputerUseDict> = { |
| 320 | zh: zhComputerUse, |
| 321 | ja: jaComputerUse, |
| 322 | vi: viComputerUse, |
| 323 | ko: koComputerUse, |
| 324 | ru: ruComputerUse, |
| 325 | uk: ukComputerUse, |
| 326 | es: esComputerUse, |
| 327 | fr: frComputerUse, |
| 328 | de: deComputerUse, |
| 329 | ca: caComputerUse, |
| 330 | hi: hiComputerUse, |
| 331 | tr: trComputerUse, |
| 332 | it: itComputerUse, |
| 333 | pl: plComputerUse, |
| 334 | ar: arComputerUse, |
| 335 | "pt-BR": ptBrComputerUse, |
| 336 | id: idComputerUse, |
| 337 | }; |
| 338 | |
| 339 | const DOCS_TRUST: Record<string, DocsTrustDict> = { |
| 340 | zh: zhDocsTrust, |
| 341 | }; |
| 342 | |
| 343 | const DOCS_FIRST_TIME: Record<string, DocsFirstTimeDict> = { |
| 344 | zh: zhDocsFirstTime, |
| 345 | }; |
| 346 | |
| 347 | const DOCS_REVIEW: Record<string, DocsReviewDict> = { |
| 348 | zh: zhDocsReview, |
| 349 | }; |
| 350 | |
| 351 | const DOCS_VOCABULARY: Record<string, DocsVocabularyDict> = { |
| 352 | zh: zhDocsVocabulary, |
| 353 | }; |
| 354 | |
| 355 | /** |
| 356 | * Shared surface states, the changelog page, the two legal pages, the FAQ, |
| 357 | * and the contribute and constitution pages follow the same optional per-locale rule as |
| 358 | * the docs page dictionaries: English is the reference, every other locale |
| 359 | * falls back to it at lookup time. |
| 360 | */ |
| 361 | const STATES: Record<string, StatesDict> = { |
| 362 | zh: zhStates, |
| 363 | }; |
| 364 | |
| 365 | const CHANGELOG: Record<string, ChangelogDict> = { |
| 366 | zh: zhChangelog, |
| 367 | }; |
| 368 | |
| 369 | const LEGAL_TERMS: Record<string, LegalTermsDict> = { |
| 370 | zh: zhLegalTerms, |
| 371 | }; |
| 372 | |
| 373 | const LEGAL_PRIVACY: Record<string, LegalPrivacyDict> = { |
| 374 | zh: zhLegalPrivacy, |
| 375 | }; |
| 376 | |
| 377 | const FAQ: Record<string, FaqDict> = { |
| 378 | zh: zhFaq, |
| 379 | }; |
| 380 | |
| 381 | const CONTRIBUTE: Record<string, ContributeDict> = { |
| 382 | zh: zhContribute, |
| 383 | ja: jaContribute, |
| 384 | vi: viContribute, |
| 385 | ko: koContribute, |
| 386 | ru: ruContribute, |
| 387 | uk: ukContribute, |
| 388 | es: esContribute, |
| 389 | "pt-BR": ptBrContribute, |
| 390 | fr: frContribute, |
| 391 | de: deContribute, |
| 392 | ca: caContribute, |
| 393 | id: idContribute, |
| 394 | hi: hiContribute, |
| 395 | tr: trContribute, |
| 396 | it: itContribute, |
| 397 | pl: plContribute, |
| 398 | ar: arContribute, |
| 399 | }; |
| 400 | |
| 401 | const CONSTITUTION: Record<string, ConstitutionDict> = { |
| 402 | zh: zhConstitution, |
| 403 | }; |
| 404 | |
| 405 | const FEATURES: Record<string, FeaturesDict> = { |
| 406 | "en": features0, |
| 407 | "zh": features1, |
| 408 | "ja": features2, |
| 409 | "vi": features3, |
| 410 | "ko": features4, |
| 411 | "ru": features5, |
| 412 | "uk": features6, |
| 413 | "es": features7, |
| 414 | "pt-BR": features8, |
| 415 | "fr": features9, |
| 416 | "de": features10, |
| 417 | "ca": features11, |
| 418 | "id": features12, |
| 419 | "hi": features13, |
| 420 | "tr": features14, |
| 421 | "it": features15, |
| 422 | "pl": features16, |
| 423 | "ar": features17, |
| 424 | }; |
| 425 | |
| 426 | export function getFeatures(locale: string): FeaturesDict { |
| 427 | return FEATURES[locale] ?? features0; |
| 428 | } |
| 429 | |
| 430 | export function getChrome(locale: string): ChromeDict { |
| 431 | return CHROME[locale] ?? enChrome; |
| 432 | } |
| 433 | |
| 434 | export function getHome(locale: string): HomeDict { |
| 435 | return HOME[locale] ?? enHome; |
| 436 | } |
| 437 | |
| 438 | export function getDocsGuide(locale: string): DocsGuideDict { |
| 439 | return DOCS_GUIDE[locale] ?? enDocsGuide; |
| 440 | } |
| 441 | |
| 442 | export function getDocsShell(locale: string): DocsShellDict { |
| 443 | return DOCS_SHELL[locale] ?? enDocsShell; |
| 444 | } |
| 445 | |
| 446 | export function getDocsHooks(locale: string): DocsHooksDict { |
| 447 | return DOCS_HOOKS[locale] ?? enDocsHooks; |
| 448 | } |
| 449 | |
| 450 | export function getDocsTroubleshooting(locale: string): DocsTroubleshootingDict { |
| 451 | return DOCS_TROUBLESHOOTING[locale] ?? enDocsTroubleshooting; |
| 452 | } |
| 453 | |
| 454 | export function getDocsConfiguration(locale: string): DocsConfigurationDict { |
| 455 | return DOCS_CONFIGURATION[locale] ?? enDocsConfiguration; |
| 456 | } |
| 457 | |
| 458 | export function getDocsFleet(locale: string): DocsFleetDict { |
| 459 | return DOCS_FLEET[locale] ?? enDocsFleet; |
| 460 | } |
| 461 | |
| 462 | export function getDocsMcp(locale: string): DocsMcpDict { |
| 463 | return DOCS_MCP[locale] ?? enDocsMcp; |
| 464 | } |
| 465 | |
| 466 | export function getDocsModes(locale: string): DocsModesDict { |
| 467 | return DOCS_MODES[locale] ?? enDocsModes; |
| 468 | } |
| 469 | |
| 470 | export function getDocsRuntimeApi(locale: string): DocsRuntimeApiDict { |
| 471 | return DOCS_RUNTIME_API[locale] ?? enDocsRuntimeApi; |
| 472 | } |
| 473 | |
| 474 | export function getDocsSandbox(locale: string): DocsSandboxDict { |
| 475 | return DOCS_SANDBOX[locale] ?? enDocsSandbox; |
| 476 | } |
| 477 | |
| 478 | export function getDocsSubagents(locale: string): DocsSubagentsDict { |
| 479 | return DOCS_SUBAGENTS[locale] ?? enDocsSubagents; |
| 480 | } |
| 481 | |
| 482 | export function getDocsWeb(locale: string): DocsWebDict { |
| 483 | return DOCS_WEB[locale] ?? enDocsWeb; |
| 484 | } |
| 485 | |
| 486 | export function getDocsWork(locale: string): DocsWorkDict { |
| 487 | return DOCS_WORK[locale] ?? enDocsWork; |
| 488 | } |
| 489 | |
| 490 | export function getDocsPet(locale: string): DocsPetDict { |
| 491 | return DOCS_PET[locale] ?? enDocsPet; |
| 492 | } |
| 493 | |
| 494 | export function getDocsAuth(locale: string): DocsAuthDict { |
| 495 | return DOCS_AUTH[locale] ?? enDocsAuth; |
| 496 | } |
| 497 | |
| 498 | export function getDocsTrust(locale: string): DocsTrustDict { |
| 499 | return DOCS_TRUST[locale] ?? enDocsTrust; |
| 500 | } |
| 501 | |
| 502 | export function getDocsFirstTime(locale: string): DocsFirstTimeDict { |
| 503 | return DOCS_FIRST_TIME[locale] ?? enDocsFirstTime; |
| 504 | } |
| 505 | |
| 506 | export function getDocsReview(locale: string): DocsReviewDict { |
| 507 | return DOCS_REVIEW[locale] ?? enDocsReview; |
| 508 | } |
| 509 | |
| 510 | export function getDocsVocabulary(locale: string): DocsVocabularyDict { |
| 511 | return DOCS_VOCABULARY[locale] ?? enDocsVocabulary; |
| 512 | } |
| 513 | |
| 514 | export function getComputerUse(locale: string): ComputerUseDict { |
| 515 | return COMPUTER_USE[locale] ?? enComputerUse; |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * Locales whose /computer-use page body is translated (the page renders only |
| 520 | * from this dictionary). The content-locale registry derives canonical, |
| 521 | * hreflang and sitemap coverage from it, so they cannot drift apart. |
| 522 | */ |
| 523 | export function hasComputerUseTranslation(locale: string): boolean { |
| 524 | return locale === "en" || Object.hasOwn(COMPUTER_USE, locale); |
| 525 | } |
| 526 | |
| 527 | export function getStates(locale: string): StatesDict { |
| 528 | return STATES[locale] ?? enStates; |
| 529 | } |
| 530 | |
| 531 | export function getChangelog(locale: string): ChangelogDict { |
| 532 | return CHANGELOG[locale] ?? enChangelog; |
| 533 | } |
| 534 | |
| 535 | export function getLegalTerms(locale: string): LegalTermsDict { |
| 536 | return LEGAL_TERMS[locale] ?? enLegalTerms; |
| 537 | } |
| 538 | |
| 539 | export function getLegalPrivacy(locale: string): LegalPrivacyDict { |
| 540 | return LEGAL_PRIVACY[locale] ?? enLegalPrivacy; |
| 541 | } |
| 542 | |
| 543 | export function getFaq(locale: string): FaqDict { |
| 544 | return FAQ[locale] ?? enFaq; |
| 545 | } |
| 546 | |
| 547 | export function getContribute(locale: string): ContributeDict { |
| 548 | return CONTRIBUTE[locale] ?? enContribute; |
| 549 | } |
| 550 | |
| 551 | export function getConstitution(locale: string): ConstitutionDict { |
| 552 | return CONSTITUTION[locale] ?? enConstitution; |
| 553 | } |
| 554 | |
| 555 | /** |
| 556 | * Select the exact available locale from shared content, with English fallback. |
| 557 | * Legacy two-language content keeps the same fallback; migrated content can |
| 558 | * supply the remaining routed locales through the dictionary spine. |
| 559 | */ |
| 560 | export function pickText(pair: { en: string; zh: string; [locale: string]: string | undefined }, locale: string): string { |
| 561 | return pair[locale] ?? pair.en; |
| 562 | } |
| 563 | |
| 564 | /** The actual language selected by the legacy two-language content bridge. */ |
| 565 | export function pickTextLocale(locale: string): "en" | "zh" { |
| 566 | return locale === "zh" ? "zh" : "en"; |
| 567 | } |
| 568 | |
| 569 | /** Reference dictionaries (parity baseline for the locale checks). */ |
| 570 | export const EN_CHROME = enChrome; |
| 571 | export const EN_HOME = enHome; |
| 572 | export const EN_DOCS_GUIDE = enDocsGuide; |
| 573 | export const EN_DOCS_SHELL = enDocsShell; |
| 574 | export const EN_DOCS_HOOKS = enDocsHooks; |
| 575 | export const EN_DOCS_TROUBLESHOOTING = enDocsTroubleshooting; |
| 576 | export const EN_DOCS_CONFIGURATION = enDocsConfiguration; |
| 577 | export const EN_DOCS_FLEET = enDocsFleet; |
| 578 | export const EN_DOCS_MCP = enDocsMcp; |
| 579 | export const EN_DOCS_MODES = enDocsModes; |
| 580 | export const EN_DOCS_RUNTIME_API = enDocsRuntimeApi; |
| 581 | export const EN_DOCS_SANDBOX = enDocsSandbox; |
| 582 | export const EN_DOCS_SUBAGENTS = enDocsSubagents; |
| 583 | export const EN_DOCS_WEB = enDocsWeb; |
| 584 | export const EN_DOCS_WORK = enDocsWork; |
| 585 | export const EN_DOCS_PET = enDocsPet; |
| 586 | export const EN_DOCS_AUTH = enDocsAuth; |
| 587 | export const EN_DOCS_TRUST = enDocsTrust; |
| 588 | export const EN_DOCS_FIRST_TIME = enDocsFirstTime; |
| 589 | export const EN_DOCS_REVIEW = enDocsReview; |
| 590 | export const EN_DOCS_VOCABULARY = enDocsVocabulary; |
| 591 | export const EN_COMPUTER_USE = enComputerUse; |
| 592 | export const EN_STATES = enStates; |
| 593 | export const EN_CHANGELOG = enChangelog; |
| 594 | export const EN_LEGAL_TERMS = enLegalTerms; |
| 595 | export const EN_LEGAL_PRIVACY = enLegalPrivacy; |
| 596 | export const EN_FAQ = enFaq; |
| 597 | export const EN_CONTRIBUTE = enContribute; |
| 598 | export const EN_CONSTITUTION = enConstitution; |
| 599 | |
| 600 | /** Interpolate `{name}` tokens in a dictionary template. Unknown tokens are |
| 601 | * left intact so a template/variable drift is visible in review, not silent. */ |
| 602 | export function fill(template: string, vars: Record<string, string | number>): string { |
| 603 | return template.replace(/\{(\w+)\}/g, (match, name: string) => |
| 604 | name in vars ? String(vars[name]) : match, |
| 605 | ); |
| 606 | } |
| 607 | |
| 608 | /** |
| 609 | * Split a template on a single `{token}` so a call site can typeset the |
| 610 | * substituted value as its own element without concatenating translated |
| 611 | * fragments around it. Returns the literal parts in template order — the |
| 612 | * caller interleaves its node between them, so a locale that puts the token |
| 613 | * in a different position still renders correctly. |
| 614 | */ |
| 615 | export function splitToken(template: string, token: string): string[] { |
| 616 | return template.split(`{${token}}`); |
| 617 | } |
| 618 | |
| 619 | |
| 620 | export function getDocsSkills(locale: string): DocsPageDict { |
| 621 | return locale === "zh" ? zhDocsSkills : enDocsSkills; |
| 622 | } |
| 623 | |
| 624 | export function getDocsClaudeCode(locale: string): DocsPageDict { |
| 625 | return locale === "zh" ? zhDocsClaudeCode : enDocsClaudeCode; |
| 626 | } |
| 627 |