@salesforcedevs/docs-components 1.29.0-alpha1 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,195 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ interface LocaleStrings {
4
+ messageText: string;
5
+ linkUrl: string;
6
+ linkText: string;
7
+ buttonLabel: string;
8
+ secondaryLabel: string;
9
+ }
10
+
11
+ const DEFAULT_LOCALE = "en-us";
12
+
13
+ const LOCALE_STRINGS: Record<string, LocaleStrings> = {
14
+ "en-us": {
15
+ messageText:
16
+ "This text has been translated using Salesforce machine translation system. More details {link}.",
17
+ linkUrl:
18
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1",
19
+ linkText: "here",
20
+ buttonLabel: "Switch to English",
21
+ secondaryLabel: "Not Now"
22
+ },
23
+ "ja-jp": {
24
+ messageText:
25
+ "この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細は{link}をご参照ください。",
26
+ linkUrl:
27
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ja",
28
+ linkText: "こちら",
29
+ buttonLabel: "英語に切り替える",
30
+ secondaryLabel: "今はしません"
31
+ },
32
+ "zh-cn": {
33
+ messageText:
34
+ "此文本已使用 Salesforce 机器翻译系统进行翻译。如需了解更多详情,请点击{link}。",
35
+ linkUrl:
36
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=zh_CN",
37
+ linkText: "此处",
38
+ buttonLabel: "切换为英语",
39
+ secondaryLabel: "而非现在"
40
+ },
41
+ "zh-tw": {
42
+ messageText:
43
+ "此文已使用 Salesforce 機器翻譯系統翻譯。更多詳細資料請參見{link}。",
44
+ linkUrl:
45
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=zh_TW",
46
+ linkText: "此處",
47
+ buttonLabel: "切換至英文",
48
+ secondaryLabel: "不要現在"
49
+ },
50
+ "fr-fr": {
51
+ messageText:
52
+ "Ce texte a été traduit à l’aide du système de traduction automatique de Salesforce. Plus de détails, consultez {link}.",
53
+ linkUrl:
54
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=fr",
55
+ linkText: "cette page",
56
+ buttonLabel: "Basculer vers la page en anglais",
57
+ secondaryLabel: "Pas maintenant"
58
+ },
59
+ "de-de": {
60
+ messageText:
61
+ "Dieser Text wurde mit dem maschinellen Übersetzungssystem von Salesforce übersetzt. Weitere Details finden Sie {link}.",
62
+ linkUrl:
63
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=de",
64
+ linkText: "hier",
65
+ buttonLabel: "Zu Englisch wechseln",
66
+ secondaryLabel: "Nicht jetzt"
67
+ },
68
+ "it-it": {
69
+ messageText:
70
+ "Questo testo è stato tradotto utilizzando il sistema di traduzione automatica di Salesforce. Ulteriori dettagli sono disponibili {link}.",
71
+ linkUrl:
72
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=it",
73
+ linkText: "qui",
74
+ buttonLabel: "Passa all'inglese",
75
+ secondaryLabel: "Non ora"
76
+ },
77
+ "ko-kr": {
78
+ messageText:
79
+ "본 텍스트는 Salesforce 기계 번역 시스템으로 번역되었습니다. 자세한 내용은 {link}를 참조하세요.",
80
+ linkUrl:
81
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ko",
82
+ linkText: "여기",
83
+ buttonLabel: "영어로 전환",
84
+ secondaryLabel: "지금 안 함"
85
+ },
86
+ "pt-br": {
87
+ messageText:
88
+ "Este texto foi traduzido pelo sistema de tradução automática da Salesforce. Mais detalhes {link}.",
89
+ linkUrl:
90
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=pt_BR",
91
+ linkText: "aqui",
92
+ buttonLabel: "Alternar para inglês",
93
+ secondaryLabel: "Agora não"
94
+ },
95
+ "es-mx": {
96
+ messageText:
97
+ "Este texto se tradujo con el sistema de traducción automática de Salesforce. Obtenga más detalles {link}.",
98
+ linkUrl:
99
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=es_MX",
100
+ linkText: "aquí",
101
+ buttonLabel: "Cambiar a inglés",
102
+ secondaryLabel: "Ahora no"
103
+ },
104
+ "es-es": {
105
+ messageText:
106
+ "Este texto se ha traducido utilizando un sistema de traducción automática de Salesforce. Más información {link}.",
107
+ linkUrl:
108
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=es",
109
+ linkText: "aquí",
110
+ buttonLabel: "Cambiar a inglés",
111
+ secondaryLabel: "Ahora no"
112
+ },
113
+ "ru-ru": {
114
+ messageText:
115
+ "Данный текст был переведен при помощи системы машинного перевода Salesforce. Дополнительные сведения см. {link}.",
116
+ linkUrl:
117
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ru",
118
+ linkText: "здесь",
119
+ buttonLabel: "Переключить на английский",
120
+ secondaryLabel: "Не сейчас"
121
+ },
122
+ "fi-fi": {
123
+ messageText:
124
+ "Tämä teksti on käännetty Salesforcen konekäännösjärjestelmän avulla. Katso lisätietoja {link}.",
125
+ linkUrl:
126
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=fi",
127
+ linkText: "täältä",
128
+ buttonLabel: "Vaihda englantiin",
129
+ secondaryLabel: "Ei nyt"
130
+ },
131
+ "da-dk": {
132
+ messageText:
133
+ "Denne tekst er oversat ved hjælp af Salesforce-maskinoversættelsessystem. Du finder flere detaljer {link}.",
134
+ linkUrl:
135
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=da",
136
+ linkText: "her",
137
+ buttonLabel: "Skift til engelsk",
138
+ secondaryLabel: "Ikke nu"
139
+ },
140
+ "sv-se": {
141
+ messageText:
142
+ "Den här texten har översatts med Salesforces maskinöversättningssystem. Mer information {link}.",
143
+ linkUrl:
144
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=sv",
145
+ linkText: "här",
146
+ buttonLabel: "Byt till engelska",
147
+ secondaryLabel: "Inte nu"
148
+ },
149
+ "nl-nl": {
150
+ messageText:
151
+ "Deze tekst werd vertaald aan de hand van het systeem voor automatische vertaling van Salesforce. U vindt {link} meer details.",
152
+ linkUrl:
153
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=nl_NL",
154
+ linkText: "hier",
155
+ buttonLabel: "Overschakelen op Engels",
156
+ secondaryLabel: "Niet nu"
157
+ },
158
+ "nb-no": {
159
+ messageText:
160
+ "Denne teksten er oversatt med Salesforce maskinoversettingssystem. Flere detaljer {link}.",
161
+ linkUrl:
162
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=no",
163
+ linkText: "her",
164
+ buttonLabel: "Bytt til engelsk",
165
+ secondaryLabel: "Ikke nå"
166
+ }
167
+ };
168
+
169
+ export default class LocaleBanner extends LightningElement {
170
+ @api locale = DEFAULT_LOCALE;
171
+ @api targetHref = "";
172
+ @api dismissStorageKey = "";
173
+
174
+ get localeData(): LocaleStrings {
175
+ return LOCALE_STRINGS[this.locale] || LOCALE_STRINGS[DEFAULT_LOCALE];
176
+ }
177
+
178
+ get bannerMessage(): string {
179
+ const data = this.localeData;
180
+ const link = `<a href="${data.linkUrl}">${data.linkText}</a>`;
181
+ return data.messageText.replace("{link}", link);
182
+ }
183
+
184
+ get bannerButtonLabel(): string {
185
+ return this.localeData.buttonLabel;
186
+ }
187
+
188
+ get bannerButtonHref(): string {
189
+ return this.targetHref;
190
+ }
191
+
192
+ get bannerSecondaryLabel(): string {
193
+ return this.localeData.secondaryLabel;
194
+ }
195
+ }
@@ -41,7 +41,7 @@
41
41
  ></path>
42
42
  </g>
43
43
  </svg>
44
- {readingTime} minute read
44
+ {readingTimeLabel}
45
45
  </div>
46
46
  <slot onslotchange={onSlotChange}></slot>
47
47
  <doc-sprig-survey
@@ -57,7 +57,10 @@
57
57
  </div>
58
58
  </div>
59
59
  <div lwc:if={showFooter} class="footer-container">
60
- <dx-footer variant="no-signup" mfe-config-origin={effectiveFooterOrigin}></dx-footer>
60
+ <dx-footer
61
+ variant="no-signup"
62
+ mfe-config-origin={effectiveFooterOrigin}
63
+ ></dx-footer>
61
64
  </div>
62
65
  </div>
63
66
  </div>
@@ -2,12 +2,10 @@
2
2
  import { createElement, LightningElement, api } from "lwc";
3
3
  import DocPhase from "doc/phase";
4
4
  import DxFooter from "dx/footer";
5
+ import DxIcon from "dx/icon";
5
6
  import SprigSurvey from "doc/sprigSurvey";
6
- import ApiPlayground from "doc/apiPlayground";
7
7
  import { throttle } from "throttle-debounce";
8
8
  import { pollUntil } from "dxUtils/async";
9
- import { parseOpenApiSpec } from "docUtils/openApiParser";
10
- import type { OperationDefinition } from "docUtils/openApiParser";
11
9
 
12
10
  declare global {
13
11
  interface Window {
@@ -17,11 +15,19 @@ declare global {
17
15
 
18
16
  declare const Sprig: (eventType: string, eventName: string) => void;
19
17
 
18
+ type ReferenceTopic = {
19
+ link?: { href?: string };
20
+ children?: ReferenceTopic[];
21
+ };
22
+
20
23
  type ReferenceItem = {
21
24
  source: string;
22
25
  href: string;
26
+ title?: string;
23
27
  isSelected?: boolean;
24
28
  docPhase?: string | null;
29
+ referenceType?: string;
30
+ topic?: ReferenceTopic;
25
31
  };
26
32
 
27
33
  type ReferenceConfig = {
@@ -31,6 +37,7 @@ type ReferenceConfig = {
31
37
  const SCROLL_THROTTLE_DELAY = 50;
32
38
  const ELEMENT_TIMEOUT = 10000;
33
39
  const ELEMENT_CHECK_INTERVAL = 100;
40
+ const REFERENCES_SEGMENT = "/references/";
34
41
 
35
42
  export default class RedocReference extends LightningElement {
36
43
  private _referenceConfig: ReferenceConfig = { refList: [] };
@@ -41,11 +48,13 @@ export default class RedocReference extends LightningElement {
41
48
  private docPhaseWrapperElement: Element | null = null;
42
49
  private lastSidebarTop = 0;
43
50
 
44
- showError = false;
51
+ /**
52
+ * History length captured at mount (pre-Redoc), used by `onBackClick` to
53
+ * distinguish in-tab navigation (> 1) from a fresh entry (=== 1).
54
+ */
55
+ private initialHistoryLength = 0;
45
56
 
46
- private parsedOperations: OperationDefinition[] = [];
47
- private openApiSpec: any = null;
48
- private playgroundInstances: Map<string, HTMLElement> = new Map();
57
+ showError = false;
49
58
 
50
59
  @api
51
60
  get referenceConfig(): ReferenceConfig {
@@ -78,6 +87,75 @@ export default class RedocReference extends LightningElement {
78
87
  /** Optional origin URL for the footer MFE (e.g. wp-json endpoint). Passed through to dx-footer. */
79
88
  @api origin: string | null = null;
80
89
 
90
+ /**
91
+ * Project title (same value passed to `<doc-header>` as `subtitle`). Used
92
+ * inside the Redoc-rendered UI to label the parent project.
93
+ */
94
+ @api projectTitle: string | null = "All Reference";
95
+
96
+ get specTitle(): string | null {
97
+ return this.getSelectedReference()?.title ?? null;
98
+ }
99
+
100
+ /**
101
+ * Whether to show the project header (only for multi-spec reference sets).
102
+ */
103
+ get showRedocHeader(): boolean {
104
+ const refCount = this._referenceConfig?.refList?.length ?? 0;
105
+ const isMultiSpecSet = refCount > 1;
106
+ return isMultiSpecSet && !!(this.projectTitle || this.specTitle);
107
+ }
108
+
109
+ /**
110
+ * Navigates back to reference doc.
111
+ */
112
+ private onBackClick = (event: Event): void => {
113
+ event.preventDefault();
114
+ const referrerHref = this.getSameOriginReferrerHref();
115
+ if (referrerHref) {
116
+ window.location.href = referrerHref;
117
+ return;
118
+ }
119
+ const fallbackHref = this.getReferencesRootHref();
120
+ if (fallbackHref) {
121
+ window.location.href = fallbackHref;
122
+ }
123
+ };
124
+
125
+ /**
126
+ * Returns the referrer URL when the page was reached via in-tab navigation
127
+ * from a same-origin page; otherwise `null`. Both `initialHistoryLength`
128
+ * and `document.referrer` are checked since neither signal is reliable on
129
+ * its own.
130
+ */
131
+ private getSameOriginReferrerHref(): string | null {
132
+ if (this.initialHistoryLength <= 1 || !document.referrer) {
133
+ return null;
134
+ }
135
+ try {
136
+ const referrerUrl = new URL(document.referrer);
137
+ if (referrerUrl.origin !== window.location.origin) {
138
+ return null;
139
+ }
140
+ return referrerUrl.href;
141
+ } catch {
142
+ return null;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Derives the project's `.../references` root from the current URL by
148
+ * trimming any trailing reference id (and deeper segments). Returns null
149
+ * when the URL doesn't contain a `/references` segment.
150
+ */
151
+ private getReferencesRootHref(): string | null {
152
+ const { pathname } = window.location;
153
+ const idx = pathname.lastIndexOf(REFERENCES_SEGMENT);
154
+ return idx === -1
155
+ ? null
156
+ : pathname.slice(0, idx + REFERENCES_SEGMENT.length);
157
+ }
158
+
81
159
  /** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
82
160
  get effectiveFooterOrigin(): string {
83
161
  return (
@@ -86,6 +164,10 @@ export default class RedocReference extends LightningElement {
86
164
  }
87
165
 
88
166
  connectedCallback(): void {
167
+ // Snapshot history length before Redoc pushes its own hash entries,
168
+ // so it reflects real in-tab navigation rather than Redoc's churn.
169
+ this.initialHistoryLength = window.history.length;
170
+
89
171
  window.addEventListener("scroll", this.handleScrollAndResize);
90
172
  window.addEventListener("resize", this.handleScrollAndResize);
91
173
  }
@@ -106,7 +188,6 @@ export default class RedocReference extends LightningElement {
106
188
  // Clean up cached DOM element references to prevent memory leaks
107
189
  this.docHeaderElement = null;
108
190
  this.docPhaseWrapperElement = null;
109
- this.playgroundInstances.clear();
110
191
  }
111
192
 
112
193
  // Displays error UI and logs error message for debugging
@@ -220,7 +301,8 @@ export default class RedocReference extends LightningElement {
220
301
  const currentUrl = window.location;
221
302
  const existingParams = currentUrl.search + currentUrl.hash;
222
303
 
223
- window.history.pushState(
304
+ // Use replaceState to avoid creating a new history entry when the user visits /references without any reference ID
305
+ window.history.replaceState(
224
306
  {},
225
307
  "",
226
308
  `${parentReferencePath}${existingParams}`
@@ -254,8 +336,6 @@ export default class RedocReference extends LightningElement {
254
336
  return;
255
337
  }
256
338
 
257
- this.fetchAndParseSpec(specUrl);
258
-
259
339
  window.Redoc.init(
260
340
  specUrl,
261
341
  {
@@ -313,10 +393,12 @@ export default class RedocReference extends LightningElement {
313
393
 
314
394
  this.appendFooterItems(apiContentDiv);
315
395
 
396
+ // Inject the multi-spec project header into Redoc's left menu only.
397
+ this.insertProjectHeaderInMenu(redocContainer);
398
+
316
399
  // Wait for footer to be rendered before updating styles
317
400
  requestAnimationFrame(() => {
318
401
  this.updateRedocThirdColumnStyle(redocContainer);
319
- this.injectTryItButtons();
320
402
 
321
403
  // Fix initial hash scroll after doc phase insertion
322
404
  this.handleInitialHashScrollFix();
@@ -326,6 +408,65 @@ export default class RedocReference extends LightningElement {
326
408
  }
327
409
  }
328
410
 
411
+ /**
412
+ * Inserts the project header into Redoc for multi-spec reference sets.
413
+ */
414
+ private insertProjectHeaderInMenu(redocContainer: HTMLElement): void {
415
+ if (!this.showRedocHeader) {
416
+ return;
417
+ }
418
+
419
+ // Select the LNB and content area of Redoc and insert the requried header.
420
+ redocContainer
421
+ .querySelectorAll<HTMLElement>(".menu-content, .api-content")
422
+ .forEach((target) => {
423
+ target.insertBefore(
424
+ this.buildProjectHeaderDom(),
425
+ target.firstChild
426
+ );
427
+ });
428
+ }
429
+
430
+ /**
431
+ * Builds a fresh project-title/spec-title header DOM node.
432
+ */
433
+ private buildProjectHeaderDom(): HTMLElement {
434
+ const wrapper = document.createElement("div");
435
+ wrapper.className = "redoc-project-header";
436
+
437
+ if (this.projectTitle) {
438
+ const backLink = document.createElement("a");
439
+ backLink.className = "redoc-project-back";
440
+ backLink.href = "#";
441
+ backLink.addEventListener("click", this.onBackClick);
442
+
443
+ const icon = createElement("dx-icon", { is: DxIcon });
444
+ Object.assign(icon, {
445
+ sprite: "utility",
446
+ symbol: "back",
447
+ size: "medium"
448
+ });
449
+ icon.classList.add("redoc-project-back-arrow");
450
+
451
+ const label = document.createElement("span");
452
+ label.className = "redoc-project-title";
453
+ label.textContent = this.projectTitle;
454
+
455
+ backLink.appendChild(icon);
456
+ backLink.appendChild(label);
457
+ wrapper.appendChild(backLink);
458
+ }
459
+
460
+ if (this.specTitle) {
461
+ const specEl = document.createElement("h2");
462
+ specEl.className = "redoc-spec-title dx-text-display-7";
463
+ specEl.textContent = this.specTitle;
464
+ wrapper.appendChild(specEl);
465
+ }
466
+
467
+ return wrapper;
468
+ }
469
+
329
470
  // Waits for Redoc's API content element to be rendered
330
471
  private async waitForApiContent(
331
472
  container: HTMLElement
@@ -359,7 +500,10 @@ export default class RedocReference extends LightningElement {
359
500
  // Appends footer component to container
360
501
  private insertFooter(container: HTMLElement): void {
361
502
  const footerElement = createElement("dx-footer", { is: DxFooter });
362
- Object.assign(footerElement, { variant: "no-signup", mfeConfigOrigin: this.effectiveFooterOrigin });
503
+ Object.assign(footerElement, {
504
+ variant: "no-signup",
505
+ mfeConfigOrigin: this.effectiveFooterOrigin
506
+ });
363
507
  container.appendChild(footerElement);
364
508
  }
365
509
 
@@ -421,114 +565,6 @@ export default class RedocReference extends LightningElement {
421
565
  );
422
566
  }
423
567
 
424
- // Fetches and parses the OpenAPI spec for Try It playground
425
- private async fetchAndParseSpec(specUrl: string): Promise<void> {
426
- try {
427
- const response = await fetch(specUrl);
428
- if (!response.ok) {
429
- return;
430
- }
431
- this.openApiSpec = await response.json();
432
- this.parsedOperations = parseOpenApiSpec(this.openApiSpec);
433
- } catch {
434
- // Non-fatal: playground simply won't be available
435
- }
436
- }
437
-
438
- // Injects "Try It" toggle buttons into Redoc operation sections
439
- private injectTryItButtons(): void {
440
- if (this.parsedOperations.length === 0) {
441
- return;
442
- }
443
-
444
- const redocContainer = this.getRedocContainer();
445
- if (!redocContainer) {
446
- return;
447
- }
448
-
449
- for (const operation of this.parsedOperations) {
450
- const sectionId = `operation/${operation.operationId}`;
451
- const section = redocContainer.querySelector(
452
- `[data-section-id="${sectionId}"]`
453
- );
454
- if (!section) {
455
- continue;
456
- }
457
-
458
- // Skip if button already injected
459
- if (section.querySelector(".try-it-toggle")) {
460
- continue;
461
- }
462
-
463
- const button = document.createElement("button");
464
- button.className = "try-it-toggle";
465
- button.textContent = "Try It";
466
- button.setAttribute("type", "button");
467
- button.setAttribute("aria-expanded", "false");
468
- button.style.cssText =
469
- "display:inline-flex;align-items:center;gap:4px;padding:4px 12px;" +
470
- "border:1px solid #0070d2;border-radius:4px;background:#fff;color:#0070d2;" +
471
- "font-size:12px;font-weight:600;cursor:pointer;margin-left:12px;vertical-align:middle;";
472
- button.addEventListener("click", () => {
473
- this.togglePlayground(operation, section as HTMLElement);
474
- });
475
-
476
- // Insert button after the first heading or at the start
477
- const heading = section.querySelector("h1, h2, h3");
478
- if (heading?.parentElement) {
479
- heading.parentElement.insertBefore(
480
- button,
481
- heading.nextSibling
482
- );
483
- } else {
484
- section.insertBefore(button, section.firstChild);
485
- }
486
- }
487
- }
488
-
489
- // Toggles the playground panel for an operation section
490
- private togglePlayground(
491
- operation: OperationDefinition,
492
- section: HTMLElement
493
- ): void {
494
- const operationId = operation.operationId;
495
- const existingWrapper = this.playgroundInstances.get(operationId);
496
-
497
- if (existingWrapper) {
498
- const isHidden = existingWrapper.style.display === "none";
499
- existingWrapper.style.display = isHidden ? "block" : "none";
500
-
501
- const button = section.querySelector(".try-it-toggle");
502
- if (button) {
503
- button.setAttribute(
504
- "aria-expanded",
505
- isHidden ? "true" : "false"
506
- );
507
- }
508
- return;
509
- }
510
-
511
- const wrapper = document.createElement("div");
512
- wrapper.className = "try-it-playground-wrapper";
513
-
514
- const playgroundElement = createElement("doc-api-playground", {
515
- is: ApiPlayground
516
- });
517
- Object.assign(playgroundElement, {
518
- operation,
519
- spec: this.openApiSpec
520
- });
521
-
522
- wrapper.appendChild(playgroundElement);
523
- section.appendChild(wrapper);
524
- this.playgroundInstances.set(operationId, wrapper);
525
-
526
- const button = section.querySelector(".try-it-toggle");
527
- if (button) {
528
- button.setAttribute("aria-expanded", "true");
529
- }
530
- }
531
-
532
568
  // Fixes initial hash scroll positioning after doc phase insertion
533
569
  private handleInitialHashScrollFix(): void {
534
570
  const hash = window.location.hash;
@@ -53,7 +53,7 @@
53
53
  </doc-content-layout>
54
54
  <div lwc:if={display404}>
55
55
  <dx-error
56
- image="https://a.sfdcstatic.com/developer-website/prod/images/404.svg"
56
+ image="https://developer.salesforce.com/ns-assets/404.svg"
57
57
  code="404"
58
58
  header="Beep boop. That did not compute."
59
59
  subtitle="The document you're looking for doesn't seem to exist."
@@ -322,8 +322,10 @@ export default class DocXmlContent extends LightningElementWithState<{
322
322
  };
323
323
  }
324
324
 
325
- private handlePopState = (event: PopStateEvent): void =>
325
+ private handlePopState = (event: PopStateEvent): void => {
326
326
  this.updatePageReference(this.getReferenceFromUrl(), event);
327
+ this.handleLocaleReload();
328
+ };
327
329
 
328
330
  handleDismissVersionBanner() {
329
331
  this.showVersionBanner = false;
@@ -598,6 +600,31 @@ export default class DocXmlContent extends LightningElementWithState<{
598
600
  "docs",
599
601
  this.pageReferenceToString(this.pageReference)
600
602
  );
603
+ this.handleLocaleReload();
604
+ }
605
+
606
+ /* This method reloads the page as locale banner context is not available in developer-website. */
607
+ private handleLocaleReload(): void {
608
+ const targetLocale = this.language?.id;
609
+ if (!targetLocale) {
610
+ return;
611
+ }
612
+
613
+ const currentPath = window.location.pathname;
614
+ const localePattern = /atlas\.[a-z]{2}-[a-z]{2}\./;
615
+
616
+ if (localePattern.test(currentPath)) {
617
+ const newPath = currentPath.replace(
618
+ localePattern,
619
+ `atlas.${targetLocale}.`
620
+ );
621
+ const newUrl =
622
+ window.location.origin +
623
+ newPath +
624
+ window.location.search +
625
+ window.location.hash;
626
+ window.location.href = newUrl;
627
+ }
601
628
  }
602
629
 
603
630
  private updateHighlighting(searchParam: string): void {