basklee-svelte 0.9.10 → 0.9.12
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.
- package/README.md +2 -2
- package/package.json +1 -1
- package/templates/src/lib/components/basklee/products/StorefrontProduct.README.md +6 -0
- package/templates/src/lib/components/basklee/products/StorefrontProduct.svelte +102 -43
- package/templates/src/lib/stores/baskleeSelections.svelte.ts +19 -1
- package/templates/src/lib/utils/basklee/presentation.ts +53 -0
- package/templates/src/lib/utils/basklee/productGallery.ts +37 -0
- package/templates/src/lib/utils/basklee/reviewLabels.ts +3 -0
- package/templates/src/routes/+layout.server.ts +17 -2
package/README.md
CHANGED
|
@@ -206,7 +206,7 @@ Product details, saved items and the cart.
|
|
|
206
206
|
|
|
207
207
|
| Component | Name | What it does |
|
|
208
208
|
| --- | --- | --- |
|
|
209
|
-
| **Product details** | `StorefrontProduct` | Loads and displays a published product or a secret-key preview with images, purchase choices, details and reviews. |
|
|
209
|
+
| **Product details** | `StorefrontProduct` | Loads and displays a published product or a secret-key preview with images and videos, purchase choices, details and reviews. |
|
|
210
210
|
| **Page path** | `BaskleeBreadcrumbs` | Linked path from the storefront home page through parent categories to the current page. |
|
|
211
211
|
| **Product characteristics** | `ProductSpecificationsDialog` | Every characteristic of the product in a dialog over the page. |
|
|
212
212
|
| **Product reviews** | `ProductReviews` | Reviews, replies, ratings and the user’s submissions. |
|
|
@@ -528,7 +528,7 @@ Page titles, descriptions and link-preview metadata follow the current page
|
|
|
528
528
|
and selected language, including client navigation. Public events and banner
|
|
529
529
|
images come from Application Load.
|
|
530
530
|
A product page takes the product's SEO tab: its heading is the page title (the product name without one), its meta description and keywords fill their tags, and its own Open Graph and Twitter Cards tags are added in the page's language only, replacing a default tag of the same name.
|
|
531
|
-
Pages with a canonical address also link the same page in the other storefront languages (`hreflang`) and set `og:type` and `og:locale`; a journal article adds its publication date (`article:published_time`) and schema.org `BlogPosting` data. The store icon (`logos.ico`) is the page's `<link rel="icon">`. An unknown `?locale` opens the
|
|
531
|
+
Pages with a canonical address also link the same page in the other storefront languages (`hreflang`) and set `og:type` and `og:locale`; a journal article adds its publication date (`article:published_time`) and schema.org `BlogPosting` data. The store icon (`logos.ico`) is the page's `<link rel="icon">`. An unknown `?locale` opens the language closest to the browser's, else the first one. A first visit without `?locale` opens in the storefront language closest to the browser's languages (`Accept-Language`; `navigator.languages` in the app build): the same code first, then the same language (`ru-RU` finds `ru`, `en` finds `en-GB`); the first available language when none of them is offered.
|
|
532
532
|
|
|
533
533
|
List pages (journal, categories, stores) link their previous and next pages as real links (`?page=2`). Each later page has its own canonical address and a title with its page number; a journal page past the last one answers 404.
|
|
534
534
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-svelte",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"description": "SvelteKit 2 storefront for your Basklee marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English, Russian and Spanish, plus an Android app build. Powered by Basklee: https://basklee.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,6 +8,12 @@ preview address with `?key=` uses `products_preview`, so anyone with the complet
|
|
|
8
8
|
preview address can view it without signing in. The request also runs during server
|
|
9
9
|
rendering so the product is present in the HTML.
|
|
10
10
|
|
|
11
|
+
The media are the photos, then the product's videos (`product.videos`, from the Video
|
|
12
|
+
tab of the panel; a video without a file is left out). A video's thumbnail shows its
|
|
13
|
+
`preview` frame under a round play mark; choosing it plays the video with the browser's
|
|
14
|
+
controls in the main image's place, never by itself. The full-screen viewer shows the
|
|
15
|
+
photos only.
|
|
16
|
+
|
|
11
17
|
Under the reviews, “You may also like” shows the products attached to this product on
|
|
12
18
|
the panel's Relevant Products tab (`related.data`, without the product itself, up to
|
|
13
19
|
eight). Only a product without attached products shows up to eight more products of its
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
import { safeArticleHtml } from '@/lib/utils/basklee/richText';
|
|
34
34
|
import { htmlTextParagraphs } from '@/lib/utils/basklee/htmlText';
|
|
35
35
|
import {
|
|
36
|
+
productMediaItems,
|
|
36
37
|
thumbnailKeyTarget,
|
|
37
38
|
thumbnailRailEdges,
|
|
38
39
|
thumbnailScrollTarget,
|
|
@@ -203,6 +204,13 @@
|
|
|
203
204
|
const images = product.value?.images;
|
|
204
205
|
return images?.full?.length ? images.full : (images?.small ?? []);
|
|
205
206
|
});
|
|
207
|
+
// The gallery: the photos, then the product's videos (Video tab of the
|
|
208
|
+
// panel). A video plays in the large photo's place; the full-screen viewer
|
|
209
|
+
// keeps to the photos, which come first, so their numbers are the same.
|
|
210
|
+
const media = computed(() => productMediaItems(product.value));
|
|
211
|
+
const current = computed(
|
|
212
|
+
() => media.value[image.value] ?? media.value[0],
|
|
213
|
+
);
|
|
206
214
|
// The first request in the browser shows a placeholder with the page
|
|
207
215
|
// layout; a later retry after an error shows it again. A product loaded
|
|
208
216
|
// during the server render is shown at once.
|
|
@@ -528,7 +536,7 @@
|
|
|
528
536
|
}
|
|
529
537
|
|
|
530
538
|
function showImage(index: number) {
|
|
531
|
-
const count =
|
|
539
|
+
const count = media.value.length;
|
|
532
540
|
image.value = (index + count) % count;
|
|
533
541
|
}
|
|
534
542
|
|
|
@@ -555,7 +563,7 @@
|
|
|
555
563
|
showImage(
|
|
556
564
|
productPhotoAfterSwipe(
|
|
557
565
|
image.value,
|
|
558
|
-
|
|
566
|
+
media.value.length,
|
|
559
567
|
touch.clientX - start.x,
|
|
560
568
|
touch.clientY - start.y,
|
|
561
569
|
),
|
|
@@ -666,7 +674,7 @@
|
|
|
666
674
|
|
|
667
675
|
// Arrow keys, Home and End move between thumbnails, which form one tab stop.
|
|
668
676
|
function thumbnailKeydown(event: KeyboardEvent, index: number) {
|
|
669
|
-
const target = thumbnailKeyTarget(event.key, index,
|
|
677
|
+
const target = thumbnailKeyTarget(event.key, index, media.value.length);
|
|
670
678
|
|
|
671
679
|
if (target === undefined) {
|
|
672
680
|
return;
|
|
@@ -809,7 +817,7 @@
|
|
|
809
817
|
revealThumbnail(index);
|
|
810
818
|
});
|
|
811
819
|
// Another variant's photos start from the first thumbnail.
|
|
812
|
-
watch(
|
|
820
|
+
watch(media, async () => {
|
|
813
821
|
await nextTick();
|
|
814
822
|
|
|
815
823
|
if (rail.value) {
|
|
@@ -877,7 +885,7 @@
|
|
|
877
885
|
`,
|
|
878
886
|
]}
|
|
879
887
|
>
|
|
880
|
-
{#if
|
|
888
|
+
{#if media.value.length}
|
|
881
889
|
<section
|
|
882
890
|
aria-label={labels.value.gallery}
|
|
883
891
|
data-product-gallery
|
|
@@ -897,40 +905,64 @@
|
|
|
897
905
|
relative min-w-0 @min-[560px]/product:col-start-2
|
|
898
906
|
@min-[560px]/product:row-start-1 @min-[960px]/product:min-h-96
|
|
899
907
|
`,
|
|
900
|
-
|
|
908
|
+
media.value.length > 1 && 'touch-pan-y',
|
|
901
909
|
]}
|
|
902
910
|
ontouchstart={startSwipe}
|
|
903
911
|
ontouchend={endSwipe}
|
|
904
912
|
>
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
913
|
+
{#if current.value?.kind === 'video'}
|
|
914
|
+
{#key current.value.key}
|
|
915
|
+
<video
|
|
916
|
+
src={current.value.src}
|
|
917
|
+
poster={current.value.preview || undefined}
|
|
918
|
+
aria-label={labels.value.productVideo}
|
|
919
|
+
controls
|
|
920
|
+
playsinline
|
|
921
|
+
preload="metadata"
|
|
922
|
+
data-product-video
|
|
923
|
+
class={[
|
|
924
|
+
`
|
|
925
|
+
box-border aspect-square h-auto max-h-[70vh] w-full bg-basklee-surface
|
|
926
|
+
object-contain @min-[560px]/product:aspect-[4/5]
|
|
927
|
+
@min-[960px]/product:absolute @min-[960px]/product:inset-0
|
|
928
|
+
@min-[960px]/product:m-auto @min-[960px]/product:aspect-auto
|
|
929
|
+
@min-[960px]/product:h-full
|
|
930
|
+
@min-[960px]/product:max-h-[calc(100vh-12rem)]
|
|
931
|
+
`,
|
|
932
|
+
]}
|
|
933
|
+
></video>
|
|
934
|
+
{/key}
|
|
935
|
+
{:else if current.value}
|
|
936
|
+
<BaskleeImage
|
|
937
|
+
src={current.value.src}
|
|
938
|
+
alt={title.value}
|
|
939
|
+
width={800}
|
|
940
|
+
height={1000}
|
|
941
|
+
loading="eager"
|
|
942
|
+
role="button"
|
|
943
|
+
tabindex="0"
|
|
944
|
+
aria-label={labels.value.openProductPhoto}
|
|
945
|
+
data-product-photo-open
|
|
946
|
+
onclick={() => {
|
|
947
|
+
viewerOpen.value = true;
|
|
948
|
+
}}
|
|
949
|
+
onkeydown={openViewerKey}
|
|
950
|
+
class={[
|
|
951
|
+
`
|
|
952
|
+
box-border aspect-square h-auto max-h-[70vh] w-full bg-basklee-surface
|
|
953
|
+
cursor-zoom-in outline-none focus-visible:outline-1
|
|
954
|
+
focus-visible:outline-solid focus-visible:outline-basklee-text
|
|
955
|
+
object-contain @min-[560px]/product:aspect-[4/5]
|
|
956
|
+
@min-[960px]/product:absolute @min-[960px]/product:inset-0
|
|
957
|
+
@min-[960px]/product:m-auto @min-[960px]/product:aspect-auto
|
|
958
|
+
@min-[960px]/product:h-full
|
|
959
|
+
@min-[960px]/product:max-h-[calc(100vh-12rem)]
|
|
960
|
+
`,
|
|
961
|
+
]}
|
|
962
|
+
/>
|
|
963
|
+
{/if}
|
|
932
964
|
|
|
933
|
-
{#if
|
|
965
|
+
{#if media.value.length > 1}
|
|
934
966
|
<button
|
|
935
967
|
type="button"
|
|
936
968
|
aria-label={labels.value.previousImage}
|
|
@@ -990,7 +1022,7 @@
|
|
|
990
1022
|
{/if}
|
|
991
1023
|
</div>
|
|
992
1024
|
|
|
993
|
-
{#if
|
|
1025
|
+
{#if media.value.length > 1}
|
|
994
1026
|
<div
|
|
995
1027
|
data-product-thumbnail-rail
|
|
996
1028
|
class={[
|
|
@@ -1014,13 +1046,14 @@
|
|
|
1014
1046
|
`,
|
|
1015
1047
|
]}
|
|
1016
1048
|
>
|
|
1017
|
-
{#each
|
|
1049
|
+
{#each media.value as item, index (item.key)}
|
|
1018
1050
|
<button
|
|
1019
1051
|
type="button"
|
|
1020
|
-
aria-label={`${labels.value.gallery} ${index + 1}`}
|
|
1052
|
+
aria-label={`${item.kind === 'video' ? labels.value.productVideo : labels.value.gallery} ${index + 1}`}
|
|
1021
1053
|
aria-pressed={index === image.value}
|
|
1022
1054
|
tabindex={index === image.value ? 0 : -1}
|
|
1023
1055
|
data-product-thumbnail={index}
|
|
1056
|
+
data-product-thumbnail-video={item.kind === 'video' || undefined}
|
|
1024
1057
|
onclick={() => {
|
|
1025
1058
|
image.value = index;
|
|
1026
1059
|
}}
|
|
@@ -1029,7 +1062,7 @@
|
|
|
1029
1062
|
}}
|
|
1030
1063
|
class={[
|
|
1031
1064
|
`
|
|
1032
|
-
box-border h-[70px] w-14 shrink-0 p-1 @min-[560px]/product:h-[90px]
|
|
1065
|
+
relative box-border h-[70px] w-14 shrink-0 p-1 @min-[560px]/product:h-[90px]
|
|
1033
1066
|
@min-[560px]/product:w-[72px] cursor-pointer border border-solid
|
|
1034
1067
|
bg-basklee-surface outline-none transition-[opacity,border-color]
|
|
1035
1068
|
motion-reduce:transition-none hover:opacity-100 focus-visible:border-2
|
|
@@ -1040,11 +1073,37 @@
|
|
|
1040
1073
|
: 'border-transparent opacity-75',
|
|
1041
1074
|
]}
|
|
1042
1075
|
>
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1076
|
+
{#if item.kind === 'image' || item.preview}
|
|
1077
|
+
<BaskleeImage
|
|
1078
|
+
src={item.kind === 'image' ? item.src : (item.preview as string)}
|
|
1079
|
+
alt=""
|
|
1080
|
+
class={[
|
|
1081
|
+
'h-full w-full',
|
|
1082
|
+
item.kind === 'image' ? 'object-contain' : 'object-cover',
|
|
1083
|
+
]}
|
|
1084
|
+
/>
|
|
1085
|
+
{/if}
|
|
1086
|
+
{#if item.kind === 'video'}
|
|
1087
|
+
<span
|
|
1088
|
+
aria-hidden="true"
|
|
1089
|
+
data-product-video-mark
|
|
1090
|
+
class={[
|
|
1091
|
+
`
|
|
1092
|
+
absolute inset-0 m-auto grid h-7 w-7 place-items-center rounded-full
|
|
1093
|
+
bg-basklee-text/80 text-basklee-surface
|
|
1094
|
+
`,
|
|
1095
|
+
]}
|
|
1096
|
+
>
|
|
1097
|
+
<svg
|
|
1098
|
+
viewBox="0 0 24 24"
|
|
1099
|
+
class="ml-0.5 h-3.5 w-3.5"
|
|
1100
|
+
fill="currentColor"
|
|
1101
|
+
aria-hidden="true"
|
|
1102
|
+
>
|
|
1103
|
+
<path d="M8 5v14l11-7z" />
|
|
1104
|
+
</svg>
|
|
1105
|
+
</span>
|
|
1106
|
+
{/if}
|
|
1048
1107
|
</button>
|
|
1049
1108
|
{/each}
|
|
1050
1109
|
</div>
|
|
@@ -3,6 +3,7 @@ import type { ComputedRef } from '@/lib/basklee/reactivity.svelte';
|
|
|
3
3
|
import { defineStore } from '@/lib/basklee/scope.svelte';
|
|
4
4
|
import type { StoreScope } from '@/lib/basklee/scope.svelte';
|
|
5
5
|
import { resolveBaskleeDomain } from '@/lib/stores/baskleeDomainAccess.svelte';
|
|
6
|
+
import { closestLocale } from '@/lib/utils/basklee/presentation';
|
|
6
7
|
import '@/lib/stores/basklee.svelte';
|
|
7
8
|
import type { IAppLoadCommon } from '@/lib/interfaces/basklee/appBase/IAppLoadCommon';
|
|
8
9
|
|
|
@@ -81,9 +82,26 @@ export function useBaskleeSelections(
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
// A language still offered stays; in the browser (the app build loads
|
|
86
|
+
// there) the one closest to navigator.languages; else the first one.
|
|
87
|
+
function browserLocale() {
|
|
88
|
+
if (typeof window === 'undefined') {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
const code = closestLocale(
|
|
92
|
+
Object.entries(locales.value).map(
|
|
93
|
+
([key, value]) => value.code?.trim() || key,
|
|
94
|
+
),
|
|
95
|
+
window.navigator.languages ?? [],
|
|
96
|
+
);
|
|
97
|
+
return code ? findLocale(code) : undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
84
100
|
function reconcile() {
|
|
85
101
|
const selected =
|
|
86
|
-
findLocale(localeCode.value) ??
|
|
102
|
+
findLocale(localeCode.value) ??
|
|
103
|
+
browserLocale() ??
|
|
104
|
+
Object.entries(locales.value)[0];
|
|
87
105
|
localeCode.value = selected?.[1].code?.trim() || selected?.[0] || '';
|
|
88
106
|
currencyId.value = availableCurrency(
|
|
89
107
|
currencies.value[currencyId.value]?.allowed_select
|
|
@@ -70,3 +70,56 @@ export function localesMatch(left: string, right: string) {
|
|
|
70
70
|
value.trim().toLowerCase().replaceAll('_', '-');
|
|
71
71
|
return normalize(left) === normalize(right);
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The languages a customer's browser asks for, most wanted first: an
|
|
76
|
+
* Accept-Language header («ru-RU,ru;q=0.9,en;q=0.8») or navigator.languages.
|
|
77
|
+
*/
|
|
78
|
+
export function wantedLanguages(
|
|
79
|
+
source: string | readonly string[] | null | undefined,
|
|
80
|
+
): string[] {
|
|
81
|
+
if (!source) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
if (typeof source !== 'string') {
|
|
85
|
+
return source.map((tag) => tag.trim()).filter(Boolean);
|
|
86
|
+
}
|
|
87
|
+
return source
|
|
88
|
+
.split(',')
|
|
89
|
+
.map((part, index) => {
|
|
90
|
+
const [tag = '', ...parameters] = part.split(';');
|
|
91
|
+
const weight = parameters
|
|
92
|
+
.map((parameter) => /^q=([0-9.]+)$/i.exec(parameter.trim()))
|
|
93
|
+
.find(Boolean);
|
|
94
|
+
return { tag: tag.trim(), weight: weight ? Number(weight[1]) : 1, index };
|
|
95
|
+
})
|
|
96
|
+
.filter((item) => item.tag && item.tag !== '*' && item.weight > 0)
|
|
97
|
+
.sort((left, right) => right.weight - left.weight || left.index - right.index)
|
|
98
|
+
.map((item) => item.tag);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The shop's language closest to what the customer wants, in the customer's
|
|
103
|
+
* order: the same tag first (pt_BR = pt-BR), then the same language (ru-RU
|
|
104
|
+
* finds ru, en finds en-GB). Nothing when no wanted language is offered.
|
|
105
|
+
*/
|
|
106
|
+
export function closestLocale(
|
|
107
|
+
available: readonly string[],
|
|
108
|
+
wanted: readonly string[],
|
|
109
|
+
): string | undefined {
|
|
110
|
+
const language = (tag: string) =>
|
|
111
|
+
tag.trim().toLowerCase().split(/[-_]/)[0] ?? '';
|
|
112
|
+
for (const tag of wanted) {
|
|
113
|
+
const same = available.find((code) => localesMatch(code, tag));
|
|
114
|
+
if (same) {
|
|
115
|
+
return same;
|
|
116
|
+
}
|
|
117
|
+
const kin = language(tag)
|
|
118
|
+
? available.find((code) => language(code) === language(tag))
|
|
119
|
+
: undefined;
|
|
120
|
+
if (kin) {
|
|
121
|
+
return kin;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
@@ -70,3 +70,40 @@ export function thumbnailKeyTarget(
|
|
|
70
70
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
export type ProductMediaItem =
|
|
75
|
+
| { kind: 'image'; key: string; src: string }
|
|
76
|
+
| { kind: 'video'; key: string; src: string; preview: string | null };
|
|
77
|
+
|
|
78
|
+
export interface IProductMediaSources {
|
|
79
|
+
images?: { full?: string[] | null; small?: string[] | null } | null;
|
|
80
|
+
videos?:
|
|
81
|
+
| { id: number; product_video: string | null; preview: string | null }[]
|
|
82
|
+
| null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The pictures and videos of a product in the order its gallery shows them:
|
|
86
|
+
// the full images first (the small copies when it has none), then the videos
|
|
87
|
+
// in the order the backend sends them. A video without a file is left out.
|
|
88
|
+
export function productMediaItems(
|
|
89
|
+
product: IProductMediaSources | null | undefined,
|
|
90
|
+
): ProductMediaItem[] {
|
|
91
|
+
const images = product?.images;
|
|
92
|
+
const photos = images?.full?.length ? images.full : (images?.small ?? []);
|
|
93
|
+
const items = photos.map(
|
|
94
|
+
(src, index): ProductMediaItem => ({ kind: 'image', key: `image-${index}`, src }),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
for (const video of product?.videos ?? []) {
|
|
98
|
+
if (video.product_video) {
|
|
99
|
+
items.push({
|
|
100
|
+
kind: 'video',
|
|
101
|
+
key: `video-${video.id}`,
|
|
102
|
+
src: video.product_video,
|
|
103
|
+
preview: video.preview,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return items;
|
|
109
|
+
}
|
|
@@ -52,6 +52,7 @@ const en = {
|
|
|
52
52
|
zoomIn: 'Show at full size',
|
|
53
53
|
zoomOut: 'Fit to screen',
|
|
54
54
|
nextImage: 'Next image',
|
|
55
|
+
productVideo: 'Product video',
|
|
55
56
|
thumbnailsBack: 'Show previous thumbnails',
|
|
56
57
|
thumbnailsForward: 'Show next thumbnails',
|
|
57
58
|
characteristics: 'Characteristics',
|
|
@@ -133,6 +134,7 @@ const ru: typeof en = {
|
|
|
133
134
|
zoomIn: 'Показать в полный размер',
|
|
134
135
|
zoomOut: 'Вписать в экран',
|
|
135
136
|
nextImage: 'Следующая фотография',
|
|
137
|
+
productVideo: 'Видео товара',
|
|
136
138
|
thumbnailsBack: 'Показать предыдущие миниатюры',
|
|
137
139
|
thumbnailsForward: 'Показать следующие миниатюры',
|
|
138
140
|
characteristics: 'Характеристики',
|
|
@@ -215,6 +217,7 @@ const es: typeof en = {
|
|
|
215
217
|
zoomIn: 'Ver a tamaño completo',
|
|
216
218
|
zoomOut: 'Ajustar a la pantalla',
|
|
217
219
|
nextImage: 'Imagen siguiente',
|
|
220
|
+
productVideo: 'Vídeo del producto',
|
|
218
221
|
thumbnailsBack: 'Ver miniaturas anteriores',
|
|
219
222
|
thumbnailsForward: 'Ver miniaturas siguientes',
|
|
220
223
|
characteristics: 'Características',
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { loadBaskleeAppLoad } from '@/lib/basklee/appLoadServer';
|
|
2
2
|
import { BaskleeStore } from '@/lib/basklee/store.svelte';
|
|
3
3
|
import { storefrontErrorLocale } from '@/lib/utils/basklee/errorPageLabels';
|
|
4
|
+
import {
|
|
5
|
+
closestLocale,
|
|
6
|
+
wantedLanguages,
|
|
7
|
+
} from '@/lib/utils/basklee/presentation';
|
|
4
8
|
import type { LayoutServerLoad } from './$types';
|
|
5
9
|
|
|
6
10
|
// Initialization depends on the request domain and session, so pages are dynamic.
|
|
@@ -18,8 +22,19 @@ export const load: LayoutServerLoad = async (event) => {
|
|
|
18
22
|
const locale = event.untrack(() =>
|
|
19
23
|
event.url.searchParams.get('locale'),
|
|
20
24
|
);
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
// ?locale= first, then the languages the browser asks for
|
|
26
|
+
// (Accept-Language); the storefront's first language when none is offered.
|
|
27
|
+
const wanted = closestLocale(
|
|
28
|
+
Object.entries(store.locales ?? {}).map(
|
|
29
|
+
([key, value]) => value.code?.trim() || key,
|
|
30
|
+
),
|
|
31
|
+
[
|
|
32
|
+
locale ?? '',
|
|
33
|
+
...wantedLanguages(event.request.headers.get('accept-language')),
|
|
34
|
+
].filter(Boolean),
|
|
35
|
+
);
|
|
36
|
+
if (wanted) {
|
|
37
|
+
store.setLocale(wanted);
|
|
23
38
|
}
|
|
24
39
|
if (!store.isReady) {
|
|
25
40
|
store.localeCode = storefrontErrorLocale(locale, store.localeCode);
|