@salesforce/ui-bundle-template-feature-vue-language-switcher 0.0.0-stage → 13.2.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.
Files changed (186) hide show
  1. package/LICENSE.txt +82 -0
  2. package/README.md +141 -2
  3. package/dist/.forceignore +15 -0
  4. package/dist/.husky/pre-commit +4 -0
  5. package/dist/.prettierignore +11 -0
  6. package/dist/.prettierrc +17 -0
  7. package/dist/CHANGELOG.md +5431 -0
  8. package/dist/README.md +83 -0
  9. package/dist/config/project-scratch-def.json +13 -0
  10. package/dist/eslint.config.js +7 -0
  11. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/.forceignore +15 -0
  12. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/.graphqlrc.yml +2 -0
  13. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/.prettierignore +9 -0
  14. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/.prettierrc +11 -0
  15. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/README.md +43 -0
  16. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/codegen.yml +95 -0
  17. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/components.json +19 -0
  18. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/e2e/app.spec.ts +17 -0
  19. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/eslint.config.js +124 -0
  20. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/feature-vue-language-switcher.uibundle-meta.xml +7 -0
  21. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/index.html +12 -0
  22. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/package.json +72 -0
  23. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/playwright.config.ts +24 -0
  24. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/scripts/get-graphql-schema.mjs +71 -0
  25. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/scripts/rewrite-e2e-assets.mjs +23 -0
  26. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/App.vue +5 -0
  27. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/api/graphqlClient.ts +44 -0
  28. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/appLayout.vue +80 -0
  29. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/alerts/status-alert.vue +59 -0
  30. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/layouts/card-layout.vue +30 -0
  31. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/alert/Alert.vue +21 -0
  32. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/alert/AlertAction.vue +17 -0
  33. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/alert/AlertDescription.vue +22 -0
  34. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/alert/AlertTitle.vue +22 -0
  35. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/alert/index.ts +25 -0
  36. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/avatar/Avatar.vue +23 -0
  37. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/avatar/AvatarFallback.vue +31 -0
  38. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/avatar/AvatarImage.vue +16 -0
  39. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/avatar/index.ts +3 -0
  40. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/button/Button.vue +33 -0
  41. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/button/index.ts +43 -0
  42. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/Card.vue +29 -0
  43. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/CardAction.vue +22 -0
  44. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/CardContent.vue +17 -0
  45. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/CardDescription.vue +17 -0
  46. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/CardFooter.vue +22 -0
  47. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/CardHeader.vue +22 -0
  48. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/CardTitle.vue +22 -0
  49. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/card/index.ts +7 -0
  50. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/checkbox/Checkbox.vue +43 -0
  51. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/checkbox/index.ts +1 -0
  52. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/collapsible/Collapsible.vue +19 -0
  53. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/collapsible/CollapsibleContent.vue +12 -0
  54. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/collapsible/CollapsibleTrigger.vue +12 -0
  55. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/collapsible/index.ts +3 -0
  56. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/Dialog.vue +15 -0
  57. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogClose.vue +12 -0
  58. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogContent.vue +59 -0
  59. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogDescription.vue +31 -0
  60. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogFooter.vue +33 -0
  61. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogHeader.vue +17 -0
  62. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogOverlay.vue +31 -0
  63. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogPortal.vue +12 -0
  64. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogTitle.vue +26 -0
  65. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/DialogTrigger.vue +12 -0
  66. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dialog/index.ts +10 -0
  67. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
  68. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +51 -0
  69. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuContent.vue +47 -0
  70. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +12 -0
  71. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuItem.vue +44 -0
  72. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +30 -0
  73. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuPortal.vue +12 -0
  74. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
  75. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +52 -0
  76. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +26 -0
  77. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +19 -0
  78. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
  79. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +37 -0
  80. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +38 -0
  81. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
  82. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/dropdown-menu/index.ts +15 -0
  83. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/Field.vue +27 -0
  84. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldContent.vue +22 -0
  85. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldDescription.vue +24 -0
  86. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldError.vue +48 -0
  87. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldGroup.vue +22 -0
  88. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldLabel.vue +24 -0
  89. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldLegend.vue +29 -0
  90. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldSeparator.vue +31 -0
  91. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldSet.vue +22 -0
  92. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/FieldTitle.vue +22 -0
  93. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/field/index.ts +33 -0
  94. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/index.ts +115 -0
  95. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/input/Input.vue +30 -0
  96. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/input/index.ts +1 -0
  97. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/label/Label.vue +29 -0
  98. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/label/index.ts +1 -0
  99. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/Pagination.vue +17 -0
  100. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/PaginationContent.vue +15 -0
  101. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/PaginationEllipsis.vue +23 -0
  102. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/PaginationItem.vue +7 -0
  103. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/PaginationLink.vue +31 -0
  104. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/PaginationNext.vue +29 -0
  105. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/PaginationPrevious.vue +29 -0
  106. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/pagination/index.ts +7 -0
  107. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/Popover.vue +15 -0
  108. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/PopoverAnchor.vue +12 -0
  109. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/PopoverContent.vue +44 -0
  110. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/PopoverDescription.vue +17 -0
  111. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/PopoverHeader.vue +17 -0
  112. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/PopoverTitle.vue +14 -0
  113. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/PopoverTrigger.vue +12 -0
  114. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/popover/index.ts +7 -0
  115. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/Select.vue +15 -0
  116. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectContent.vue +65 -0
  117. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectGroup.vue +26 -0
  118. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectItem.vue +41 -0
  119. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectLabel.vue +26 -0
  120. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectScrollDownButton.vue +32 -0
  121. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectScrollUpButton.vue +32 -0
  122. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectSeparator.vue +24 -0
  123. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectTrigger.vue +45 -0
  124. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/SelectValue.vue +12 -0
  125. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/select/index.ts +10 -0
  126. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/separator/Separator.vue +33 -0
  127. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/separator/index.ts +1 -0
  128. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/skeleton/Skeleton.vue +15 -0
  129. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/skeleton/index.ts +1 -0
  130. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/sonner/Sonner.vue +29 -0
  131. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/sonner/index.ts +3 -0
  132. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/spinner/Spinner.vue +17 -0
  133. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/components/ui/spinner/index.ts +1 -0
  134. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/composables/useAsyncData.ts +69 -0
  135. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/LanguageSwitcher.vue +75 -0
  136. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/__examples__/language-switcher-example.vue +34 -0
  137. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/__examples__/vite-config-site-example.ts +44 -0
  138. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/buildLanguageUrl.ts +158 -0
  139. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/getCurrentLanguage.ts +59 -0
  140. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/index.ts +31 -0
  141. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/languages.ts +46 -0
  142. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/index.ts +8 -0
  143. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/lib/utils.ts +6 -0
  144. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/main.ts +6 -0
  145. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/pages/Home.vue +10 -0
  146. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/pages/NotFound.vue +18 -0
  147. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/router-utils.ts +32 -0
  148. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/router.ts +40 -0
  149. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/styles/global.css +134 -0
  150. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/test/setup.ts +1 -0
  151. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/src/types/globals.d.ts +23 -0
  152. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/tsconfig.json +45 -0
  153. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/tsconfig.node.json +13 -0
  154. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/tsconfig.tsbuildinfo +1 -0
  155. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/ui-bundle.json +7 -0
  156. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/vite-env.d.ts +14 -0
  157. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/vite.config.ts +106 -0
  158. package/dist/force-app/main/default/uiBundles/feature-vue-language-switcher/vitest-env.d.ts +2 -0
  159. package/dist/jest.config.js +6 -0
  160. package/dist/package-lock.json +12554 -0
  161. package/dist/package.json +46 -0
  162. package/dist/scripts/apex/hello.apex +10 -0
  163. package/dist/scripts/gitignore-templates.json +4 -0
  164. package/dist/scripts/graphql-search.sh +191 -0
  165. package/dist/scripts/network-senders.mjs +84 -0
  166. package/dist/scripts/org-setup-config-schema.mjs +132 -0
  167. package/dist/scripts/org-setup-dev.mjs +114 -0
  168. package/dist/scripts/org-setup-url.mjs +108 -0
  169. package/dist/scripts/org-setup-utils.mjs +569 -0
  170. package/dist/scripts/org-setup-xml.mjs +283 -0
  171. package/dist/scripts/org-setup.config.json +5 -0
  172. package/dist/scripts/org-setup.mjs +2545 -0
  173. package/dist/scripts/sf-project-setup.mjs +103 -0
  174. package/dist/scripts/soql/account.soql +6 -0
  175. package/dist/scripts/validate-org-setup-config.mjs +38 -0
  176. package/dist/sfdx-project.json +12 -0
  177. package/package.json +51 -4
  178. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/LanguageSwitcher.vue +75 -0
  179. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/__examples__/language-switcher-example.vue +34 -0
  180. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/__examples__/vite-config-site-example.ts +44 -0
  181. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/buildLanguageUrl.ts +158 -0
  182. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/getCurrentLanguage.ts +59 -0
  183. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/index.ts +31 -0
  184. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/features/language-switcher/languages.ts +46 -0
  185. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/index.ts +8 -0
  186. package/src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/types/globals.d.ts +23 -0
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Run from SFDX project root: install dependencies, build, and launch the dev server
4
+ * for the UI bundle in force-app/main/default/uiBundles/.
5
+ *
6
+ * Usage: npm run sf-project-setup
7
+ * (from the directory that contains force-app/ and sfdx-project.json)
8
+ */
9
+
10
+ import { spawnSync } from 'node:child_process';
11
+ import { resolve, dirname } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+ import { readdirSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
14
+
15
+ const __dirname = dirname(fileURLToPath(import.meta.url));
16
+ const ROOT = resolve(__dirname, '..');
17
+
18
+ /**
19
+ * npm strips .gitignore from published packages — generate them on first run.
20
+ * Templates are stored in scripts/gitignore-templates.json (generated at build
21
+ * time from the actual .gitignore files). The JSON may not exist in git-cloned
22
+ * distributions where .gitignore is already present, so loading is best-effort.
23
+ */
24
+ function loadGitignoreTemplates() {
25
+ const templatesPath = resolve(__dirname, 'gitignore-templates.json');
26
+ if (!existsSync(templatesPath)) return null;
27
+ try {
28
+ return JSON.parse(readFileSync(templatesPath, 'utf8'));
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+
34
+ function ensureGitignore(dir, content) {
35
+ if (!content) return;
36
+ const gitignorePath = resolve(dir, '.gitignore');
37
+ if (!existsSync(gitignorePath)) {
38
+ writeFileSync(gitignorePath, content, 'utf8');
39
+ console.log(`Created .gitignore in ${dir}`);
40
+ }
41
+ }
42
+
43
+ function resolveUIBundlesDir() {
44
+ const sfdxPath = resolve(ROOT, 'sfdx-project.json');
45
+ if (!existsSync(sfdxPath)) {
46
+ console.error('Error: sfdx-project.json not found at project root.');
47
+ process.exit(1);
48
+ }
49
+ const sfdxProject = JSON.parse(readFileSync(sfdxPath, 'utf8'));
50
+ const pkgDir = sfdxProject?.packageDirectories?.[0]?.path;
51
+ if (!pkgDir) {
52
+ console.error('Error: No packageDirectories[].path found in sfdx-project.json.');
53
+ process.exit(1);
54
+ }
55
+ return resolve(ROOT, pkgDir, 'main', 'default', 'uiBundles');
56
+ }
57
+
58
+ function discoverUIBundleDir() {
59
+ const uiBundlesDir = resolveUIBundlesDir();
60
+ if (!existsSync(uiBundlesDir)) {
61
+ console.error(`Error: uiBundles directory not found: ${uiBundlesDir}`);
62
+ process.exit(1);
63
+ }
64
+ const entries = readdirSync(uiBundlesDir, { withFileTypes: true });
65
+ const dirs = entries.filter((e) => e.isDirectory() && !e.name.startsWith('.'));
66
+ if (dirs.length === 0) {
67
+ console.error(`Error: No UI bundle folder found under ${uiBundlesDir}`);
68
+ process.exit(1);
69
+ }
70
+ if (dirs.length > 1) {
71
+ console.log(`Multiple UI bundles found; using first: ${dirs[0].name}`);
72
+ }
73
+ return resolve(uiBundlesDir, dirs[0].name);
74
+ }
75
+
76
+ function run(label, cmd, args, opts) {
77
+ console.log(`\n--- ${label} ---\n`);
78
+ const result = spawnSync(cmd, args, { stdio: 'inherit', ...opts });
79
+ if (result.status !== 0) {
80
+ process.exit(result.status ?? 1);
81
+ }
82
+ }
83
+
84
+ // Ensure .gitignore files exist (npm strips them from published packages).
85
+ const gitignoreTemplates = loadGitignoreTemplates();
86
+ if (gitignoreTemplates) {
87
+ ensureGitignore(ROOT, gitignoreTemplates.sfdx);
88
+ const bundlesDir = resolveUIBundlesDir();
89
+ if (existsSync(bundlesDir)) {
90
+ for (const entry of readdirSync(bundlesDir, { withFileTypes: true })) {
91
+ if (entry.isDirectory() && !entry.name.startsWith('.')) {
92
+ ensureGitignore(resolve(bundlesDir, entry.name), gitignoreTemplates.webapp);
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ const uiBundleDir = discoverUIBundleDir();
99
+ console.log('SFDX project root:', ROOT);
100
+ console.log('UI bundle directory:', uiBundleDir);
101
+
102
+ run('npm install', 'npm', ['install', '--registry', 'https://registry.npmjs.org/'], { cwd: uiBundleDir });
103
+ run('npm run build', 'npm', ['run', 'build'], { cwd: uiBundleDir });
@@ -0,0 +1,6 @@
1
+ // Use .soql files to store SOQL queries.
2
+ // You can execute queries in VS Code by selecting the
3
+ // query text and running the command:
4
+ // SFDX: Execute SOQL Query with Currently Selected Text
5
+
6
+ SELECT Id, Name FROM Account
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Build / CI gate: validate this package's org-setup.config.json against the
3
+ * shared schema (W-23043729, spec §5.2).
4
+ *
5
+ * Ships inside the SFDX project template, so a generated app can self-check its
6
+ * org-setup.config.json in its own CI:
7
+ * npm run validate:org-setup-config
8
+ *
9
+ * Uses the SAME validateConfig + schema as org-setup.mjs runtime, so build-time
10
+ * and runtime checks can never drift. A missing config file is OK (not every
11
+ * project ships one); a present-but-invalid config fails the gate.
12
+ */
13
+
14
+ import { existsSync, readFileSync } from 'node:fs';
15
+ import { resolve, dirname } from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
17
+
18
+ import { validateConfig } from './org-setup-config-schema.mjs';
19
+
20
+ const __dirname = dirname(fileURLToPath(import.meta.url));
21
+ const configPath = resolve(__dirname, 'org-setup.config.json');
22
+
23
+ if (!existsSync(configPath)) {
24
+ console.log('✓ org-setup.config.json: not present (nothing to validate)');
25
+ process.exit(0);
26
+ }
27
+
28
+ const result = validateConfig(readFileSync(configPath, 'utf8'), configPath);
29
+ if (result.ok) {
30
+ console.log('✓ org-setup.config.json');
31
+ process.exit(0);
32
+ }
33
+
34
+ console.error('❌ org-setup.config.json is invalid:');
35
+ for (const err of result.errors) {
36
+ console.error(` - ${err}`);
37
+ }
38
+ process.exit(1);
@@ -0,0 +1,12 @@
1
+ {
2
+ "packageDirectories": [
3
+ {
4
+ "path": "force-app",
5
+ "default": true
6
+ }
7
+ ],
8
+ "name": "MyProject",
9
+ "namespace": "",
10
+ "sfdcLoginUrl": "https://login.salesforce.com",
11
+ "sourceApiVersion": "67.0"
12
+ }
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle-template-feature-vue-language-switcher",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "13.2.0",
4
+ "description": "Language switcher for B2X Vue UI Bundles — rewrites the URL language segment and reloads",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "author": "",
7
+ "type": "module",
8
+ "main": "src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/index.ts",
9
+ "types": "src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/index.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/index.ts",
13
+ "import": "./src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/index.ts",
14
+ "default": "./src/force-app/main/default/uiBundles/feature-vue-language-switcher/src/index.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "src"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "scripts": {
25
+ "clean": "rm -rf dist"
26
+ },
27
+ "devDependencies": {
28
+ "vue": "^3.5.13",
29
+ "vue-router": "^4.5.0"
30
+ },
31
+ "nx": {
32
+ "targets": {
33
+ "build": {
34
+ "executor": "@salesforce/ui-bundle-template-cli:apply-patches",
35
+ "options": {
36
+ "baseAppPath": "packages/template/base-app/base-vue-app"
37
+ }
38
+ },
39
+ "watch": {
40
+ "executor": "@salesforce/ui-bundle-template-cli:watch-patches",
41
+ "options": {
42
+ "baseAppPath": "packages/template/base-app/base-vue-app"
43
+ }
44
+ },
45
+ "build:dist-app": {
46
+ "executor": "@salesforce/ui-bundle-template-cli:build-dist-app"
47
+ },
48
+ "dev": {
49
+ "executor": "@salesforce/ui-bundle-template-cli:dev-server"
50
+ }
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,75 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2026, Salesforce, Inc.,
4
+ * All rights reserved.
5
+ * For full license text, see the LICENSE.txt file
6
+ */
7
+
8
+ /**
9
+ * Drop-in language switcher for B2X (Experience) apps.
10
+ *
11
+ * Renders a labeled `<select>` of the site's supported {@link LANGUAGES}.
12
+ * Choosing a language rewrites the current URL so the chosen code becomes the
13
+ * first path segment after `basePath` (see {@link buildLanguageUrl}) and reloads
14
+ * the page via `window.location.assign`. A full reload lets the platform serve
15
+ * the correctly localized content — this component owns only the URL rewrite.
16
+ */
17
+
18
+ import { computed } from "vue";
19
+ import { buildLanguageUrl } from "./buildLanguageUrl";
20
+ import { getBasePath, getCurrentLanguage } from "./getCurrentLanguage";
21
+ import { DEFAULT_LANGUAGE, LANGUAGE_CODES, LANGUAGES } from "./languages";
22
+
23
+ const props = withDefaults(
24
+ defineProps<{
25
+ /** Accessible label for the control. Defaults to "Language". */
26
+ label?: string;
27
+ /** Extra classes merged onto the `<select>`. */
28
+ className?: string;
29
+ }>(),
30
+ { label: "Language" },
31
+ );
32
+
33
+ // Render nothing when there is no real choice to make. A single-option dropdown
34
+ // is an inert control: it can't change anything, yet it still takes a focus stop
35
+ // and is announced as a "1 of 1" menu, implying options that don't exist.
36
+ // Omitting it entirely keeps the accessibility tree honest.
37
+ const hasChoice = computed(() => LANGUAGES.length >= 2);
38
+
39
+ const current = getCurrentLanguage();
40
+
41
+ const selectClass = computed(
42
+ () =>
43
+ props.className ??
44
+ "rounded-md border border-border bg-card px-3 py-1.5 text-sm text-foreground",
45
+ );
46
+
47
+ function handleChange(event: Event) {
48
+ const next = (event.target as HTMLSelectElement).value;
49
+ // No-op when the selection already matches the active language.
50
+ if (next === current) return;
51
+
52
+ const nextUrl = buildLanguageUrl(
53
+ window.location.href,
54
+ getBasePath(),
55
+ next,
56
+ LANGUAGE_CODES,
57
+ DEFAULT_LANGUAGE,
58
+ );
59
+ window.location.assign(nextUrl);
60
+ }
61
+ </script>
62
+
63
+ <template>
64
+ <select
65
+ v-if="hasChoice"
66
+ :aria-label="label"
67
+ :value="current"
68
+ :class="selectClass"
69
+ @change="handleChange"
70
+ >
71
+ <option v-for="language in LANGUAGES" :key="language.code" :value="language.code">
72
+ {{ language.label }}
73
+ </option>
74
+ </select>
75
+ </template>
@@ -0,0 +1,34 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2026, Salesforce, Inc.,
4
+ * All rights reserved.
5
+ * For full license text, see the LICENSE.txt file
6
+ */
7
+
8
+ /**
9
+ * Example: mounting <LanguageSwitcher /> in an app layout/header.
10
+ *
11
+ * This file is illustrative — it is copied into the app as an example, not wired
12
+ * into routing. To adopt the switcher, render <LanguageSwitcher /> wherever your
13
+ * app's chrome lives (typically the nav/header in `appLayout.vue`). It manages
14
+ * its own state from the URL + SFDC_ENV, so no props are required.
15
+ */
16
+
17
+ import { RouterView } from "vue-router";
18
+ import { LanguageSwitcher } from "../index";
19
+ </script>
20
+
21
+ <template>
22
+ <nav class="bg-white border-b border-gray-200">
23
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
24
+ <div class="flex justify-between items-center h-16">
25
+ <span class="text-xl font-semibold text-gray-900">Vue App</span>
26
+ <div class="flex items-center gap-2">
27
+ <!-- Drop the switcher anywhere in your header/chrome. -->
28
+ <LanguageSwitcher />
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </nav>
33
+ <RouterView />
34
+ </template>
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /**
8
+ * Example: switching your app's `vite.config.ts` to the SITE entry of
9
+ * `@salesforce/vite-plugin-ui-bundle` so language switching works in local dev.
10
+ *
11
+ * This file is illustrative — it is copied into the app as an example, not used
12
+ * directly. Apply the two changes below to your real `vite.config.ts`.
13
+ *
14
+ * WHY: On a deployed Experience site the platform injects `SFDC_ENV.language`
15
+ * and folds the active language into `SFDC_ENV.basePath` (e.g. `/shop/fr`),
16
+ * recomputed from the URL on every load. The generic local Vite dev server does
17
+ * neither — `SFDC_ENV.language` is absent and `basePath` is always `/` — so the
18
+ * switcher can't route a non-default language locally (the reload 404s and the
19
+ * labels never flip). The SITE entry mirrors production for local dev only.
20
+ *
21
+ * HOW: change the import from the generic plugin to the `/site` subpath, and
22
+ * pass the feature's supported `LANGUAGES` (the single source of truth). The
23
+ * plugin needs the language CODES, so map the `{ code, label }` list to codes.
24
+ * The FIRST entry is the default, served un-prefixed at `/` — matching
25
+ * `DEFAULT_LANGUAGE` in `languages.ts`.
26
+ *
27
+ * This has NO effect on a deployed build; non-site bundles keep the generic
28
+ * `@salesforce/vite-plugin-ui-bundle` import unchanged.
29
+ */
30
+
31
+ // 1. Replace the generic plugin import:
32
+ // import salesforce from "@salesforce/vite-plugin-ui-bundle";
33
+ // with the site entry + the feature's language list:
34
+ import siteUiBundlePlugin from "@salesforce/vite-plugin-ui-bundle/site";
35
+ import { LANGUAGES } from "../languages";
36
+
37
+ // 2. In your `defineConfig({ plugins: [...] })`, replace the `salesforce()`
38
+ // call with `siteUiBundlePlugin(...)`, passing the language codes:
39
+ export const examplePlugins = [
40
+ // tailwindcss(),
41
+ // vue(),
42
+ siteUiBundlePlugin({ languages: LANGUAGES.map((l) => l.code) }),
43
+ // ...codegen
44
+ ];
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /** Strip leading and trailing slashes from a path fragment. */
8
+ function trimSlashes(value: string): string {
9
+ return value.replace(/^\/+/, "").replace(/\/+$/, "");
10
+ }
11
+
12
+ /**
13
+ * Convert a Salesforce locale code to the form used in the URL path.
14
+ *
15
+ * Locale codes use underscores (e.g. `en_US`), but URL path segments use hyphens
16
+ * (e.g. `en-US`). This maps a code to its URL segment.
17
+ */
18
+ function codeToUrlSegment(code: string): string {
19
+ return code.replace(/_/g, "-");
20
+ }
21
+
22
+ /**
23
+ * Convert a hyphenated language token back to a Salesforce locale code — the
24
+ * inverse of {@link codeToUrlSegment} (e.g. `en-US` → `en_US`). Locale codes
25
+ * never contain hyphens, so this remapping is unambiguous. Used both for URL
26
+ * path segments and for the hyphenated `SFDC_ENV.language` value the platform
27
+ * injects (e.g. `"en-US"`), which share the same hyphen convention.
28
+ */
29
+ export function urlSegmentToCode(segment: string): string {
30
+ return segment.replace(/-/g, "_");
31
+ }
32
+
33
+ /**
34
+ * Recover the true, language-free site root from `basePath`.
35
+ *
36
+ * When a non-default language is active, the platform folds the language segment
37
+ * into `SFDC_ENV.basePath` itself — `/shop` becomes `/shop/fr` — rather than
38
+ * leaving `basePath` as the stable site root with the language living in the path
39
+ * after it. If we took `basePath` at face value, the language segment would be
40
+ * treated as part of the base and never seen as a leading language segment, so
41
+ * switching to the default (which should remove the segment) and switching
42
+ * between non-default languages (which should replace it) would both fail.
43
+ *
44
+ * Strip a single trailing segment when it is a known language (remapped from its
45
+ * URL form back to a locale code), yielding the language-free site root so the
46
+ * rest of this module can treat the leading path segment after it as the language.
47
+ */
48
+ function normalizeBasePath(basePath: string, knownCodes: ReadonlySet<string>): string {
49
+ const segments = trimSlashes(basePath).split("/").filter(Boolean);
50
+ const last = segments[segments.length - 1];
51
+ if (last && knownCodes.has(urlSegmentToCode(last))) {
52
+ segments.pop();
53
+ }
54
+ return segments.join("/");
55
+ }
56
+
57
+ /**
58
+ * Return the path segments that live AFTER `basePath` in `pathname`.
59
+ * Both are compared with leading/trailing slashes normalized.
60
+ */
61
+ function segmentsAfterBase(pathname: string, basePath: string): string[] {
62
+ const base = trimSlashes(basePath);
63
+ const trimmedPath = trimSlashes(pathname);
64
+
65
+ let rest = trimmedPath;
66
+ if (base && (trimmedPath === base || trimmedPath.startsWith(`${base}/`))) {
67
+ rest = trimmedPath.slice(base.length);
68
+ }
69
+ return trimSlashes(rest).split("/").filter(Boolean);
70
+ }
71
+
72
+ /**
73
+ * Read the language encoded in a URL: the first path segment after `basePath`,
74
+ * remapped from its URL form (hyphens) back to a locale code (underscores) and
75
+ * returned only when it is one of `knownCodes`. Returns `undefined` when the
76
+ * leading segment is absent or is not a known language code.
77
+ *
78
+ * @param currentUrl Absolute URL to inspect (e.g. `window.location.href`).
79
+ * @param basePath Site root path (e.g. `SFDC_ENV.basePath`); may be `""`.
80
+ * @param knownCodes Language codes considered valid leading segments.
81
+ * @returns The matched locale code (e.g. `en_US`), or `undefined`.
82
+ */
83
+ export function getLanguageFromUrl(
84
+ currentUrl: string,
85
+ basePath: string,
86
+ knownCodes: ReadonlySet<string>,
87
+ ): string | undefined {
88
+ const { pathname } = new URL(currentUrl);
89
+ const siteRoot = normalizeBasePath(basePath, knownCodes);
90
+ const [first] = segmentsAfterBase(pathname, siteRoot);
91
+ if (!first) {
92
+ return undefined;
93
+ }
94
+ const code = urlSegmentToCode(first);
95
+ return knownCodes.has(code) ? code : undefined;
96
+ }
97
+
98
+ /**
99
+ * Rewrite `currentUrl` so `language` is reflected in the first path segment after
100
+ * `basePath`. The rest of the path, the query string, and the hash are preserved.
101
+ *
102
+ * The leading segment after `basePath` is examined and remapped from its URL form
103
+ * (hyphens) back to a locale code before being compared against `knownCodes`:
104
+ *
105
+ * - **Default language** (`language === defaultLanguage`): the default is the
106
+ * implicit, un-prefixed language, so NO segment is written. An existing
107
+ * known-language leading segment is REMOVED (`/shop/fr/page` → `/shop/page`);
108
+ * if there is none, the path is left unchanged.
109
+ * - **Non-default language**: an existing known-language leading segment is
110
+ * REPLACED — so switching never stacks segments (`/en-US/fr/page`) — otherwise
111
+ * the language is INSERTED as a new first segment. The written segment uses the
112
+ * URL form of the code (underscores → hyphens, e.g. `en_US` → `en-US`).
113
+ *
114
+ * When a non-default language is active the platform folds that language into
115
+ * `basePath` itself (`/shop` → `/shop/fr`); a trailing known-language segment is
116
+ * stripped from `basePath` first (see {@link normalizeBasePath}) so the leading
117
+ * segment after the true site root is always what gets replaced/removed/inserted.
118
+ *
119
+ * `basePath` is matched with trailing slashes normalized, and the result never
120
+ * contains double slashes.
121
+ *
122
+ * @param currentUrl Absolute URL to rewrite (e.g. `window.location.href`).
123
+ * @param basePath Site root path (e.g. `SFDC_ENV.basePath`); may be `""`.
124
+ * @param language Locale code to reflect after `basePath` (e.g. `en_US`).
125
+ * @param knownCodes Language codes eligible for the leading-segment check.
126
+ * @param defaultLanguage Locale code that is served without a URL segment.
127
+ * @returns The rewritten absolute URL as a string.
128
+ */
129
+ export function buildLanguageUrl(
130
+ currentUrl: string,
131
+ basePath: string,
132
+ language: string,
133
+ knownCodes: ReadonlySet<string>,
134
+ defaultLanguage: string,
135
+ ): string {
136
+ const url = new URL(currentUrl);
137
+
138
+ const base = normalizeBasePath(basePath, knownCodes);
139
+ const segments = segmentsAfterBase(url.pathname, base);
140
+ const leadingIsLanguage = segments.length > 0 && knownCodes.has(urlSegmentToCode(segments[0]));
141
+
142
+ if (language === defaultLanguage) {
143
+ // The default language is served un-prefixed. Drop an existing language
144
+ // segment so switching back to default removes it, rather than writing one.
145
+ if (leadingIsLanguage) {
146
+ segments.shift();
147
+ }
148
+ } else if (leadingIsLanguage) {
149
+ segments[0] = codeToUrlSegment(language);
150
+ } else {
151
+ segments.unshift(codeToUrlSegment(language));
152
+ }
153
+
154
+ const rebuiltPath = [base, ...segments].filter(Boolean).join("/");
155
+ url.pathname = `/${rebuiltPath}`;
156
+
157
+ return url.toString();
158
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { getLanguageFromUrl, urlSegmentToCode } from "./buildLanguageUrl";
8
+ import { DEFAULT_LANGUAGE, LANGUAGE_CODES } from "./languages";
9
+
10
+ /**
11
+ * The subset of `SFDC_ENV` the switcher reads. We type it structurally here
12
+ * (rather than relying on the ambient `SfdcEnv`) so the feature type-checks in
13
+ * isolation: its ambient augmentation intentionally declares only `language?`,
14
+ * while `basePath` is provided by the platform types once composed into an app.
15
+ */
16
+ interface SfdcEnvSubset {
17
+ basePath?: string;
18
+ /** Page locale in hyphenated form, e.g. "en-US" (the platform's injected form). */
19
+ language?: string;
20
+ }
21
+
22
+ /** Read `SFDC_ENV` off the global scope without assuming it exists. */
23
+ function getSfdcEnv(): SfdcEnvSubset | undefined {
24
+ return (globalThis as { SFDC_ENV?: SfdcEnvSubset }).SFDC_ENV;
25
+ }
26
+
27
+ /**
28
+ * Resolve the active language, in precedence order:
29
+ *
30
+ * 1. `SFDC_ENV.language` — authoritative when the platform provides it. The
31
+ * platform injects this in hyphenated form (e.g. `"en-US"`), so it is
32
+ * remapped back to a locale code (`en_US`) before matching, mirroring how the
33
+ * URL segment is handled.
34
+ * 2. The leading URL path segment after `basePath`, when it is a supported
35
+ * language code — reflects the page the user is actually viewing (e.g. a
36
+ * direct hit on `/shop/fr/catalog`) even before the runtime populates
37
+ * `SFDC_ENV.language`.
38
+ * 3. {@link DEFAULT_LANGUAGE}.
39
+ *
40
+ * Only codes in {@link LANGUAGES} are honored; anything else falls through.
41
+ */
42
+ export function getCurrentLanguage(): string {
43
+ const envLanguage = getSfdcEnv()?.language;
44
+ if (envLanguage) {
45
+ const envCode = urlSegmentToCode(envLanguage);
46
+ if (LANGUAGE_CODES.has(envCode)) {
47
+ return envCode;
48
+ }
49
+ }
50
+
51
+ const basePath = getSfdcEnv()?.basePath ?? "";
52
+ const urlLanguage = getLanguageFromUrl(window.location.href, basePath, LANGUAGE_CODES);
53
+ return urlLanguage ?? DEFAULT_LANGUAGE;
54
+ }
55
+
56
+ /** Read the active `basePath` from `SFDC_ENV`, defaulting to `""`. */
57
+ export function getBasePath(): string {
58
+ return getSfdcEnv()?.basePath ?? "";
59
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /**
8
+ * Public API for the language switcher feature.
9
+ *
10
+ * Most apps only need:
11
+ * ```vue
12
+ * <script setup lang="ts">
13
+ * import { LanguageSwitcher } from "@/features/language-switcher";
14
+ * </script>
15
+ * <template><LanguageSwitcher /></template>
16
+ * ```
17
+ *
18
+ * Lower-level pieces are exported for custom UIs and testing:
19
+ * - {@link getCurrentLanguage} to read the active language
20
+ * - {@link buildLanguageUrl} to compute the rewritten URL yourself
21
+ * - {@link LANGUAGES} / {@link DEFAULT_LANGUAGE} for the supported set
22
+ */
23
+
24
+ export { default as LanguageSwitcher } from "./LanguageSwitcher.vue";
25
+
26
+ export { getCurrentLanguage } from "./getCurrentLanguage";
27
+
28
+ export { buildLanguageUrl, getLanguageFromUrl } from "./buildLanguageUrl";
29
+
30
+ export { LANGUAGES, DEFAULT_LANGUAGE, LANGUAGE_CODES } from "./languages";
31
+ export type { LanguageOption } from "./languages";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /** A single language option offered by the switcher. */
8
+ export interface LanguageOption {
9
+ /** Salesforce locale code, e.g. "en_US". Used as the URL path segment. */
10
+ code: string;
11
+ /** Human-readable label shown in the dropdown, e.g. "English". */
12
+ label: string;
13
+ }
14
+
15
+ /**
16
+ * The languages this app offers in the switcher.
17
+ *
18
+ * IMPORTANT — keep this list in sync BY HAND with the site's language settings:
19
+ * digitalExperiences/site/<siteName>/sfdc_cms__languageSettings/content.json
20
+ *
21
+ * There is no runtime API to read `sfdc_cms__languageSettings` on a published
22
+ * site, so the supported languages are baked into the bundle at authoring time.
23
+ * When the site's content.json changes, update this array (and
24
+ * {@link DEFAULT_LANGUAGE}) to match.
25
+ *
26
+ * `code` values are Salesforce locale codes (underscores). They are converted to
27
+ * hyphenated form for use as the first URL path segment after `basePath` (e.g.
28
+ * `en_US` → `/en-US/...`, `fr` → `/fr/...`). Display order here is the order shown
29
+ * in the dropdown.
30
+ */
31
+ export const LANGUAGES: readonly LanguageOption[] = [
32
+ { code: "en_US", label: "English" },
33
+ { code: "fr", label: "Français" },
34
+ { code: "es", label: "Español" },
35
+ { code: "de", label: "Deutsch" },
36
+ { code: "ja", label: "日本語" },
37
+ ];
38
+
39
+ /**
40
+ * Language used when `SFDC_ENV.language` is missing or is not one of
41
+ * {@link LANGUAGES}. Should match the site's default language in content.json.
42
+ */
43
+ export const DEFAULT_LANGUAGE = "en_US";
44
+
45
+ /** Set of known language codes, for fast membership checks. */
46
+ export const LANGUAGE_CODES: ReadonlySet<string> = new Set(LANGUAGES.map((l) => l.code));