@7365admin1/layer-common 4.97.1-staging.731 → 4.97.1-staging.733
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/components/DashboardMain.vue +6 -4
- package/components/Layout/Header.vue +3 -1
- package/components/Layout/NavigationDrawer.vue +3 -1
- package/components/ListCsvExport.vue +3 -1
- package/components/NavigationItem.vue +5 -3
- package/composables/useReportPdf.ts +1 -1
- package/composables/useUiLanguage.ts +9 -3
- package/package.json +1 -1
- package/plugins/ui-language.ts +10 -1
- package/utils/ui-translate.ts +3 -1
|
@@ -333,7 +333,7 @@
|
|
|
333
333
|
:icon="card.icon"
|
|
334
334
|
:tint="card.tint"
|
|
335
335
|
:color="card.color"
|
|
336
|
-
:label="cardTitle(card)"
|
|
336
|
+
:label="uiTr(cardTitle(card))"
|
|
337
337
|
:value="card.value"
|
|
338
338
|
:chip="kpiChipText(card)"
|
|
339
339
|
:down="Number(card.percentage) < 0"
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
>
|
|
423
423
|
<div class="d-flex align-center justify-space-between">
|
|
424
424
|
<h2 class="dashboard-card-title mb-0">
|
|
425
|
-
{{ activityTitle }}
|
|
425
|
+
{{ uiTr(activityTitle) }}
|
|
426
426
|
</h2>
|
|
427
427
|
</div>
|
|
428
428
|
|
|
@@ -1108,10 +1108,10 @@
|
|
|
1108
1108
|
<div
|
|
1109
1109
|
class="text-body-2 font-weight-black text-high-emphasis"
|
|
1110
1110
|
>
|
|
1111
|
-
{{ widget.title }}
|
|
1111
|
+
{{ uiTr(widget.title) }}
|
|
1112
1112
|
</div>
|
|
1113
1113
|
<div class="text-caption text-medium-emphasis mt-1">
|
|
1114
|
-
{{ widget.description }}
|
|
1114
|
+
{{ uiTr(widget.description) }}
|
|
1115
1115
|
</div>
|
|
1116
1116
|
</div>
|
|
1117
1117
|
<!--
|
|
@@ -1230,6 +1230,8 @@
|
|
|
1230
1230
|
</template>
|
|
1231
1231
|
|
|
1232
1232
|
<script setup lang="ts">
|
|
1233
|
+
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
1234
|
+
import { uiTr } from "../composables/useUiLanguage";
|
|
1233
1235
|
// The one non-auto-imported thing this file needs: the cookie options type, so
|
|
1234
1236
|
// `runtimeConfig.public.cookieConfig` (typed `unknown`) can be narrowed once
|
|
1235
1237
|
// rather than at the call site. Same import `useThemePreference.ts` uses.
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
<div ref="crumbEl" class="app-topbar-shell__crumb">
|
|
25
25
|
<span v-if="siteName" class="app-topbar-shell__site">{{ siteName }}</span>
|
|
26
26
|
<span v-if="siteName && moduleName" class="app-topbar-shell__sep">/</span>
|
|
27
|
-
<span class="app-topbar-shell__module">{{
|
|
27
|
+
<span class="app-topbar-shell__module">{{ uiTr(moduleName) }}</span>
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
30
|
<template #append>
|
|
@@ -128,6 +128,8 @@
|
|
|
128
128
|
</template>
|
|
129
129
|
|
|
130
130
|
<script setup lang="ts">
|
|
131
|
+
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
132
|
+
import { uiTr } from "../../composables/useUiLanguage";
|
|
131
133
|
import { moduleNameFromRoute } from "../../utils/breadcrumb";
|
|
132
134
|
|
|
133
135
|
const props = defineProps({
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
v-for="({ item, section }, index) in sectionedItems"
|
|
92
92
|
:key="`${item.title}-${index}`"
|
|
93
93
|
>
|
|
94
|
-
<div v-if="section" class="brand-drawer__section">{{
|
|
94
|
+
<div v-if="section" class="brand-drawer__section">{{ uiTr(section) }}</div>
|
|
95
95
|
|
|
96
96
|
<v-tooltip location="right" :disabled="!item.disabled">
|
|
97
97
|
<template #activator="{ props: tooltipProps }">
|
|
@@ -121,6 +121,8 @@
|
|
|
121
121
|
</template>
|
|
122
122
|
|
|
123
123
|
<script setup lang="ts">
|
|
124
|
+
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
125
|
+
import { uiTr } from "../../composables/useUiLanguage";
|
|
124
126
|
import { useDisplay } from "vuetify";
|
|
125
127
|
|
|
126
128
|
import { withSections } from "../../utils/nav-sections";
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
data-test="list-csv-export"
|
|
13
13
|
@click="download"
|
|
14
14
|
>
|
|
15
|
-
{{ label }}
|
|
15
|
+
{{ uiTr(label) }}
|
|
16
16
|
</v-btn>
|
|
17
17
|
<Snackbar v-model="toast.show" :text="toast.message" :color="toast.color" />
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
20
|
<script setup lang="ts">
|
|
21
|
+
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
22
|
+
import { uiTr } from "../composables/useUiLanguage";
|
|
21
23
|
import { collectAllPages, EXPORT_MAX_ROWS, listCsv, type TExportColumn } from "../utils/list-export";
|
|
22
24
|
|
|
23
25
|
const props = defineProps({
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
class="nav-item"
|
|
15
15
|
@click.stop="onParentClick"
|
|
16
16
|
>
|
|
17
|
-
{{
|
|
17
|
+
{{ uiTr(title) }}
|
|
18
18
|
</v-list-item>
|
|
19
19
|
</template>
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
color="primary"
|
|
36
36
|
class="nav-item"
|
|
37
37
|
>
|
|
38
|
-
{{
|
|
38
|
+
{{ uiTr(title) }}
|
|
39
39
|
</v-list-item>
|
|
40
40
|
|
|
41
41
|
<v-list-item
|
|
@@ -45,11 +45,13 @@
|
|
|
45
45
|
color="primary"
|
|
46
46
|
class="nav-item"
|
|
47
47
|
>
|
|
48
|
-
{{
|
|
48
|
+
{{ uiTr(title) }}
|
|
49
49
|
</v-list-item>
|
|
50
50
|
</template>
|
|
51
51
|
|
|
52
52
|
<script setup lang="ts">
|
|
53
|
+
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
54
|
+
import { uiTr } from "../composables/useUiLanguage";
|
|
53
55
|
const props = defineProps({
|
|
54
56
|
title: {
|
|
55
57
|
type: String,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import html2canvas from "html2canvas";
|
|
2
2
|
import jsPDF from "jspdf";
|
|
3
|
-
import useUiLanguage from "./useUiLanguage";
|
|
3
|
+
import useUiLanguage from "./useUiLanguage.ts";
|
|
4
4
|
import { formatGeneratedAt, planPdfPages, type PdfTable } from "../utils/report-export";
|
|
5
5
|
|
|
6
6
|
export type ReportPdfMeta = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { nextTick, ref } from "vue";
|
|
2
|
-
import { createUiTranslator, UI_LANGUAGES } from "../utils/ui-translate";
|
|
2
|
+
import { createUiTranslator, UI_LANGUAGES } from "../utils/ui-translate.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The web language picker (top bar > profile menu > Language).
|
|
@@ -33,16 +33,22 @@ function applyHtmlLang(code: string) {
|
|
|
33
33
|
export function installUiLanguage(deps: {
|
|
34
34
|
post: (q: string[], target: string) => Promise<any>;
|
|
35
35
|
getVersion: () => Promise<any>;
|
|
36
|
+
/** The shared-domain cookie, so the choice follows the user across the apps. */
|
|
37
|
+
sharedLanguage?: () => string | undefined;
|
|
38
|
+
shareLanguage?: (code: string) => void;
|
|
36
39
|
}) {
|
|
37
40
|
if (engine || typeof window === "undefined") return;
|
|
38
41
|
engine = createUiTranslator({
|
|
39
42
|
storage: localStore(),
|
|
40
43
|
post: deps.post,
|
|
41
44
|
getVersion: deps.getVersion,
|
|
45
|
+
initialLanguage: deps.sharedLanguage?.(),
|
|
42
46
|
onChange: () => {
|
|
43
47
|
revision.value++;
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
const code = engine?.language ?? "en";
|
|
49
|
+
if (code !== language.value) deps.shareLanguage?.(code);
|
|
50
|
+
language.value = code;
|
|
51
|
+
applyHtmlLang(code);
|
|
46
52
|
},
|
|
47
53
|
});
|
|
48
54
|
language.value = engine.language;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.733",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
package/plugins/ui-language.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { installUiLanguage, uiTr, uiTrHeaders } from "../composables/useUiLanguage";
|
|
1
|
+
import { installUiLanguage, uiTr, uiTrHeaders } from "../composables/useUiLanguage.ts";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* `$tr` / `$trHeaders` for every template (the build-time transform in
|
|
@@ -23,7 +23,16 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
23
23
|
return $fetch(path, { ...init, retry: 0, headers: { Authorization: token } });
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Same domain-wide cookie pattern as the theme (useThemePreference): one
|
|
27
|
+
// choice for all eleven apps, not one per app host.
|
|
28
|
+
const langCookie = () =>
|
|
29
|
+
nuxtApp.runWithContext(() => useCookie<string | null>("ui-lang", { ...cookieConfig, maxAge: 365 * 24 * 60 * 60 }));
|
|
30
|
+
|
|
26
31
|
installUiLanguage({
|
|
32
|
+
sharedLanguage: () => langCookie().value ?? undefined,
|
|
33
|
+
shareLanguage: (code) => {
|
|
34
|
+
langCookie().value = code;
|
|
35
|
+
},
|
|
27
36
|
post: (q, target) => call("/api/translations/v1", { method: "POST", body: { q, target } }),
|
|
28
37
|
getVersion: async () => ((await call("/api/translations/v1/version")) as any)?.version,
|
|
29
38
|
});
|
package/utils/ui-translate.ts
CHANGED
|
@@ -79,6 +79,8 @@ export type TranslatorDeps = {
|
|
|
79
79
|
post: (q: string[], target: string) => Promise<{ translations?: unknown; version?: unknown }>;
|
|
80
80
|
getVersion: () => Promise<unknown>;
|
|
81
81
|
onChange: () => void;
|
|
82
|
+
/** Language chosen in another app of the same domain (shared cookie); wins over storage. */
|
|
83
|
+
initialLanguage?: string;
|
|
82
84
|
now?: () => number;
|
|
83
85
|
schedule?: (fn: () => void, ms: number) => unknown;
|
|
84
86
|
};
|
|
@@ -101,7 +103,7 @@ export function createUiTranslator(deps: TranslatorDeps) {
|
|
|
101
103
|
const schedule = deps.schedule ?? ((fn: () => void, ms: number) => setTimeout(fn, ms));
|
|
102
104
|
|
|
103
105
|
const known = new Set(UI_LANGUAGES.map((l) => l.code));
|
|
104
|
-
const stored = safe(() => storage?.getItem(UI_TR_LANG_KEY) ?? "", "");
|
|
106
|
+
const stored = deps.initialLanguage || safe(() => storage?.getItem(UI_TR_LANG_KEY) ?? "", "");
|
|
105
107
|
let lang = known.has(stored) ? stored : "en";
|
|
106
108
|
let version = safe(() => storage?.getItem(UI_TR_VERSION_KEY) ?? "", "");
|
|
107
109
|
let dict: Record<string, string> = {};
|