@burdenoff/microfe-i18n 2026.1129.2 → 2026.1129.4
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/dist/generated/global-operations.d.ts +337 -0
- package/dist/generated/global-operations.js +155 -15
- package/dist/generated/global-types.js +7 -3
- package/dist/i18n/I18nRoutes.d.ts +4 -2
- package/dist/i18n/I18nRoutes.js +55 -47
- package/dist/i18n/v2/ExportDialog.d.ts +9 -0
- package/dist/i18n/v2/ExportDialog.js +107 -0
- package/dist/i18n/v2/LanguageDialog.d.ts +17 -0
- package/dist/i18n/v2/LanguageDialog.js +193 -0
- package/dist/i18n/v2/LanguagesDialogs.d.ts +7 -0
- package/dist/i18n/v2/LanguagesDialogs.js +43 -0
- package/dist/i18n/v2/LanguagesPage.js +62 -53
- package/dist/i18n/v2/LanguagesTab.js +1 -1
- package/dist/i18n/v2/ReviewTab.d.ts +3 -1
- package/dist/i18n/v2/ReviewTab.js +28 -27
- package/dist/i18n/v2/TabRedirect.d.ts +12 -0
- package/dist/i18n/v2/TabRedirect.js +25 -9
- package/dist/i18n/v2/language/FormatsTab.d.ts +6 -0
- package/dist/i18n/v2/language/FormatsTab.js +93 -0
- package/dist/i18n/v2/language/LanguagePage.d.ts +3 -0
- package/dist/i18n/v2/language/LanguagePage.js +256 -0
- package/dist/i18n/v2/language/TranslateDialog.d.ts +18 -0
- package/dist/i18n/v2/language/TranslateDialog.js +101 -0
- package/dist/i18n/v2/language/WordsTab.d.ts +11 -0
- package/dist/i18n/v2/language/WordsTab.js +190 -0
- package/dist/i18n/v2/language/useLanguage.d.ts +23 -0
- package/dist/i18n/v2/language/useLanguage.js +22 -0
- package/dist/i18n/v2/language/useWords.d.ts +31 -0
- package/dist/i18n/v2/language/useWords.js +51 -0
- package/dist/i18n/v2/languageModel.d.ts +66 -0
- package/dist/i18n/v2/languageModel.js +124 -0
- package/dist/i18n/v2/links.d.ts +10 -2
- package/dist/i18n/v2/links.js +11 -10
- package/dist/i18n/v2/useAddLanguage.d.ts +10 -0
- package/dist/i18n/v2/useAddLanguage.js +30 -0
- package/dist/i18n/v2/useDebouncedValue.d.ts +1 -0
- package/dist/i18n/v2/useDebouncedValue.js +10 -0
- package/dist/i18n/v2/useExportTranslations.d.ts +8 -0
- package/dist/i18n/v2/useExportTranslations.js +26 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/calendar-days.js +49 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/eye-off.js +21 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/eye.js +12 -0
- package/package.json +1 -1
package/dist/i18n/I18nRoutes.js
CHANGED
|
@@ -7,97 +7,105 @@ import { ImportExportPage as a } from "./pages/ImportExportPage.js";
|
|
|
7
7
|
import { LocaleConfigPage as o } from "./pages/LocaleConfigPage.js";
|
|
8
8
|
import { joinPath as s } from "./utils/paths.js";
|
|
9
9
|
import { LanguagesPage as c } from "./v2/LanguagesPage.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
10
|
+
import { LanguagePage as l } from "./v2/language/LanguagePage.js";
|
|
11
|
+
import { DialogRedirect as u, LanguageRedirect as d, TabRedirect as f } from "./v2/TabRedirect.js";
|
|
12
|
+
import { ADD_LANGUAGE_DIALOG as p, EXPORT_DIALOG as m } from "./v2/links.js";
|
|
13
|
+
import { Navigate as h, Route as g, Routes as _ } from "react-router";
|
|
14
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
15
|
+
import { useAccountPagesV2 as b } from "@burdenoff/fe-libs/ui/account-pages-v2";
|
|
14
16
|
// src/i18n/I18nRoutes.tsx
|
|
15
|
-
function
|
|
16
|
-
let t =
|
|
17
|
-
return /* @__PURE__ */
|
|
17
|
+
function x({ basePath: e = "/" }) {
|
|
18
|
+
let t = b();
|
|
19
|
+
return /* @__PURE__ */ v(S, {
|
|
18
20
|
basePath: e,
|
|
19
21
|
v2: t
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
|
-
function
|
|
23
|
-
let
|
|
24
|
-
basePath:
|
|
24
|
+
function S({ basePath: b, v2: x }) {
|
|
25
|
+
let S = s(b, "languages"), C = s(b, "products"), w = (e) => /* @__PURE__ */ v(f, {
|
|
26
|
+
basePath: b,
|
|
25
27
|
tab: e
|
|
26
28
|
});
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ y(_, { children: [
|
|
30
|
+
/* @__PURE__ */ v(g, {
|
|
29
31
|
index: !0,
|
|
30
|
-
element: /* @__PURE__ */
|
|
31
|
-
to:
|
|
32
|
+
element: /* @__PURE__ */ v(h, {
|
|
33
|
+
to: S,
|
|
32
34
|
replace: !0
|
|
33
35
|
})
|
|
34
36
|
}),
|
|
35
|
-
/* @__PURE__ */
|
|
37
|
+
/* @__PURE__ */ v(g, {
|
|
36
38
|
path: "languages",
|
|
37
|
-
element:
|
|
39
|
+
element: x ? /* @__PURE__ */ v(c, { basePath: b }) : /* @__PURE__ */ v(e, {})
|
|
38
40
|
}),
|
|
39
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ v(g, {
|
|
40
42
|
path: "languages/new",
|
|
41
|
-
element: /* @__PURE__ */
|
|
43
|
+
element: x ? /* @__PURE__ */ v(u, {
|
|
44
|
+
basePath: b,
|
|
45
|
+
dialog: p
|
|
46
|
+
}) : /* @__PURE__ */ v(o, {})
|
|
42
47
|
}),
|
|
43
|
-
/* @__PURE__ */
|
|
48
|
+
/* @__PURE__ */ v(g, {
|
|
44
49
|
path: "languages/:code",
|
|
45
|
-
element: /* @__PURE__ */
|
|
50
|
+
element: x ? /* @__PURE__ */ v(l, { basePath: b }) : /* @__PURE__ */ v(o, {})
|
|
46
51
|
}),
|
|
47
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ v(g, {
|
|
48
53
|
path: "products",
|
|
49
|
-
element:
|
|
54
|
+
element: x ? w("products") : /* @__PURE__ */ v(t, {})
|
|
50
55
|
}),
|
|
51
|
-
/* @__PURE__ */
|
|
56
|
+
/* @__PURE__ */ v(g, {
|
|
52
57
|
path: "products/*",
|
|
53
|
-
element:
|
|
54
|
-
to:
|
|
58
|
+
element: x ? w("products") : /* @__PURE__ */ v(h, {
|
|
59
|
+
to: C,
|
|
55
60
|
replace: !0
|
|
56
61
|
})
|
|
57
62
|
}),
|
|
58
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ v(g, {
|
|
59
64
|
path: "editor",
|
|
60
|
-
element: /* @__PURE__ */
|
|
65
|
+
element: /* @__PURE__ */ v(n, {})
|
|
61
66
|
}),
|
|
62
|
-
/* @__PURE__ */
|
|
67
|
+
/* @__PURE__ */ v(g, {
|
|
63
68
|
path: "editor/:keyId",
|
|
64
|
-
element: /* @__PURE__ */
|
|
69
|
+
element: /* @__PURE__ */ v(n, {})
|
|
65
70
|
}),
|
|
66
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ v(g, {
|
|
67
72
|
path: "editor/:keyId/:languageCode",
|
|
68
|
-
element: /* @__PURE__ */
|
|
73
|
+
element: /* @__PURE__ */ v(n, {})
|
|
69
74
|
}),
|
|
70
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ v(g, {
|
|
71
76
|
path: "progress",
|
|
72
|
-
element:
|
|
77
|
+
element: x ? w("languages") : /* @__PURE__ */ v(r, {})
|
|
73
78
|
}),
|
|
74
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ v(g, {
|
|
75
80
|
path: "review",
|
|
76
|
-
element:
|
|
81
|
+
element: x ? w("languages") : /* @__PURE__ */ v(i, {})
|
|
77
82
|
}),
|
|
78
|
-
/* @__PURE__ */
|
|
83
|
+
/* @__PURE__ */ v(g, {
|
|
79
84
|
path: "import",
|
|
80
|
-
element: /* @__PURE__ */
|
|
85
|
+
element: /* @__PURE__ */ v(a, { mode: "import" })
|
|
81
86
|
}),
|
|
82
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ v(g, {
|
|
83
88
|
path: "export",
|
|
84
|
-
element: /* @__PURE__ */
|
|
89
|
+
element: x ? /* @__PURE__ */ v(u, {
|
|
90
|
+
basePath: b,
|
|
91
|
+
dialog: m
|
|
92
|
+
}) : /* @__PURE__ */ v(a, { mode: "export" })
|
|
85
93
|
}),
|
|
86
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ v(g, {
|
|
87
95
|
path: "locales",
|
|
88
|
-
element:
|
|
96
|
+
element: x ? w("languages") : /* @__PURE__ */ v(e, {})
|
|
89
97
|
}),
|
|
90
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ v(g, {
|
|
91
99
|
path: "locales/:code",
|
|
92
|
-
element: /* @__PURE__ */
|
|
100
|
+
element: x ? /* @__PURE__ */ v(d, { basePath: b }) : /* @__PURE__ */ v(o, {})
|
|
93
101
|
}),
|
|
94
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ v(g, {
|
|
95
103
|
path: "*",
|
|
96
|
-
element: /* @__PURE__ */
|
|
97
|
-
to:
|
|
104
|
+
element: /* @__PURE__ */ v(h, {
|
|
105
|
+
to: S,
|
|
98
106
|
replace: !0
|
|
99
107
|
})
|
|
100
108
|
})
|
|
101
109
|
] });
|
|
102
110
|
}
|
|
103
|
-
export {
|
|
111
|
+
export { S as I18nRouteTable, x as I18nRoutes };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LanguageRow, ProductRow } from './useLanguagesData';
|
|
2
|
+
export declare function ExportDialog({ open, products, languages, startLanguage, onClose, }: {
|
|
3
|
+
open: boolean;
|
|
4
|
+
products: readonly ProductRow[];
|
|
5
|
+
languages: readonly LanguageRow[];
|
|
6
|
+
/** The language it starts on, or null for every language. */
|
|
7
|
+
startLanguage: string | null;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}): import('react').JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { exportFileName as t, pickProduct as n } from "./languageModel.js";
|
|
3
|
+
import { useExportTranslations as r } from "./useExportTranslations.js";
|
|
4
|
+
import { useId as i, useState as a } from "react";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
import { Button as c, Label as l, ResponsiveDialog as u, ResponsiveDialogContent as d, ResponsiveDialogDescription as f, ResponsiveDialogFooter as p, ResponsiveDialogHeader as m, ResponsiveDialogTitle as h, Select as g, SelectContent as _, SelectItem as v, SelectTrigger as y, SelectValue as b, useNotify as x } from "@burdenoff/fe-libs/ui";
|
|
7
|
+
import { useAppShell as S } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
8
|
+
// src/i18n/v2/ExportDialog.tsx
|
|
9
|
+
var C = "every";
|
|
10
|
+
function w({ id: e, label: t, value: n, onChange: r, testId: i, children: a }) {
|
|
11
|
+
return /* @__PURE__ */ s("div", {
|
|
12
|
+
className: "flex flex-col gap-1.5",
|
|
13
|
+
children: [/* @__PURE__ */ o(l, {
|
|
14
|
+
id: `${e}-label`,
|
|
15
|
+
children: t
|
|
16
|
+
}), /* @__PURE__ */ s(g, {
|
|
17
|
+
value: n,
|
|
18
|
+
onValueChange: r,
|
|
19
|
+
children: [/* @__PURE__ */ o(y, {
|
|
20
|
+
"aria-labelledby": `${e}-label`,
|
|
21
|
+
"data-testid": i,
|
|
22
|
+
children: /* @__PURE__ */ o(b, {})
|
|
23
|
+
}), /* @__PURE__ */ o(_, { children: a })]
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function T({ products: l, languages: u, startLanguage: g, onClose: _ }) {
|
|
28
|
+
let y = e(), b = i(), T = x(), { productName: E } = S(), D = r(), [O, k] = a(() => n(l, null, E)?.id ?? ""), [A, j] = a(g ?? C), [M, N] = a(!1), P = l.find((e) => e.id === O), F = u.find((e) => e.code === A), I = async () => {
|
|
29
|
+
if (P) {
|
|
30
|
+
N(!0);
|
|
31
|
+
try {
|
|
32
|
+
await D({
|
|
33
|
+
productId: P.id,
|
|
34
|
+
languageCode: F ? F.code : null,
|
|
35
|
+
fileName: t(P.displayName, F ? F.code : y("i18n.v3.export.everyFile", "all-languages"), "json")
|
|
36
|
+
}), T({
|
|
37
|
+
title: y("i18n.v3.export.done", "Downloaded {{product}}’s translations", { product: P.displayName }),
|
|
38
|
+
tone: "success"
|
|
39
|
+
}), _();
|
|
40
|
+
} catch {
|
|
41
|
+
T({
|
|
42
|
+
title: y("i18n.v3.export.failed", "Couldn’t export them. Try again."),
|
|
43
|
+
tone: "error"
|
|
44
|
+
});
|
|
45
|
+
} finally {
|
|
46
|
+
N(!1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ s(d, {
|
|
51
|
+
"data-testid": "export-dialog",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ s(m, { children: [/* @__PURE__ */ o(h, { children: y("i18n.v3.export.title", "Export translations") }), /* @__PURE__ */ o(f, { children: y("i18n.v3.export.body", "A JSON file (i18next, nested) with the words that are live.") })] }),
|
|
54
|
+
/* @__PURE__ */ s("div", {
|
|
55
|
+
className: "flex flex-col gap-4",
|
|
56
|
+
children: [/* @__PURE__ */ o(w, {
|
|
57
|
+
id: `${b}-product`,
|
|
58
|
+
label: y("i18n.v3.word.product", "Product"),
|
|
59
|
+
value: O,
|
|
60
|
+
onChange: k,
|
|
61
|
+
testId: "export-product",
|
|
62
|
+
children: l.map((e) => /* @__PURE__ */ o(v, {
|
|
63
|
+
value: e.id,
|
|
64
|
+
children: e.displayName
|
|
65
|
+
}, e.id))
|
|
66
|
+
}), /* @__PURE__ */ s(w, {
|
|
67
|
+
id: `${b}-language`,
|
|
68
|
+
label: y("i18n.v3.export.language", "Language"),
|
|
69
|
+
value: A,
|
|
70
|
+
onChange: j,
|
|
71
|
+
testId: "export-language",
|
|
72
|
+
children: [/* @__PURE__ */ o(v, {
|
|
73
|
+
value: C,
|
|
74
|
+
children: y("i18n.v3.export.every", "Every language")
|
|
75
|
+
}), u.map((e) => /* @__PURE__ */ o(v, {
|
|
76
|
+
value: e.code,
|
|
77
|
+
children: e.name
|
|
78
|
+
}, e.code))]
|
|
79
|
+
})]
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ s(p, { children: [/* @__PURE__ */ o(c, {
|
|
82
|
+
variant: "ghost",
|
|
83
|
+
onClick: _,
|
|
84
|
+
children: y("i18n.v3.cancel", "Cancel")
|
|
85
|
+
}), /* @__PURE__ */ o(c, {
|
|
86
|
+
busy: M,
|
|
87
|
+
disabled: !P,
|
|
88
|
+
onClick: () => void I(),
|
|
89
|
+
"data-testid": "export-download",
|
|
90
|
+
children: y("i18n.v3.export.download", "Download")
|
|
91
|
+
})] })
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function E({ open: e, products: t, languages: n, startLanguage: r, onClose: i }) {
|
|
96
|
+
return /* @__PURE__ */ o(u, {
|
|
97
|
+
open: e,
|
|
98
|
+
onOpenChange: (e) => e ? void 0 : i(),
|
|
99
|
+
children: e ? /* @__PURE__ */ o(T, {
|
|
100
|
+
products: t,
|
|
101
|
+
languages: n,
|
|
102
|
+
startLanguage: r,
|
|
103
|
+
onClose: i
|
|
104
|
+
}) : null
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
export { E as ExportDialog };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LanguageDirection } from '../../generated/global-types';
|
|
2
|
+
/** What the dialog saves: a new language, or new names for one. */
|
|
3
|
+
export interface LanguageFields {
|
|
4
|
+
code: string;
|
|
5
|
+
name: string;
|
|
6
|
+
nativeName: string;
|
|
7
|
+
direction: LanguageDirection;
|
|
8
|
+
}
|
|
9
|
+
type SaveResult = "saved" | "taken" | "failed";
|
|
10
|
+
export declare function LanguageDialog({ open, editing, onSave, onClose, }: {
|
|
11
|
+
open: boolean;
|
|
12
|
+
/** The language whose names change; null to add one. */
|
|
13
|
+
editing: LanguageFields | null;
|
|
14
|
+
onSave: (fields: LanguageFields) => Promise<SaveResult>;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}): import('react').JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { LanguageDirection as t } from "../../generated/global-types.js";
|
|
3
|
+
import { canSaveLanguage as n, codeProblem as r, factsForCode as i } from "./languageModel.js";
|
|
4
|
+
import { useId as a, useRef as o, useState as s } from "react";
|
|
5
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
+
import { Button as d, Input as f, Label as p, ResponsiveDialog as m, ResponsiveDialogContent as h, ResponsiveDialogDescription as g, ResponsiveDialogFooter as _, ResponsiveDialogHeader as v, ResponsiveDialogTitle as y, Segmented as b } from "@burdenoff/fe-libs/ui";
|
|
7
|
+
// src/i18n/v2/LanguageDialog.tsx
|
|
8
|
+
function x({ id: e, label: t, hint: n, children: r }) {
|
|
9
|
+
return /* @__PURE__ */ u("div", {
|
|
10
|
+
className: "flex flex-col gap-1.5",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ l(p, {
|
|
13
|
+
htmlFor: e,
|
|
14
|
+
children: t
|
|
15
|
+
}),
|
|
16
|
+
r,
|
|
17
|
+
n ? /* @__PURE__ */ l("p", {
|
|
18
|
+
id: `${e}-hint`,
|
|
19
|
+
className: "m-0 text-xs text-text-secondary",
|
|
20
|
+
children: n
|
|
21
|
+
}) : null
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function S({ id: t, value: n, problem: r, onChange: i }) {
|
|
26
|
+
let a = e();
|
|
27
|
+
return /* @__PURE__ */ l(x, {
|
|
28
|
+
id: t,
|
|
29
|
+
label: a("i18n.v3.add.code", "Language code"),
|
|
30
|
+
hint: r ?? a("i18n.v3.add.codeHint", "For example es, pt-BR or zh-Hans. It can’t be changed later."),
|
|
31
|
+
children: /* @__PURE__ */ l(f, {
|
|
32
|
+
id: t,
|
|
33
|
+
value: n,
|
|
34
|
+
onChange: (e) => i(e.target.value),
|
|
35
|
+
"aria-describedby": `${t}-hint`,
|
|
36
|
+
"aria-invalid": r ? !0 : void 0,
|
|
37
|
+
autoComplete: "off",
|
|
38
|
+
spellCheck: !1,
|
|
39
|
+
"data-testid": "language-code"
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function C({ id: n, value: r, onChange: i }) {
|
|
44
|
+
let a = e();
|
|
45
|
+
return /* @__PURE__ */ u("div", {
|
|
46
|
+
className: "flex flex-col gap-1.5",
|
|
47
|
+
children: [/* @__PURE__ */ l("span", {
|
|
48
|
+
id: n,
|
|
49
|
+
className: "text-sm font-medium",
|
|
50
|
+
children: a("i18n.v3.lang.reads", "Reads")
|
|
51
|
+
}), /* @__PURE__ */ l(b, {
|
|
52
|
+
"aria-labelledby": n,
|
|
53
|
+
value: r,
|
|
54
|
+
onValueChange: i,
|
|
55
|
+
options: [{
|
|
56
|
+
value: t.Ltr,
|
|
57
|
+
label: a("i18n.v3.lang.ltr", "Left to right")
|
|
58
|
+
}, {
|
|
59
|
+
value: t.Rtl,
|
|
60
|
+
label: a("i18n.v3.lang.rtl", "Right to left")
|
|
61
|
+
}]
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function w({ editing: t }) {
|
|
66
|
+
let n = e();
|
|
67
|
+
return /* @__PURE__ */ u(v, { children: [/* @__PURE__ */ l(y, { children: t ? n("i18n.v3.edit.title", "Change {{name}}’s names", { name: t.name }) : n("i18n.v3.add.title", "Add a language") }), /* @__PURE__ */ l(g, { children: t ? n("i18n.v3.edit.body", "How the language is named here, and to people who speak it.") : n("i18n.v3.add.body", "It is offered as soon as it is added; its words start untranslated.") })] });
|
|
68
|
+
}
|
|
69
|
+
function T({ id: t, name: n, nativeName: r, onName: i, onNativeName: a }) {
|
|
70
|
+
let o = e();
|
|
71
|
+
return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(x, {
|
|
72
|
+
id: `${t}-name`,
|
|
73
|
+
label: o("i18n.v3.add.name", "Name"),
|
|
74
|
+
children: /* @__PURE__ */ l(f, {
|
|
75
|
+
id: `${t}-name`,
|
|
76
|
+
value: n,
|
|
77
|
+
onChange: (e) => i(e.target.value),
|
|
78
|
+
"data-testid": "language-name"
|
|
79
|
+
})
|
|
80
|
+
}), /* @__PURE__ */ l(x, {
|
|
81
|
+
id: `${t}-native`,
|
|
82
|
+
label: o("i18n.v3.add.nativeName", "Its own name"),
|
|
83
|
+
hint: o("i18n.v3.add.nativeHint", "What people who speak it call it, as the language menu shows it."),
|
|
84
|
+
children: /* @__PURE__ */ l(f, {
|
|
85
|
+
id: `${t}-native`,
|
|
86
|
+
value: r,
|
|
87
|
+
onChange: (e) => a(e.target.value),
|
|
88
|
+
"aria-describedby": `${t}-native-hint`,
|
|
89
|
+
dir: "auto",
|
|
90
|
+
"data-testid": "language-native"
|
|
91
|
+
})
|
|
92
|
+
})] });
|
|
93
|
+
}
|
|
94
|
+
function E({ editing: c, onSave: f, onClose: p }) {
|
|
95
|
+
let m = e(), g = a(), v = c === null, [y, b] = s(c ?? {
|
|
96
|
+
code: "",
|
|
97
|
+
name: "",
|
|
98
|
+
nativeName: "",
|
|
99
|
+
direction: t.Ltr
|
|
100
|
+
}), x = o({
|
|
101
|
+
name: !1,
|
|
102
|
+
nativeName: !1
|
|
103
|
+
}), [E, D] = s(!1), [O, k] = s(!1), A = v ? i(y.code) : null, j = v ? r(y.code, E) : null, M = {
|
|
104
|
+
taken: m("i18n.v3.add.taken", "There’s a language with this code already."),
|
|
105
|
+
badCode: m("i18n.v3.add.badCode", "Use a language code such as es, pt-BR or zh-Hans.")
|
|
106
|
+
}, N = (e) => {
|
|
107
|
+
D(!1);
|
|
108
|
+
let n = i(e);
|
|
109
|
+
b((r) => n ? {
|
|
110
|
+
code: e,
|
|
111
|
+
name: x.current.name ? r.name : n.name,
|
|
112
|
+
nativeName: x.current.nativeName ? r.nativeName : n.nativeName,
|
|
113
|
+
direction: n.rtl ? t.Rtl : t.Ltr
|
|
114
|
+
} : {
|
|
115
|
+
...r,
|
|
116
|
+
code: e
|
|
117
|
+
});
|
|
118
|
+
}, P = (e, t) => {
|
|
119
|
+
x.current[e] = !0, b((n) => ({
|
|
120
|
+
...n,
|
|
121
|
+
[e]: t
|
|
122
|
+
}));
|
|
123
|
+
}, F = async () => {
|
|
124
|
+
k(!0);
|
|
125
|
+
let e = "failed";
|
|
126
|
+
try {
|
|
127
|
+
e = await f({
|
|
128
|
+
code: A?.code ?? y.code.trim(),
|
|
129
|
+
name: y.name.trim(),
|
|
130
|
+
nativeName: y.nativeName.trim(),
|
|
131
|
+
direction: y.direction
|
|
132
|
+
});
|
|
133
|
+
} finally {
|
|
134
|
+
k(!1);
|
|
135
|
+
}
|
|
136
|
+
e === "saved" && p(), D(e === "taken");
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ u(h, {
|
|
139
|
+
"data-testid": "language-dialog",
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ l(w, { editing: c }),
|
|
142
|
+
/* @__PURE__ */ u("div", {
|
|
143
|
+
className: "flex flex-col gap-4",
|
|
144
|
+
children: [
|
|
145
|
+
v ? /* @__PURE__ */ l(S, {
|
|
146
|
+
id: `${g}-code`,
|
|
147
|
+
value: y.code,
|
|
148
|
+
problem: j ? M[j] : null,
|
|
149
|
+
onChange: N
|
|
150
|
+
}) : null,
|
|
151
|
+
/* @__PURE__ */ l(T, {
|
|
152
|
+
id: g,
|
|
153
|
+
name: y.name,
|
|
154
|
+
nativeName: y.nativeName,
|
|
155
|
+
onName: (e) => P("name", e),
|
|
156
|
+
onNativeName: (e) => P("nativeName", e)
|
|
157
|
+
}),
|
|
158
|
+
v ? /* @__PURE__ */ l(C, {
|
|
159
|
+
id: `${g}-reads`,
|
|
160
|
+
value: y.direction,
|
|
161
|
+
onChange: (e) => b((t) => ({
|
|
162
|
+
...t,
|
|
163
|
+
direction: e
|
|
164
|
+
}))
|
|
165
|
+
}) : null
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ u(_, { children: [/* @__PURE__ */ l(d, {
|
|
169
|
+
variant: "ghost",
|
|
170
|
+
onClick: p,
|
|
171
|
+
children: m("i18n.v3.cancel", "Cancel")
|
|
172
|
+
}), /* @__PURE__ */ l(d, {
|
|
173
|
+
busy: O,
|
|
174
|
+
disabled: !n(y, A, v),
|
|
175
|
+
onClick: () => void F(),
|
|
176
|
+
"data-testid": "language-save",
|
|
177
|
+
children: v ? m("i18n.v3.addLanguage", "Add language") : m("i18n.v3.edit.save", "Save names")
|
|
178
|
+
})] })
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function D({ open: e, editing: t, onSave: n, onClose: r }) {
|
|
183
|
+
return /* @__PURE__ */ l(m, {
|
|
184
|
+
open: e,
|
|
185
|
+
onOpenChange: (e) => e ? void 0 : r(),
|
|
186
|
+
children: e ? /* @__PURE__ */ l(E, {
|
|
187
|
+
editing: t,
|
|
188
|
+
onSave: n,
|
|
189
|
+
onClose: r
|
|
190
|
+
}) : null
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
export { D as LanguageDialog };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LanguagesLinks } from './links';
|
|
2
|
+
import { LanguageRow, ProductRow } from './useLanguagesData';
|
|
3
|
+
export declare function LanguagesDialogs({ links, products, languages, }: {
|
|
4
|
+
links: LanguagesLinks;
|
|
5
|
+
products: readonly ProductRow[];
|
|
6
|
+
languages: readonly LanguageRow[];
|
|
7
|
+
}): import('react').JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { ExportDialog as t } from "./ExportDialog.js";
|
|
3
|
+
import { LanguageDialog as n } from "./LanguageDialog.js";
|
|
4
|
+
import { ADD_LANGUAGE_DIALOG as r, EXPORT_DIALOG as i, EXPORT_LANGUAGE_PARAM as a } from "./links.js";
|
|
5
|
+
import { useAddLanguage as o } from "./useAddLanguage.js";
|
|
6
|
+
import { useRef as s } from "react";
|
|
7
|
+
import { useNavigate as c, useSearchParams as l } from "react-router";
|
|
8
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
|
+
import { useNotify as p } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
// src/i18n/v2/LanguagesDialogs.tsx
|
|
11
|
+
function m({ links: m, products: h, languages: g }) {
|
|
12
|
+
let _ = e(), v = c(), y = p(), [b, x] = l(), S = o(), C = b.get("dialog"), w = s(null), T = () => {
|
|
13
|
+
let e = w.current;
|
|
14
|
+
if (w.current = null, e) {
|
|
15
|
+
v(m.language(e), { replace: !0 });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let t = new URLSearchParams(b);
|
|
19
|
+
t.delete("dialog"), t.delete(a), x(t, { replace: !0 });
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(n, {
|
|
22
|
+
open: C === r,
|
|
23
|
+
editing: null,
|
|
24
|
+
onClose: T,
|
|
25
|
+
onSave: async (e) => {
|
|
26
|
+
let t = await S(e);
|
|
27
|
+
return t.outcome === "saved" ? (y({
|
|
28
|
+
title: _("i18n.v3.add.added", "Added {{name}}", { name: e.name }),
|
|
29
|
+
tone: "success"
|
|
30
|
+
}), w.current = t.code, "saved") : (t.outcome === "failed" && y({
|
|
31
|
+
title: _("i18n.v3.add.failed", "Couldn’t add it. Try again."),
|
|
32
|
+
tone: "error"
|
|
33
|
+
}), t.outcome);
|
|
34
|
+
}
|
|
35
|
+
}), /* @__PURE__ */ d(t, {
|
|
36
|
+
open: C === i,
|
|
37
|
+
products: h,
|
|
38
|
+
languages: g,
|
|
39
|
+
startLanguage: b.get(a),
|
|
40
|
+
onClose: T
|
|
41
|
+
})] });
|
|
42
|
+
}
|
|
43
|
+
export { m as LanguagesDialogs };
|