@jskit-ai/users-web 0.1.268 → 0.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,65 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 - 2026-10-29
4
+
5
+ - Translation ready: every user-visible text is a message key with its English in `locales/en.json`, so an app translates it by supplying translation files only. With no translations, texts and behaviour are unchanged. See the guide "Translating a JSKIT app".
6
+ - Account settings (sections, preferences, avatar upload, toasts) are translated; the language select offers `config.languages`; `useAccountLocale()` exposes the signed-in user's saved locale.
7
+ - Without `config.languages` the language select keeps JSKIT's built-in list unchanged; language names follow the app's language (English without one).
8
+
9
+ ### New message keys (49)
10
+
11
+ All keys in `locales/en.json` (exported as `./locales/en.json`) are new in this version.
12
+
13
+ <details><summary>Key list</summary>
14
+
15
+ - `jskit.users.accountSettings.title`
16
+ - `jskit.users.accountSettings.subtitle`
17
+ - `jskit.users.accountSettings.back`
18
+ - `jskit.users.accountSettings.loadFailedTitle`
19
+ - `jskit.users.accountSettings.loadFailed`
20
+ - `jskit.users.accountSettings.retry`
21
+ - `jskit.users.accountSettings.noSections`
22
+ - `jskit.users.accountSettings.profile.title`
23
+ - `jskit.users.accountSettings.profile.previewSizePrefix`
24
+ - `jskit.users.accountSettings.profile.previewSizeSuffix`
25
+ - `jskit.users.accountSettings.profile.replaceAvatar`
26
+ - `jskit.users.accountSettings.profile.removeAvatar`
27
+ - `jskit.users.accountSettings.profile.selectedFilePrefix`
28
+ - `jskit.users.accountSettings.profile.displayName`
29
+ - `jskit.users.accountSettings.profile.email`
30
+ - `jskit.users.accountSettings.profile.emailHint`
31
+ - `jskit.users.accountSettings.profile.save`
32
+ - `jskit.users.accountSettings.profile.saved`
33
+ - `jskit.users.accountSettings.profile.saveFailed`
34
+ - `jskit.users.accountSettings.profile.initialsFallback`
35
+ - `jskit.users.accountSettings.avatar.removed`
36
+ - `jskit.users.accountSettings.avatar.removeFailed`
37
+ - `jskit.users.accountSettings.avatar.uploaded`
38
+ - `jskit.users.accountSettings.avatar.uploadInvalidResponse`
39
+ - `jskit.users.accountSettings.avatar.uploadFailed`
40
+ - `jskit.users.accountSettings.avatar.uploadRestriction`
41
+ - `jskit.users.accountSettings.avatar.editorUnavailable`
42
+ - `jskit.users.accountSettings.avatar.refreshFailed`
43
+ - `jskit.users.accountSettings.avatar.secureRequestFailed`
44
+ - `jskit.users.accountSettings.preferences.saved`
45
+ - `jskit.users.accountSettings.preferences.saveFailed`
46
+ - `jskit.users.accountSettings.preferences.theme.system`
47
+ - `jskit.users.accountSettings.preferences.theme.light`
48
+ - `jskit.users.accountSettings.preferences.theme.dark`
49
+ - `jskit.users.accountSettings.preferences.locale.enUS`
50
+ - `jskit.users.accountSettings.preferences.locale.enGB`
51
+ - `jskit.users.accountSettings.preferences.locale.itIT`
52
+ - `jskit.users.accountSettings.preferences.locale.esES`
53
+ - `jskit.users.accountSettings.preferences.dateFormat.system`
54
+ - `jskit.users.accountSettings.preferences.dateFormat.mdy`
55
+ - `jskit.users.accountSettings.preferences.dateFormat.dmy`
56
+ - `jskit.users.accountSettings.preferences.dateFormat.ymd`
57
+ - `jskit.users.accountSettings.preferences.numberFormat.system`
58
+ - `jskit.users.accountSettings.preferences.numberFormat.commaDot`
59
+ - `jskit.users.accountSettings.preferences.numberFormat.dotComma`
60
+ - `jskit.users.accountSettings.preferences.numberFormat.spaceComma`
61
+ - `jskit.users.accountSettings.notifications.saved`
62
+ - `jskit.users.accountSettings.notifications.saveFailed`
63
+ - `jskit.users.homeTools.label`
64
+
65
+ </details>
@@ -0,0 +1,75 @@
1
+ {
2
+ "jskit": {
3
+ "users": {
4
+ "accountSettings": {
5
+ "title": "Account settings",
6
+ "subtitle": "Global profile, preferences, notifications, and account controls.",
7
+ "back": "Back",
8
+ "loadFailedTitle": "Unable to load account settings",
9
+ "loadFailed": "Unable to load settings.",
10
+ "retry": "Retry",
11
+ "noSections": "No account settings sections are registered.",
12
+ "profile": {
13
+ "title": "Profile",
14
+ "previewSizePrefix": "Preview size:",
15
+ "previewSizeSuffix": "px",
16
+ "replaceAvatar": "Replace avatar",
17
+ "removeAvatar": "Remove avatar",
18
+ "selectedFilePrefix": "Selected file:",
19
+ "displayName": "Display name",
20
+ "email": "Email",
21
+ "emailHint": "Managed by your sign-in account",
22
+ "save": "Save profile",
23
+ "saved": "Profile updated.",
24
+ "saveFailed": "Unable to update profile.",
25
+ "initialsFallback": "U"
26
+ },
27
+ "avatar": {
28
+ "removed": "Avatar removed.",
29
+ "removeFailed": "Unable to remove avatar.",
30
+ "uploaded": "Avatar uploaded.",
31
+ "uploadInvalidResponse": "Avatar uploaded, but the response payload was invalid.",
32
+ "uploadFailed": "Unable to upload avatar.",
33
+ "uploadRestriction": "Selected avatar file does not meet upload restrictions.",
34
+ "editorUnavailable": "Avatar editor is unavailable in this environment.",
35
+ "refreshFailed": "Avatar uploaded, but the settings view could not refresh.",
36
+ "secureRequestFailed": "Unable to prepare secure avatar upload request."
37
+ },
38
+ "preferences": {
39
+ "saved": "Preferences updated.",
40
+ "saveFailed": "Unable to update preferences.",
41
+ "theme": {
42
+ "system": "System",
43
+ "light": "Light",
44
+ "dark": "Dark"
45
+ },
46
+ "locale": {
47
+ "enUS": "English (US)",
48
+ "enGB": "English (UK)",
49
+ "itIT": "Italian",
50
+ "esES": "Spanish"
51
+ },
52
+ "dateFormat": {
53
+ "system": "System",
54
+ "mdy": "MM/DD/YYYY",
55
+ "dmy": "DD/MM/YYYY",
56
+ "ymd": "YYYY-MM-DD"
57
+ },
58
+ "numberFormat": {
59
+ "system": "System",
60
+ "commaDot": "1,234.56",
61
+ "dotComma": "1.234,56",
62
+ "spaceComma": "1 234,56"
63
+ }
64
+ },
65
+ "notifications": {
66
+ "saved": "Notification settings updated.",
67
+ "saveFailed": "Unable to update notifications."
68
+ }
69
+ },
70
+ "homeTools": {
71
+ "label": "Home cog"
72
+ }
73
+ }
74
+ }
75
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/users-web",
3
- "version": "0.1.268",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test --test-concurrency=1"
@@ -9,18 +9,19 @@
9
9
  "./client": "./src/client/index.js",
10
10
  "./client/providers/UsersWebClientProvider": "./src/client/providers/UsersWebClientProvider.js",
11
11
  "./client/components/AccountSettingsClientElement": "./src/client/components/AccountSettingsClientElement.vue",
12
- "./client/account-settings/sections": "./src/client/account-settings/sections.js"
12
+ "./client/account-settings/sections": "./src/client/account-settings/sections.js",
13
+ "./locales/en.json": "./locales/en.json"
13
14
  },
14
15
  "dependencies": {
15
- "@jskit-ai/uploads-image-web": "0.1.222",
16
- "@jskit-ai/users-core": "0.1.260"
16
+ "@jskit-ai/uploads-image-web": "0.2.0",
17
+ "@jskit-ai/users-core": "0.2.0"
17
18
  },
18
19
  "peerDependencies": {
19
- "@jskit-ai/auth-web": "0.1.250",
20
- "@jskit-ai/http-runtime": "0.1.245",
21
- "@jskit-ai/http-web": "0.1.95",
22
- "@jskit-ai/kernel": "0.1.247",
23
- "@jskit-ai/shell-web": "0.1.254",
20
+ "@jskit-ai/auth-web": "0.2.0",
21
+ "@jskit-ai/http-runtime": "0.2.0",
22
+ "@jskit-ai/http-web": "0.2.0",
23
+ "@jskit-ai/kernel": "0.2.0",
24
+ "@jskit-ai/shell-web": "0.2.0",
24
25
  "@tanstack/vue-query": "^5.90.5",
25
26
  "vue": "^3.5.13",
26
27
  "vue-router": "^5.0.4",
@@ -28,6 +28,16 @@ section order, and which account operations require reauthentication.
28
28
  Use account settings elements and composables from `@jskit-ai/users-web`,
29
29
  ordinary `useCommand()` mutation behavior, and JSKIT shell placements.
30
30
 
31
+ The runtime's `preferences.options.locale` lists the app's `config.languages`
32
+ (`[{ code, name }]` in the public app config), or a built-in list when the app
33
+ configures none; theme, date and number format options arrive translated. The
34
+ saved locale is a canonical BCP 47 code. `useAccountLocale()` from
35
+ `@jskit-ai/users-web/client` returns it as a read-only ref (`""` when signed
36
+ out), updated at bootstrap and after preferences save. JSKIT does not switch the
37
+ app's language; the app does, for example
38
+ `watch(useAccountLocale(), (code) => { if (code) i18n.global.locale.value = code; }, { immediate: true })`.
39
+ Section titles may be plain text, a message key or `{ key, fallback }`.
40
+
31
41
  ## Invariants
32
42
 
33
43
  - Sections use JSKIT account settings APIs rather than direct HTTP helpers.
@@ -13,6 +13,15 @@ import {
13
13
  const ACCOUNT_SETTINGS_SECTION_TARGET = "account-settings:sections";
14
14
  const EMPTY_ACCOUNT_SETTINGS_SECTIONS = Object.freeze([]);
15
15
 
16
+ // A section title is plain text, a message key or { key, fallback, params };
17
+ // the settings host renders it with useJskitText().text().
18
+ function normalizeSectionTitle(value) {
19
+ if (value && typeof value === "object" && !Array.isArray(value)) {
20
+ return value.key || value.fallback ? Object.freeze({ ...value }) : "";
21
+ }
22
+ return String(value || "").trim();
23
+ }
24
+
16
25
  function normalizeAccountSettingsSectionEntry(entry = null) {
17
26
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
18
27
  return null;
@@ -22,7 +31,7 @@ function normalizeAccountSettingsSectionEntry(entry = null) {
22
31
  ? entry.props
23
32
  : {};
24
33
  const value = String(props.value || entry.value || "").trim().toLowerCase();
25
- const title = String(props.title || entry.title || "").trim();
34
+ const title = normalizeSectionTitle(props.title || entry.title);
26
35
  const component = entry.component;
27
36
  if (!value || !title || !component) {
28
37
  return null;
@@ -1,11 +1,13 @@
1
1
  import { resolveBootstrapErrorStatusCode } from "@jskit-ai/shell-web/client/bootstrap";
2
2
  import { resolvePlacementUserFromBootstrapPayload } from "../lib/bootstrap.js";
3
+ import { resolveBootstrapAccountLocale, setAccountLocale } from "../lib/accountLocale.js";
3
4
 
4
5
  function createUsersBootstrapUserHandler() {
5
6
  return Object.freeze({
6
7
  handlerId: "users.web.bootstrap.user",
7
8
  order: 50,
8
9
  applyBootstrapPayload({ payload = {}, placementRuntime, source } = {}) {
10
+ setAccountLocale(resolveBootstrapAccountLocale(payload));
9
11
  if (!placementRuntime || typeof placementRuntime.setContext !== "function") {
10
12
  return;
11
13
  }
@@ -21,10 +23,11 @@ function createUsersBootstrapUserHandler() {
21
23
  );
22
24
  },
23
25
  handleBootstrapError({ error, placementRuntime, source } = {}) {
24
- if (!placementRuntime || typeof placementRuntime.setContext !== "function") {
26
+ if (resolveBootstrapErrorStatusCode(error) !== 401) {
25
27
  return;
26
28
  }
27
- if (resolveBootstrapErrorStatusCode(error) !== 401) {
29
+ setAccountLocale("");
30
+ if (!placementRuntime || typeof placementRuntime.setContext !== "function") {
28
31
  return;
29
32
  }
30
33
 
@@ -4,7 +4,9 @@ import { useRoute, useRouter } from "vue-router";
4
4
  import { normalizeOneOf } from "@jskit-ai/kernel/shared/support/normalize";
5
5
  import { useAccountSettingsRuntime } from "../composables/useAccountSettingsRuntime.js";
6
6
  import { useAccountSettingsSections } from "../account-settings/sections.js";
7
+ import { useJskitText } from "../i18n.js";
7
8
 
9
+ const { t, text } = useJskitText();
8
10
  const runtime = useAccountSettingsRuntime();
9
11
  const route = useRoute();
10
12
  const router = useRouter();
@@ -59,9 +61,9 @@ const activeTab = computed({
59
61
  <v-sheet class="settings-panel" rounded="lg" border>
60
62
  <header class="settings-panel__header">
61
63
  <div>
62
- <h1 class="settings-panel__title">Account settings</h1>
64
+ <h1 class="settings-panel__title">{{ t("jskit.users.accountSettings.title") }}</h1>
63
65
  <p class="text-body-2 text-medium-emphasis mb-0">
64
- Global profile, preferences, notifications, and account controls.
66
+ {{ t("jskit.users.accountSettings.subtitle") }}
65
67
  </p>
66
68
  </div>
67
69
  <v-btn
@@ -70,7 +72,7 @@ const activeTab = computed({
70
72
  :to="runtime.backNavigationTarget.value.sameOrigin ? runtime.backNavigationTarget.value.href : undefined"
71
73
  :href="runtime.backNavigationTarget.value.sameOrigin ? undefined : runtime.backNavigationTarget.value.href"
72
74
  >
73
- Back
75
+ {{ t("jskit.users.accountSettings.back") }}
74
76
  </v-btn>
75
77
  </header>
76
78
 
@@ -80,7 +82,7 @@ const activeTab = computed({
80
82
  <v-skeleton-loader type="text@2, paragraph, button" />
81
83
  </template>
82
84
  <div v-else-if="runtime.settingsLoadError.value" class="settings-panel__state">
83
- <h2 class="text-h6 mb-2">Unable to load account settings</h2>
85
+ <h2 class="text-h6 mb-2">{{ t("jskit.users.accountSettings.loadFailedTitle") }}</h2>
84
86
  <p class="text-body-2 text-medium-emphasis mb-4">{{ runtime.settingsLoadError.value }}</p>
85
87
  <v-btn
86
88
  color="primary"
@@ -88,11 +90,11 @@ const activeTab = computed({
88
90
  :loading="runtime.refreshingSettings.value"
89
91
  @click="runtime.refreshSettings"
90
92
  >
91
- Retry
93
+ {{ t("jskit.users.accountSettings.retry") }}
92
94
  </v-btn>
93
95
  </div>
94
96
  <template v-else-if="sections.length < 1">
95
- <p class="text-body-2 text-medium-emphasis mb-0">No account settings sections are registered.</p>
97
+ <p class="text-body-2 text-medium-emphasis mb-0">{{ t("jskit.users.accountSettings.noSections") }}</p>
96
98
  </template>
97
99
  <template v-else>
98
100
  <v-progress-linear v-if="runtime.refreshingSettings.value" indeterminate class="mb-4" />
@@ -102,7 +104,7 @@ const activeTab = computed({
102
104
  <v-list-item
103
105
  v-for="section in sections"
104
106
  :key="section.value"
105
- :title="section.title"
107
+ :title="text(section.title)"
106
108
  :active="activeTab === section.value"
107
109
  rounded="lg"
108
110
  @click="activeTab = section.value"
@@ -92,18 +92,22 @@ import {
92
92
  normalizeObject,
93
93
  normalizeOneOf
94
94
  } from "@jskit-ai/kernel/shared/support/normalize";
95
-
96
- const DEFAULT_COPY = Object.freeze({
97
- title: "Profile",
98
- previewSizePrefix: "Preview size:",
99
- previewSizeSuffix: "px",
100
- replaceAvatar: "Replace avatar",
101
- removeAvatar: "Remove avatar",
102
- selectedFilePrefix: "Selected file:",
103
- displayName: "Display name",
104
- email: "Email",
105
- emailHint: "Managed by your sign-in account",
106
- saveProfile: "Save profile"
95
+ import { useJskitText } from "../i18n.js";
96
+
97
+ const { t } = useJskitText();
98
+
99
+ // Default copy, by copy prop key; the copy prop overrides it.
100
+ const DEFAULT_COPY_KEYS = Object.freeze({
101
+ title: "jskit.users.accountSettings.profile.title",
102
+ previewSizePrefix: "jskit.users.accountSettings.profile.previewSizePrefix",
103
+ previewSizeSuffix: "jskit.users.accountSettings.profile.previewSizeSuffix",
104
+ replaceAvatar: "jskit.users.accountSettings.profile.replaceAvatar",
105
+ removeAvatar: "jskit.users.accountSettings.profile.removeAvatar",
106
+ selectedFilePrefix: "jskit.users.accountSettings.profile.selectedFilePrefix",
107
+ displayName: "jskit.users.accountSettings.profile.displayName",
108
+ email: "jskit.users.accountSettings.profile.email",
109
+ emailHint: "jskit.users.accountSettings.profile.emailHint",
110
+ saveProfile: "jskit.users.accountSettings.profile.save"
107
111
  });
108
112
 
109
113
  const props = defineProps({
@@ -143,7 +147,7 @@ const {
143
147
  } = createComponentInteractionEmitter(emit);
144
148
 
145
149
  const copyText = computed(() => ({
146
- ...DEFAULT_COPY,
150
+ ...Object.fromEntries(Object.entries(DEFAULT_COPY_KEYS).map(([name, key]) => [name, t(key)])),
147
151
  ...normalizeObject(props.copy)
148
152
  }));
149
153
 
@@ -1,11 +1,14 @@
1
1
  <script setup>
2
2
  import ShellOutletMenuWidget from "@jskit-ai/shell-web/client/components/ShellOutletMenuWidget";
3
3
  import { HOME_COG_OUTLET } from "../../shared/toolsOutletContracts.js";
4
+ import { useJskitText } from "../i18n.js";
5
+
6
+ const { text } = useJskitText();
4
7
  </script>
5
8
 
6
9
  <template>
7
10
  <ShellOutletMenuWidget
8
11
  :target="HOME_COG_OUTLET.target"
9
- :aria-label="HOME_COG_OUTLET.ariaLabel"
12
+ :aria-label="text(HOME_COG_OUTLET.ariaLabel)"
10
13
  />
11
14
  </template>
@@ -2,6 +2,7 @@ import "@jskit-ai/uploads-image-web/client/styles";
2
2
  import { createManagedImageAssetRuntime } from "@jskit-ai/uploads-image-web/client/composables/createManagedImageAssetRuntime";
3
3
  import { resolveFieldErrors } from "@jskit-ai/http-runtime/client";
4
4
  import { httpWebClient } from "@jskit-ai/http-web/client/lib/httpClient";
5
+ import { useJskitText } from "../../i18n.js";
5
6
 
6
7
  function createAccountSettingsAvatarUploadRuntime({
7
8
  queryClient,
@@ -11,6 +12,8 @@ function createAccountSettingsAvatarUploadRuntime({
11
12
  applySettingsData,
12
13
  reportAccountFeedback
13
14
  } = {}) {
15
+ const { t, fieldErrorMessages, serverMessage } = useJskitText();
16
+
14
17
  async function resolveCsrfToken() {
15
18
  const sessionPayload = await queryClient.fetchQuery({
16
19
  queryKey: sessionQueryKey,
@@ -23,7 +26,7 @@ function createAccountSettingsAvatarUploadRuntime({
23
26
 
24
27
  const csrfToken = String(sessionPayload?.csrfToken || "");
25
28
  if (!csrfToken) {
26
- throw new Error("Unable to prepare secure avatar upload request.");
29
+ throw new Error(t("jskit.users.accountSettings.avatar.secureRequestFailed"));
27
30
  }
28
31
 
29
32
  return csrfToken;
@@ -43,16 +46,18 @@ function createAccountSettingsAvatarUploadRuntime({
43
46
  reportFeedback: reportAccountFeedback,
44
47
  resolveUploadErrorMessage: ({ error, response, defaultMessage }) => {
45
48
  const body = response?.body && typeof response.body === "object" ? response.body : {};
46
- const fieldErrors = resolveFieldErrors(body);
47
- return String(fieldErrors.avatar || body?.error || error?.message || defaultMessage);
49
+ const fieldError = fieldErrorMessages({ ...body, fieldErrors: resolveFieldErrors(body) }).avatar;
50
+ const bodyError = body.error ? serverMessage({ ...body, message: body.error }) : "";
51
+ return String(fieldError || bodyError || error?.message || defaultMessage);
48
52
  },
53
+ // Message keys, translated when shown.
49
54
  messages: {
50
- uploadSuccess: "Avatar uploaded.",
51
- uploadInvalidResponse: "Avatar uploaded, but the response payload was invalid.",
52
- uploadError: "Unable to upload avatar.",
53
- uploadRestriction: "Selected avatar file does not meet upload restrictions.",
54
- editorUnavailable: "Avatar editor is unavailable in this environment.",
55
- changeError: "Avatar uploaded, but the settings view could not refresh."
55
+ uploadSuccess: "jskit.users.accountSettings.avatar.uploaded",
56
+ uploadInvalidResponse: "jskit.users.accountSettings.avatar.uploadInvalidResponse",
57
+ uploadError: "jskit.users.accountSettings.avatar.uploadFailed",
58
+ uploadRestriction: "jskit.users.accountSettings.avatar.uploadRestriction",
59
+ editorUnavailable: "jskit.users.accountSettings.avatar.editorUnavailable",
60
+ changeError: "jskit.users.accountSettings.avatar.refreshFailed"
56
61
  },
57
62
  source: "users-web.account-settings-runtime:avatar"
58
63
  });
@@ -0,0 +1,55 @@
1
+ import { getClientAppConfig } from "@jskit-ai/kernel/client";
2
+ import { normalizeLocaleCode } from "@jskit-ai/users-core/shared/settings";
3
+ import { useJskitText } from "../../i18n.js";
4
+ import { LOCALE_OPTIONS } from "./accountSettingsRuntimeConstants.js";
5
+
6
+ function translateOptions(options = []) {
7
+ const { t } = useJskitText();
8
+ return options.map(({ titleKey, value }) => ({ title: t(titleKey), value }));
9
+ }
10
+
11
+ // Language names in the app's language; an app without one is English.
12
+ function languageName(code) {
13
+ try {
14
+ return new Intl.DisplayNames(useJskitText().locale || "en", { type: "language" }).of(code) || code;
15
+ } catch {
16
+ return code;
17
+ }
18
+ }
19
+
20
+ function configuredLanguageOptions(appConfig) {
21
+ const { text } = useJskitText();
22
+ const options = [];
23
+ for (const language of Array.isArray(appConfig?.languages) ? appConfig.languages : []) {
24
+ const value = normalizeLocaleCode(language?.code);
25
+ if (value && !options.some((option) => option.value === value)) {
26
+ options.push({ title: text(language.name) || languageName(value), value });
27
+ }
28
+ }
29
+ return options;
30
+ }
31
+
32
+ // The app's languages (config.languages = [{ code, name }]); the name may also be a
33
+ // message key. Without them, JSKIT's default list.
34
+ function resolveLanguageOptions(appConfig = getClientAppConfig()) {
35
+ const options = configuredLanguageOptions(appConfig);
36
+ return options.length > 0 ? options : translateOptions(LOCALE_OPTIONS);
37
+ }
38
+
39
+ // With configured languages, a saved locale the list does not offer (the server
40
+ // default "en", or a language the app no longer configures) stays selectable under
41
+ // its language name. JSKIT's default list stays exactly as it is.
42
+ function resolveLocaleOptions(savedLocale = "", appConfig = getClientAppConfig()) {
43
+ const options = resolveLanguageOptions(appConfig);
44
+ const saved = normalizeLocaleCode(savedLocale);
45
+ if (!saved || !configuredLanguageOptions(appConfig).length || options.some((option) => option.value === saved)) {
46
+ return options;
47
+ }
48
+ return [...options, { title: languageName(saved), value: saved }];
49
+ }
50
+
51
+ export {
52
+ resolveLanguageOptions,
53
+ resolveLocaleOptions,
54
+ translateOptions
55
+ };
@@ -1,30 +1,32 @@
1
1
  const AVATAR_DEFAULT_SIZE = 64;
2
2
 
3
+ // Option titles are message keys; the runtime translates them.
3
4
  const THEME_OPTIONS = Object.freeze([
4
- { title: "System", value: "system" },
5
- { title: "Light", value: "light" },
6
- { title: "Dark", value: "dark" }
5
+ { titleKey: "jskit.users.accountSettings.preferences.theme.system", value: "system" },
6
+ { titleKey: "jskit.users.accountSettings.preferences.theme.light", value: "light" },
7
+ { titleKey: "jskit.users.accountSettings.preferences.theme.dark", value: "dark" }
7
8
  ]);
8
9
 
10
+ // The languages offered when the app configures none (config.languages).
9
11
  const LOCALE_OPTIONS = Object.freeze([
10
- { title: "English (US)", value: "en-US" },
11
- { title: "English (UK)", value: "en-GB" },
12
- { title: "Italian", value: "it-IT" },
13
- { title: "Spanish", value: "es-ES" }
12
+ { titleKey: "jskit.users.accountSettings.preferences.locale.enUS", value: "en-US" },
13
+ { titleKey: "jskit.users.accountSettings.preferences.locale.enGB", value: "en-GB" },
14
+ { titleKey: "jskit.users.accountSettings.preferences.locale.itIT", value: "it-IT" },
15
+ { titleKey: "jskit.users.accountSettings.preferences.locale.esES", value: "es-ES" }
14
16
  ]);
15
17
 
16
18
  const DATE_FORMAT_OPTIONS = Object.freeze([
17
- { title: "System", value: "system" },
18
- { title: "MM/DD/YYYY", value: "mdy" },
19
- { title: "DD/MM/YYYY", value: "dmy" },
20
- { title: "YYYY-MM-DD", value: "ymd" }
19
+ { titleKey: "jskit.users.accountSettings.preferences.dateFormat.system", value: "system" },
20
+ { titleKey: "jskit.users.accountSettings.preferences.dateFormat.mdy", value: "mdy" },
21
+ { titleKey: "jskit.users.accountSettings.preferences.dateFormat.dmy", value: "dmy" },
22
+ { titleKey: "jskit.users.accountSettings.preferences.dateFormat.ymd", value: "ymd" }
21
23
  ]);
22
24
 
23
25
  const NUMBER_FORMAT_OPTIONS = Object.freeze([
24
- { title: "System", value: "system" },
25
- { title: "1,234.56", value: "comma-dot" },
26
- { title: "1.234,56", value: "dot-comma" },
27
- { title: "1 234,56", value: "space-comma" }
26
+ { titleKey: "jskit.users.accountSettings.preferences.numberFormat.system", value: "system" },
27
+ { titleKey: "jskit.users.accountSettings.preferences.numberFormat.commaDot", value: "comma-dot" },
28
+ { titleKey: "jskit.users.accountSettings.preferences.numberFormat.dotComma", value: "dot-comma" },
29
+ { titleKey: "jskit.users.accountSettings.preferences.numberFormat.spaceComma", value: "space-comma" }
28
30
  ]);
29
31
 
30
32
  const CURRENCY_OPTIONS = Object.freeze(["USD", "EUR", "GBP", "AUD", "JPY"]);
@@ -26,7 +26,6 @@ import {
26
26
  AVATAR_SIZE_OPTIONS,
27
27
  CURRENCY_OPTIONS,
28
28
  DATE_FORMAT_OPTIONS,
29
- LOCALE_OPTIONS,
30
29
  NUMBER_FORMAT_OPTIONS,
31
30
  THEME_OPTIONS,
32
31
  TIME_ZONE_OPTIONS
@@ -37,6 +36,9 @@ import {
37
36
  normalizeSettingsPayload
38
37
  } from "./account-settings/accountSettingsRuntimeHelpers.js";
39
38
  import { createAccountSettingsAvatarUploadRuntime } from "./account-settings/accountSettingsAvatarUploadRuntime.js";
39
+ import { resolveLocaleOptions, translateOptions } from "./account-settings/accountSettingsPreferenceOptions.js";
40
+ import { setAccountLocale } from "../lib/accountLocale.js";
41
+ import { useJskitText } from "../i18n.js";
40
42
 
41
43
  function useAccountSettingsRuntime() {
42
44
  const route = useRoute();
@@ -44,6 +46,7 @@ function useAccountSettingsRuntime() {
44
46
  const queryClient = useQueryClient();
45
47
  const errorRuntime = useShellWebErrorRuntime();
46
48
  const vuetifyTheme = useTheme();
49
+ const { t } = useJskitText();
47
50
 
48
51
  const accountSettingsQueryKey = ["users-web", "settings", "account"];
49
52
  const accountProfileWriteQueryKey = ["users-web", "settings", "account-profile-write"];
@@ -118,12 +121,19 @@ function useAccountSettingsRuntime() {
118
121
  });
119
122
 
120
123
  const selectedAvatarFileName = ref("");
124
+ const savedLocale = ref("");
121
125
 
122
126
  const profileInitials = computed(() => {
123
- const source = String(profileForm.displayName || profileForm.email || "U").trim();
124
- return source.slice(0, 2).toUpperCase() || "U";
127
+ const fallback = t("jskit.users.accountSettings.profile.initialsFallback");
128
+ const source = String(profileForm.displayName || profileForm.email || fallback).trim();
129
+ return source.slice(0, 2).toUpperCase() || fallback;
125
130
  });
126
131
 
132
+ const themeOptions = computed(() => translateOptions(THEME_OPTIONS));
133
+ const localeOptions = computed(() => resolveLocaleOptions(savedLocale.value));
134
+ const dateFormatOptions = computed(() => translateOptions(DATE_FORMAT_OPTIONS));
135
+ const numberFormatOptions = computed(() => translateOptions(NUMBER_FORMAT_OPTIONS));
136
+
127
137
  function reportAccountFeedback({
128
138
  message,
129
139
  severity = "error",
@@ -183,6 +193,10 @@ function useAccountSettingsRuntime() {
183
193
  notificationsForm.securityAlerts = ACCOUNT_SETTINGS_DEFAULTS.notifications.securityAlerts;
184
194
 
185
195
  applyThemePreference(preferencesForm.theme);
196
+ if (data.preferences?.locale) {
197
+ savedLocale.value = preferencesForm.locale;
198
+ setAccountLocale(preferencesForm.locale);
199
+ }
186
200
  }
187
201
 
188
202
  const avatarUploadRuntime = createAccountSettingsAvatarUploadRuntime({
@@ -206,7 +220,7 @@ function useAccountSettingsRuntime() {
206
220
  realtime: {
207
221
  event: "account.settings.changed"
208
222
  },
209
- fallbackLoadError: "Unable to load settings.",
223
+ fallbackLoadError: t("jskit.users.accountSettings.loadFailed"),
210
224
  mapLoadedToModel: mapAccountSettingsPayload
211
225
  });
212
226
 
@@ -218,7 +232,7 @@ function useAccountSettingsRuntime() {
218
232
  readEnabled: false,
219
233
  writeMethod: "PATCH",
220
234
  transport: USER_PROFILE_UPDATE_TRANSPORT,
221
- fallbackSaveError: "Unable to update profile.",
235
+ fallbackSaveError: t("jskit.users.accountSettings.profile.saveFailed"),
222
236
  fieldErrorKeys: ["displayName"],
223
237
  model: profileForm,
224
238
  mapLoadedToModel: mapAccountSettingsPayload,
@@ -227,8 +241,8 @@ function useAccountSettingsRuntime() {
227
241
  displayName: String(model.displayName || "").trim()
228
242
  }),
229
243
  messages: {
230
- saveSuccess: "Profile updated.",
231
- saveError: "Unable to update profile."
244
+ saveSuccess: t("jskit.users.accountSettings.profile.saved"),
245
+ saveError: t("jskit.users.accountSettings.profile.saveFailed")
232
246
  }
233
247
  });
234
248
 
@@ -237,15 +251,15 @@ function useAccountSettingsRuntime() {
237
251
  apiSuffix: "/settings/profile/avatar",
238
252
  writeMethod: "DELETE",
239
253
  transport: USER_PROFILE_AVATAR_DELETE_TRANSPORT,
240
- fallbackRunError: "Unable to remove avatar.",
254
+ fallbackRunError: t("jskit.users.accountSettings.avatar.removeFailed"),
241
255
  model: profileForm,
242
256
  onRunSuccess: (payload, { queryClient: commandQueryClient }) => {
243
257
  applySettingsData(payload);
244
258
  commandQueryClient.setQueryData(accountSettingsQueryKey, payload);
245
259
  },
246
260
  messages: {
247
- success: "Avatar removed.",
248
- error: "Unable to remove avatar."
261
+ success: t("jskit.users.accountSettings.avatar.removed"),
262
+ error: t("jskit.users.accountSettings.avatar.removeFailed")
249
263
  }
250
264
  });
251
265
 
@@ -257,7 +271,7 @@ function useAccountSettingsRuntime() {
257
271
  readEnabled: false,
258
272
  writeMethod: "PATCH",
259
273
  transport: USER_PREFERENCES_UPDATE_TRANSPORT,
260
- fallbackSaveError: "Unable to update preferences.",
274
+ fallbackSaveError: t("jskit.users.accountSettings.preferences.saveFailed"),
261
275
  fieldErrorKeys: ["theme", "locale", "timeZone", "dateFormat", "numberFormat", "currencyCode", "avatarSize"],
262
276
  model: preferencesForm,
263
277
  mapLoadedToModel: mapAccountSettingsPayload,
@@ -272,8 +286,8 @@ function useAccountSettingsRuntime() {
272
286
  avatarSize: Number(model.avatarSize)
273
287
  }),
274
288
  messages: {
275
- saveSuccess: "Preferences updated.",
276
- saveError: "Unable to update preferences."
289
+ saveSuccess: t("jskit.users.accountSettings.preferences.saved"),
290
+ saveError: t("jskit.users.accountSettings.preferences.saveFailed")
277
291
  }
278
292
  });
279
293
 
@@ -285,7 +299,7 @@ function useAccountSettingsRuntime() {
285
299
  readEnabled: false,
286
300
  writeMethod: "PATCH",
287
301
  transport: USER_NOTIFICATION_SETTINGS_UPDATE_TRANSPORT,
288
- fallbackSaveError: "Unable to update notifications.",
302
+ fallbackSaveError: t("jskit.users.accountSettings.notifications.saveFailed"),
289
303
  model: notificationsForm,
290
304
  mapLoadedToModel: mapAccountSettingsPayload,
291
305
  input: userSettingsResource.operations.notificationsUpdate.body,
@@ -295,8 +309,8 @@ function useAccountSettingsRuntime() {
295
309
  securityAlerts: true
296
310
  }),
297
311
  messages: {
298
- saveSuccess: "Notification settings updated.",
299
- saveError: "Unable to update notifications."
312
+ saveSuccess: t("jskit.users.accountSettings.notifications.saved"),
313
+ saveError: t("jskit.users.accountSettings.notifications.saveFailed")
300
314
  }
301
315
  });
302
316
 
@@ -367,12 +381,21 @@ function useAccountSettingsRuntime() {
367
381
  fieldErrors: preferencesAddEdit.fieldErrors,
368
382
  isSaving: preferencesAddEdit.isSaving,
369
383
  isRefreshing: refreshingSettings,
384
+ // Plain arrays for v-select items; the getters follow the active language.
370
385
  options: Object.freeze({
371
- theme: THEME_OPTIONS,
372
- locale: LOCALE_OPTIONS,
386
+ get theme() {
387
+ return themeOptions.value;
388
+ },
389
+ get locale() {
390
+ return localeOptions.value;
391
+ },
373
392
  timeZone: TIME_ZONE_OPTIONS,
374
- dateFormat: DATE_FORMAT_OPTIONS,
375
- numberFormat: NUMBER_FORMAT_OPTIONS,
393
+ get dateFormat() {
394
+ return dateFormatOptions.value;
395
+ },
396
+ get numberFormat() {
397
+ return numberFormatOptions.value;
398
+ },
376
399
  currency: CURRENCY_OPTIONS,
377
400
  avatarSize: AVATAR_SIZE_OPTIONS
378
401
  }),
@@ -0,0 +1,6 @@
1
+ import { registerJskitMessages, useJskitText } from "@jskit-ai/kernel/client";
2
+ import en from "../../locales/en.json" with { type: "json" };
3
+
4
+ registerJskitMessages(en);
5
+
6
+ export { useJskitText };
@@ -1,2 +1,3 @@
1
1
  export { UsersWebClientProvider } from "./providers/UsersWebClientProvider.js";
2
2
  export { default as AccountSettingsClientElement } from "./components/AccountSettingsClientElement.vue";
3
+ export { useAccountLocale } from "./lib/accountLocale.js";
@@ -0,0 +1,30 @@
1
+ import { readonly, ref } from "vue";
2
+ import { normalizeLocaleCode } from "@jskit-ai/users-core/shared/settings";
3
+
4
+ // The signed-in user's saved language (user_settings.locale) as a canonical BCP 47
5
+ // code, or "" when nobody is signed in. JSKIT never switches the app's vue-i18n
6
+ // locale; the app watches this and switches it.
7
+ const accountLocale = ref("");
8
+ const readonlyAccountLocale = readonly(accountLocale);
9
+
10
+ function setAccountLocale(value) {
11
+ accountLocale.value = normalizeLocaleCode(value);
12
+ }
13
+
14
+ function resolveBootstrapAccountLocale(payload = {}) {
15
+ const source = payload && typeof payload === "object" ? payload : {};
16
+ if (source.session?.authenticated !== true) {
17
+ return "";
18
+ }
19
+ return normalizeLocaleCode(source.userSettings?.locale);
20
+ }
21
+
22
+ function useAccountLocale() {
23
+ return readonlyAccountLocale;
24
+ }
25
+
26
+ export {
27
+ resolveBootstrapAccountLocale,
28
+ setAccountLocale,
29
+ useAccountLocale
30
+ };
@@ -1,6 +1,7 @@
1
1
  const HOME_COG_OUTLET = Object.freeze({
2
2
  target: "home-cog:primary-menu",
3
- ariaLabel: "Home cog"
3
+ // A message key; render it with useJskitText().text().
4
+ ariaLabel: "jskit.users.homeTools.label"
4
5
  });
5
6
 
6
7
  export {
@@ -0,0 +1,96 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { createI18n } from "vue-i18n";
4
+ import { setJskitI18n } from "@jskit-ai/kernel/client";
5
+ import {
6
+ DATE_FORMAT_OPTIONS,
7
+ NUMBER_FORMAT_OPTIONS,
8
+ THEME_OPTIONS
9
+ } from "../src/client/composables/account-settings/accountSettingsRuntimeConstants.js";
10
+ import {
11
+ resolveLocaleOptions,
12
+ translateOptions
13
+ } from "../src/client/composables/account-settings/accountSettingsPreferenceOptions.js";
14
+ import { createUsersBootstrapUserHandler } from "../src/client/bootstrap/user-bootstrap-handler.js";
15
+ import { useAccountLocale } from "../src/client/lib/accountLocale.js";
16
+
17
+ test("preference options keep their English labels without app translations", () => {
18
+ assert.deepEqual(translateOptions(THEME_OPTIONS), [
19
+ { title: "System", value: "system" },
20
+ { title: "Light", value: "light" },
21
+ { title: "Dark", value: "dark" }
22
+ ]);
23
+ assert.deepEqual(translateOptions(DATE_FORMAT_OPTIONS).map((option) => option.title), ["System", "MM/DD/YYYY", "DD/MM/YYYY", "YYYY-MM-DD"]);
24
+ assert.deepEqual(translateOptions(NUMBER_FORMAT_OPTIONS).map((option) => option.title), ["System", "1,234.56", "1.234,56", "1 234,56"]);
25
+ });
26
+
27
+ test("the language select offers the default list when the app configures no languages", () => {
28
+ assert.deepEqual(resolveLocaleOptions("en-US", {}), [
29
+ { title: "English (US)", value: "en-US" },
30
+ { title: "English (UK)", value: "en-GB" },
31
+ { title: "Italian", value: "it-IT" },
32
+ { title: "Spanish", value: "es-ES" }
33
+ ]);
34
+ });
35
+
36
+ test("the language select offers the app's configured languages as canonical codes", () => {
37
+ const appConfig = {
38
+ languages: [
39
+ { code: "en-us", name: "English" },
40
+ { code: "it", name: "Italiano" },
41
+ { code: "EN-US", name: "Duplicate" },
42
+ { code: "", name: "Missing code" }
43
+ ]
44
+ };
45
+ assert.deepEqual(resolveLocaleOptions("it", appConfig), [
46
+ { title: "English", value: "en-US" },
47
+ { title: "Italiano", value: "it" }
48
+ ]);
49
+ });
50
+
51
+ test("a saved locale missing from the configured languages stays selectable under its language name", () => {
52
+ const options = resolveLocaleOptions("en", { languages: [{ code: "it-IT", name: "Italiano" }] });
53
+ assert.deepEqual(options, [{ title: "Italiano", value: "it-IT" }, { title: "English", value: "en" }]);
54
+ });
55
+
56
+ test("without configured languages the default list stays as it was, whatever is saved", () => {
57
+ assert.equal(resolveLocaleOptions("en", {}).length, 4);
58
+ });
59
+
60
+ test("preference option labels follow the app's vue-i18n locale", () => {
61
+ const i18n = createI18n({
62
+ legacy: false,
63
+ locale: "it",
64
+ messages: {
65
+ it: { jskit: { users: { accountSettings: { preferences: { theme: { dark: "Scuro" } } } } } }
66
+ }
67
+ });
68
+ setJskitI18n(i18n);
69
+ try {
70
+ assert.equal(translateOptions(THEME_OPTIONS).find((option) => option.value === "dark").title, "Scuro");
71
+ // A key the app has not translated falls back to English.
72
+ assert.equal(translateOptions(THEME_OPTIONS).find((option) => option.value === "light").title, "Light");
73
+ } finally {
74
+ setJskitI18n(null);
75
+ }
76
+ });
77
+
78
+ test("useAccountLocale follows the bootstrap payload's saved locale", async () => {
79
+ const handler = createUsersBootstrapUserHandler();
80
+ const accountLocale = useAccountLocale();
81
+
82
+ await handler.applyBootstrapPayload({
83
+ payload: { session: { authenticated: true, userId: "7" }, userSettings: { locale: "it-it" } }
84
+ });
85
+ assert.equal(accountLocale.value, "it-IT");
86
+
87
+ await handler.handleBootstrapError({ error: { statusCode: 500 } });
88
+ assert.equal(accountLocale.value, "it-IT");
89
+
90
+ await handler.handleBootstrapError({ error: { statusCode: 401 } });
91
+ assert.equal(accountLocale.value, "");
92
+
93
+ await handler.applyBootstrapPayload({ payload: { session: { authenticated: true }, userSettings: { locale: "en" } } });
94
+ await handler.applyBootstrapPayload({ payload: { session: { authenticated: false }, userSettings: null } });
95
+ assert.equal(accountLocale.value, "");
96
+ });
@@ -101,3 +101,18 @@ test("normalizeAccountSettingsSectionEntry rejects malformed placement entries",
101
101
  null
102
102
  );
103
103
  });
104
+
105
+ test("normalizeAccountSettingsSectionEntry keeps a message-key title for the host to translate", () => {
106
+ const entry = normalizeAccountSettingsSectionEntry({
107
+ component: {},
108
+ props: {
109
+ value: "billing",
110
+ title: { key: "app.settings.billing", fallback: "Billing" }
111
+ }
112
+ });
113
+ assert.deepEqual(entry.title, { key: "app.settings.billing", fallback: "Billing" });
114
+ assert.equal(
115
+ normalizeAccountSettingsSectionEntry({ component: {}, props: { value: "billing", title: {} } }),
116
+ null
117
+ );
118
+ });
@@ -17,7 +17,9 @@ test("users-web exports only user-owned client surfaces", () => {
17
17
  "./client",
18
18
  "./client/providers/UsersWebClientProvider",
19
19
  "./client/components/AccountSettingsClientElement",
20
- "./client/account-settings/sections"
20
+ "./client/account-settings/sections",
21
+ // The generated client bootstrap registers the package's English catalog.
22
+ "./locales/en.json"
21
23
  ]
22
24
  });
23
25
 
@@ -0,0 +1,16 @@
1
+ import assert from "node:assert/strict";
2
+ import path from "node:path";
3
+ import test from "node:test";
4
+ import { fileURLToPath } from "node:url";
5
+ import { evaluateI18nCatalogContract } from "../../../tooling/test-support/i18nCatalogContract.mjs";
6
+
7
+ const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
8
+ const REPO_ROOT = path.resolve(TEST_DIRECTORY, "..", "..", "..");
9
+
10
+ test("users-web English catalog matches its source", () => {
11
+ const { problems } = evaluateI18nCatalogContract({
12
+ repoRoot: REPO_ROOT,
13
+ packageDir: path.join(REPO_ROOT, "packages", "users-web")
14
+ });
15
+ assert.deepEqual(problems, []);
16
+ });
@@ -63,8 +63,9 @@ test("account settings pattern keeps the app-owned route and sections as adaptab
63
63
  });
64
64
 
65
65
  test("profile copy remains authentication-provider neutral", async () => {
66
+ // The package's profile form takes its copy from the English catalog.
66
67
  for (const sourcePath of [
67
- path.join("src", "client", "components", "ProfileClientElement.vue"),
68
+ path.join("locales", "en.json"),
68
69
  path.join(
69
70
  "patterns",
70
71
  "account-settings",