@abpjs/ui 0.2.0-next.4 → 0.2.0-next.40
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 +428 -0
- package/dist/agent.d.ts +800 -0
- package/dist/agent.js +2468 -0
- package/dist/agent.js.map +1 -0
- package/dist/ai.d.ts +1 -1
- package/dist/ai.js +25 -9
- package/dist/ai.js.map +1 -1
- package/dist/guard.d.ts +1686 -0
- package/dist/guard.js +4194 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.d.ts +740 -41
- package/dist/index.js +4060 -1379
- package/dist/index.js.map +1 -1
- package/dist/languages.d.ts +162 -0
- package/dist/languages.js +771 -0
- package/dist/languages.js.map +1 -0
- package/dist/rules.d.ts +23 -1
- package/dist/rules.js +35 -0
- package/dist/rules.js.map +1 -1
- package/dist/storage.d.ts +102 -0
- package/dist/storage.js +315 -0
- package/dist/storage.js.map +1 -0
- package/package.json +24 -1
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/areas/languages/LanguagesScreen.tsx
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Grid, HStack, Input, Progress, Stack, Text, VisuallyHidden } from "@chakra-ui/react";
|
|
6
|
+
import { Languages as LanguagesIcon, Star, Trash2 } from "lucide-react";
|
|
7
|
+
import {
|
|
8
|
+
AppLink,
|
|
9
|
+
Button,
|
|
10
|
+
DataTable,
|
|
11
|
+
errorText,
|
|
12
|
+
Field,
|
|
13
|
+
FormDialog,
|
|
14
|
+
HostSlot,
|
|
15
|
+
IconButton,
|
|
16
|
+
notify,
|
|
17
|
+
PageHeader,
|
|
18
|
+
Panel,
|
|
19
|
+
SelectField,
|
|
20
|
+
StatusPill,
|
|
21
|
+
SwitchField,
|
|
22
|
+
useApiQuery,
|
|
23
|
+
useAreaRequest,
|
|
24
|
+
useConfirm
|
|
25
|
+
} from "@abpjs/ui";
|
|
26
|
+
|
|
27
|
+
// src/areas/languages/texts.ts
|
|
28
|
+
import { createAreaTexts } from "@abpjs/ui";
|
|
29
|
+
|
|
30
|
+
// src/areas/languages/texts/ar.json
|
|
31
|
+
var ar_default = {
|
|
32
|
+
title: "\u0627\u0644\u0644\u063A\u0627\u062A",
|
|
33
|
+
description: "\u0627\u0644\u0644\u063A\u0627\u062A \u0627\u0644\u062A\u064A \u064A\u0648\u0641\u0631\u0647\u0627 \u0627\u0644\u0645\u0648\u0642\u0639. \u062A\u0639\u0648\u062F \u0643\u0644 \u0644\u063A\u0629 \u0625\u0644\u0649 \u0644\u063A\u0629 \u0623\u062E\u0631\u0649 \u0644\u0645\u0627 \u0644\u0645 \u064A\u064F\u062A\u0631\u062C\u0645\u060C \u062B\u0645 \u0625\u0644\u0649 \u0627\u0644\u0644\u063A\u0629 \u0627\u0644\u0627\u0641\u062A\u0631\u0627\u0636\u064A\u0629 \u0648\u0627\u0644\u0625\u0646\u062C\u0644\u064A\u0632\u064A\u0629.",
|
|
34
|
+
add: "\u0625\u0636\u0627\u0641\u0629 \u0644\u063A\u0629",
|
|
35
|
+
edit: "\u062A\u062D\u0631\u064A\u0631 {name}",
|
|
36
|
+
save: "\u062D\u0641\u0638",
|
|
37
|
+
none: "\u0644\u0627 \u062A\u0648\u062C\u062F \u0644\u063A\u0627\u062A.",
|
|
38
|
+
language: "\u0627\u0644\u0644\u063A\u0629",
|
|
39
|
+
default: "\u0627\u0641\u062A\u0631\u0627\u0636\u064A\u0629",
|
|
40
|
+
fallback: "\u062A\u0639\u0648\u062F \u0625\u0644\u0649",
|
|
41
|
+
defaultFallback: "\u0627\u0644\u0644\u063A\u0629 \u0627\u0644\u0627\u0641\u062A\u0631\u0627\u0636\u064A\u0629",
|
|
42
|
+
fallbackHelp: "\u062A\u064F\u0633\u062A\u062E\u062F\u0645 \u0644\u0623\u064A \u0646\u0635 \u063A\u064A\u0631 \u0645\u064F\u0639\u0637\u0649 \u0628\u0647\u0630\u0647 \u0627\u0644\u0644\u063A\u0629\u060C \u0642\u0628\u0644 \u0627\u0644\u0644\u063A\u0629 \u0627\u0644\u0627\u0641\u062A\u0631\u0627\u0636\u064A\u0629 \u0648\u0627\u0644\u0625\u0646\u062C\u0644\u064A\u0632\u064A\u0629.",
|
|
43
|
+
translated: "\u0645\u064F\u062A\u0631\u062C\u0645",
|
|
44
|
+
progress: "{done} \u0645\u0646 {total, plural, zero {# \u0646\u0635} one {\u0646\u0635 \u0648\u0627\u062D\u062F} two {\u0646\u0635\u0651\u064A\u0646} few {# \u0646\u0635\u0648\u0635} many {# \u0646\u0635\u064B\u0627} other {# \u0646\u0635}} ({percent}\u066A)",
|
|
45
|
+
enabled: "\u0645\u0641\u0639\u0651\u0644\u0629",
|
|
46
|
+
enabledLabel: "\u0625\u062A\u0627\u062D\u0629 {name}",
|
|
47
|
+
translate: "\u062A\u0631\u062C\u0645\u0629",
|
|
48
|
+
makeDefault: "\u062C\u0639\u0644 {name} \u0627\u0644\u0644\u063A\u0629 \u0627\u0644\u0627\u0641\u062A\u0631\u0627\u0636\u064A\u0629",
|
|
49
|
+
deleteTitle: "\u0625\u0632\u0627\u0644\u0629 {name}\u061F",
|
|
50
|
+
deleteDescription: "\u062A\u064F\u0632\u0627\u0644 \u0645\u0639\u0647\u0627 \u062A\u0631\u062C\u0645\u0627\u062A\u0647\u0627 \u0644\u0646\u0635\u0648\u0635 {product}. \u0644\u0627 \u064A\u0645\u0643\u0646 \u0627\u0644\u062A\u0631\u0627\u062C\u0639 \u0639\u0646 \u0630\u0644\u0643.",
|
|
51
|
+
delete: "\u0625\u0632\u0627\u0644\u0629",
|
|
52
|
+
code: "\u0627\u0644\u0631\u0645\u0632",
|
|
53
|
+
codeHelp: "\u0631\u0645\u0632 BCP 47: fr \u0623\u0648 tr \u0623\u0648 fr-CA. \u0644\u0627 \u064A\u0645\u0643\u0646 \u062A\u063A\u064A\u064A\u0631\u0647 \u0644\u0627\u062D\u0642\u064B\u0627.",
|
|
54
|
+
codePlaceholder: "fr, tr, fr-CA",
|
|
55
|
+
englishName: "\u0627\u0644\u0627\u0633\u0645 \u0628\u0627\u0644\u0625\u0646\u062C\u0644\u064A\u0632\u064A\u0629",
|
|
56
|
+
englishNamePlaceholder: "French",
|
|
57
|
+
nativeName: "\u0627\u0644\u0627\u0633\u0645 \u0628\u0627\u0644\u0644\u063A\u0629 \u0646\u0641\u0633\u0647\u0627",
|
|
58
|
+
nativeNameHelp: "\u064A\u0638\u0647\u0631 \u0641\u064A \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0644\u063A\u0627\u062A.",
|
|
59
|
+
nativeNamePlaceholder: "Fran\xE7ais",
|
|
60
|
+
direction: "\u0627\u0644\u0627\u062A\u062C\u0627\u0647",
|
|
61
|
+
directionAuto: "\u0645\u0646 \u0627\u0644\u0631\u0645\u0632 ({direction})",
|
|
62
|
+
"directions.ltr": "\u0645\u0646 \u0627\u0644\u064A\u0633\u0627\u0631 \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646",
|
|
63
|
+
"directions.rtl": "\u0645\u0646 \u0627\u0644\u064A\u0645\u064A\u0646 \u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631",
|
|
64
|
+
afterAdding: "\u0628\u0639\u062F \u0625\u0636\u0627\u0641\u062A\u0647\u0627\u060C \u062A\u0631\u062C\u0645 \u0646\u0635\u0648\u0635 {product} \u0645\u0646 \u0635\u0641\u062D\u0629 \u0627\u0644\u062A\u0631\u062C\u0645\u0629 \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0647\u0627\u060C \u0623\u0648 \u0627\u0633\u062A\u0648\u0631\u062F \u0645\u0644\u0641\u064B\u0627 \u0645\u0644\u0623\u0647 \u0645\u062A\u0631\u062C\u0645. \u062D\u062A\u0649 \u0630\u0644\u0643 \u0627\u0644\u062D\u064A\u0646 \u062A\u0638\u0647\u0631 \u0646\u0635\u0648\u0635 \u0627\u0644\u0644\u063A\u0629 \u0627\u0644\u0627\u062D\u062A\u064A\u0627\u0637\u064A\u0629.",
|
|
65
|
+
"editor.title": "\u0627\u0644\u062A\u0631\u062C\u0645\u0629: {name}",
|
|
66
|
+
"editor.description": "\u0643\u0644 \u0646\u0635\u0648\u0635 {product}\u060C \u0645\u0639 \u0627\u0644\u0646\u0635 \u0627\u0644\u0625\u0646\u062C\u0644\u064A\u0632\u064A \u0627\u0644\u0623\u0635\u0644\u064A. \u0627\u062A\u0631\u0643 \u0627\u0644\u0646\u0635 \u0641\u0627\u0631\u063A\u064B\u0627 \u0644\u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0627\u0644\u0646\u0635 \u0627\u0644\u0645\u0631\u0641\u0642 \u0623\u0648 \u0627\u0644\u0644\u063A\u0629 \u0627\u0644\u0627\u062D\u062A\u064A\u0627\u0637\u064A\u0629. \u062A\u0638\u0647\u0631 \u0627\u0644\u062A\u063A\u064A\u064A\u0631\u0627\u062A \u0627\u0644\u0645\u062D\u0641\u0648\u0638\u0629 \u0641\u064A \u0643\u0644 \u0627\u0644\u0635\u0641\u062D\u0627\u062A \u0641\u0648\u0631\u064B\u0627.",
|
|
67
|
+
"editor.saved": "{saved, plural, zero {\u0644\u0645 \u062A\u064F\u062D\u0641\u0638 \u0623\u064A \u062A\u0631\u062C\u0645\u0629} one {\u062D\u064F\u0641\u0638\u062A \u062A\u0631\u062C\u0645\u0629 \u0648\u0627\u062D\u062F\u0629} two {\u062D\u064F\u0641\u0638\u062A \u062A\u0631\u062C\u0645\u062A\u0627\u0646} few {\u062D\u064F\u0641\u0638\u062A # \u062A\u0631\u062C\u0645\u0627\u062A} many {\u062D\u064F\u0641\u0638\u062A # \u062A\u0631\u062C\u0645\u0629\u064B} other {\u062D\u064F\u0641\u0638\u062A # \u062A\u0631\u062C\u0645\u0629}}\u060C \u0648{removed, plural, zero {\u0644\u0645 \u062A\u064F\u0632\u064E\u0644 \u0623\u064A \u062A\u0631\u062C\u0645\u0629} one {\u0623\u064F\u0632\u064A\u0644\u062A \u062A\u0631\u062C\u0645\u0629 \u0648\u0627\u062D\u062F\u0629} two {\u0623\u064F\u0632\u064A\u0644\u062A \u062A\u0631\u062C\u0645\u062A\u0627\u0646} few {\u0623\u064F\u0632\u064A\u0644\u062A # \u062A\u0631\u062C\u0645\u0627\u062A} many {\u0623\u064F\u0632\u064A\u0644\u062A # \u062A\u0631\u062C\u0645\u0629\u064B} other {\u0623\u064F\u0632\u064A\u0644\u062A # \u062A\u0631\u062C\u0645\u0629}}.",
|
|
68
|
+
"editor.import": "\u0627\u0633\u062A\u064A\u0631\u0627\u062F \u062A\u0631\u062C\u0645\u0627\u062A",
|
|
69
|
+
"editor.importSubmit": "\u0627\u0633\u062A\u064A\u0631\u0627\u062F",
|
|
70
|
+
"editor.importHint": "\u0645\u0644\u0641 JSON \u0645\u0646 \u0627\u0644\u0646\u0635\u0648\u0635 \u0627\u0644\u0645\u062A\u062F\u0627\u062E\u0644\u0629 \u0643\u0645\u0627 \u064A\u064F\u0646\u062A\u062C\u0647 \u0627\u0644\u062A\u0635\u062F\u064A\u0631. \u062A\u064F\u062A\u062E\u0637\u0649 \u0627\u0644\u0646\u0635\u0648\u0635 \u0627\u0644\u0645\u0637\u0627\u0628\u0642\u0629 \u0644\u0644\u0645\u0631\u0641\u0642\u061B \u0648\u062A\u064F\u0630\u0643\u0631 \u0627\u0644\u0645\u0641\u0627\u062A\u064A\u062D \u063A\u064A\u0631 \u0627\u0644\u0645\u0639\u0631\u0648\u0641\u0629 \u0648\u0644\u0627 \u062A\u064F\u062E\u0632\u064E\u0651\u0646.",
|
|
71
|
+
"editor.imported": "\u0627\u0633\u062A\u064F\u0648\u0631\u062F {imported}\u061B {unchanged} \u062F\u0648\u0646 \u062A\u063A\u064A\u064A\u0631\u060C {kept} \u0623\u064F\u0628\u0642\u064A\u062A\u060C {unknown} \u063A\u064A\u0631 \u0645\u0639\u0631\u0648\u0641\u0629\u060C {refused} \u0645\u0631\u0641\u0648\u0636\u0629.",
|
|
72
|
+
"editor.export": "\u062A\u0635\u062F\u064A\u0631 {catalog}",
|
|
73
|
+
"editor.mainCatalog": "{product}",
|
|
74
|
+
"editor.catalog": "\u0646\u0635\u0648\u0635",
|
|
75
|
+
"editor.allCatalogs": "\u0643\u0644 \u0627\u0644\u0646\u0635\u0648\u0635",
|
|
76
|
+
"editor.status": "\u0627\u0644\u062D\u0627\u0644\u0629",
|
|
77
|
+
"editor.statuses.all": "\u0627\u0644\u0643\u0644",
|
|
78
|
+
"editor.statuses.missing": "\u0645\u0641\u0642\u0648\u062F\u0629",
|
|
79
|
+
"editor.statuses.outdated": "\u0642\u062F\u064A\u0645\u0629",
|
|
80
|
+
"editor.statuses.translated": "\u0645\u062A\u0631\u062C\u0645\u0629 \u0647\u0646\u0627",
|
|
81
|
+
"editor.statuses.bundled": "\u0645\u0631\u0641\u0642\u0629",
|
|
82
|
+
"editor.statuses.source": "\u0627\u0644\u0645\u0635\u062F\u0631 \u0627\u0644\u0625\u0646\u062C\u0644\u064A\u0632\u064A",
|
|
83
|
+
"editor.search": "\u0627\u0644\u0628\u062D\u062B \u0641\u064A \u0627\u0644\u0645\u0641\u0627\u062A\u064A\u062D \u0648\u0627\u0644\u0646\u0635\u0648\u0635",
|
|
84
|
+
"editor.nothing": "\u0644\u0627 \u062A\u0648\u062C\u062F \u0646\u0635\u0648\u0635 \u0645\u0637\u0627\u0628\u0642\u0629.",
|
|
85
|
+
"editor.unsaved": "\u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638\u0629",
|
|
86
|
+
"editor.reset": "\u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0627\u0644\u0646\u0635 \u0627\u0644\u0645\u0631\u0641\u0642",
|
|
87
|
+
"editor.translationOf": "\u062A\u0631\u062C\u0645\u0629 {key}",
|
|
88
|
+
"editor.outdatedHint": "\u062A\u063A\u064A\u0651\u0631 \u0627\u0644\u0646\u0635 \u0627\u0644\u0625\u0646\u062C\u0644\u064A\u0632\u064A \u0628\u0639\u062F \u062A\u0631\u062C\u0645\u0629 \u0647\u0630\u0627. \u0631\u0627\u062C\u0639\u0647 \u0648\u0627\u062D\u0641\u0638\u0647 \u0645\u062C\u062F\u062F\u064B\u0627.",
|
|
89
|
+
"editor.previous": "\u0627\u0644\u0633\u0627\u0628\u0642",
|
|
90
|
+
"editor.next": "\u0627\u0644\u062A\u0627\u0644\u064A",
|
|
91
|
+
"editor.page": "\u0627\u0644\u0635\u0641\u062D\u0629 {page} \u0645\u0646 {pages} \xB7 {count, plural, zero {\u0644\u0627 \u0646\u0635\u0648\u0635} one {\u0646\u0635 \u0648\u0627\u062D\u062F} two {\u0646\u0635\u0651\u0627\u0646} few {# \u0646\u0635\u0648\u0635} many {# \u0646\u0635\u064B\u0627} other {# \u0646\u0635}}",
|
|
92
|
+
"editor.file": "\u0627\u0644\u0645\u0644\u0641",
|
|
93
|
+
"editor.chooseFile": "\u0627\u062E\u062A\u0631 \u0645\u0644\u0641\u064B\u0627.",
|
|
94
|
+
"editor.notJson": "\u0647\u0630\u0627 \u0627\u0644\u0645\u0644\u0641 \u0644\u064A\u0633 JSON.",
|
|
95
|
+
"editor.overwrite": "\u0627\u0633\u062A\u0628\u062F\u0627\u0644 \u0627\u0644\u0646\u0635\u0648\u0635 \u0627\u0644\u0645\u062A\u0631\u062C\u0645\u0629 \u0647\u0646\u0627 \u0633\u0627\u0628\u0642\u064B\u0627",
|
|
96
|
+
"editor.memory": "\u0627\u0644\u0646\u0635 \u0627\u0644\u0625\u0646\u062C\u0644\u064A\u0632\u064A \u0646\u0641\u0633\u0647 \u0641\u064A \u0645\u0643\u0627\u0646 \u0622\u062E\u0631:",
|
|
97
|
+
"editor.useMemory": "\u0627\u0633\u062A\u062E\u062F\u0627\u0645 \xAB{text}\xBB",
|
|
98
|
+
"editor.leaveTitle": "\u0627\u0644\u0645\u063A\u0627\u062F\u0631\u0629 \u062F\u0648\u0646 \u062D\u0641\u0638\u061F",
|
|
99
|
+
"editor.leaveDescription": "{count, plural, zero {\u0644\u0627 \u062A\u063A\u064A\u064A\u0631\u0627\u062A \u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638\u0629.} one {\u062A\u063A\u064A\u064A\u0631 \u0648\u0627\u062D\u062F \u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638 \u0648\u0633\u064A\u0636\u064A\u0639.} two {\u062A\u063A\u064A\u064A\u0631\u0627\u0646 \u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638\u064A\u0646 \u0648\u0633\u064A\u0636\u064A\u0639\u0627\u0646.} few {# \u062A\u063A\u064A\u064A\u0631\u0627\u062A \u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638\u0629 \u0648\u0633\u062A\u0636\u064A\u0639.} many {# \u062A\u063A\u064A\u064A\u0631\u064B\u0627 \u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638 \u0648\u0633\u062A\u0636\u064A\u0639.} other {# \u062A\u063A\u064A\u064A\u0631 \u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638 \u0648\u0633\u062A\u0636\u064A\u0639.}}",
|
|
100
|
+
"editor.leave": "\u0645\u063A\u0627\u062F\u0631\u0629"
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// src/areas/languages/texts/en.json
|
|
104
|
+
var en_default = {
|
|
105
|
+
title: "Languages",
|
|
106
|
+
description: "The languages the site offers. Each falls back to another for anything not translated, then to the default language and English.",
|
|
107
|
+
add: "Add language",
|
|
108
|
+
edit: "Edit {name}",
|
|
109
|
+
save: "Save",
|
|
110
|
+
none: "No languages.",
|
|
111
|
+
language: "Language",
|
|
112
|
+
default: "Default",
|
|
113
|
+
fallback: "Falls back to",
|
|
114
|
+
defaultFallback: "The default language",
|
|
115
|
+
fallbackHelp: "Used for any text not given in this language, before the default language and English.",
|
|
116
|
+
translated: "Translated",
|
|
117
|
+
progress: "{done} of {total, plural, one {# text} other {# texts}} ({percent}%)",
|
|
118
|
+
enabled: "On",
|
|
119
|
+
enabledLabel: "Offer {name}",
|
|
120
|
+
translate: "Translate",
|
|
121
|
+
makeDefault: "Make {name} the default language",
|
|
122
|
+
deleteTitle: "Remove {name}?",
|
|
123
|
+
deleteDescription: "Its translations of {product}\u2019s texts are removed with it. This can\u2019t be undone.",
|
|
124
|
+
delete: "Remove",
|
|
125
|
+
code: "Code",
|
|
126
|
+
codeHelp: "A BCP 47 code: fr, tr, fr-CA. It can\u2019t be changed later.",
|
|
127
|
+
codePlaceholder: "fr, tr, fr-CA",
|
|
128
|
+
englishName: "Name in English",
|
|
129
|
+
englishNamePlaceholder: "French",
|
|
130
|
+
nativeName: "Name in the language",
|
|
131
|
+
nativeNameHelp: "Shown in the language menu.",
|
|
132
|
+
nativeNamePlaceholder: "Fran\xE7ais",
|
|
133
|
+
direction: "Direction",
|
|
134
|
+
directionAuto: "From the code ({direction})",
|
|
135
|
+
"directions.ltr": "Left to right",
|
|
136
|
+
"directions.rtl": "Right to left",
|
|
137
|
+
afterAdding: "After adding it, translate {product}\u2019s texts on its Translate page, or import a file a translator filled in. Until then it shows the fallback\u2019s texts.",
|
|
138
|
+
"editor.title": "Translate: {name}",
|
|
139
|
+
"editor.description": "Every text of {product}, with the English it\u2019s written in. Leave a text empty to use what ships, or the fallback language. Saved changes show on every page at once.",
|
|
140
|
+
"editor.saved": "Saved {saved, plural, one {# translation} other {# translations}} and removed {removed}.",
|
|
141
|
+
"editor.import": "Import translations",
|
|
142
|
+
"editor.importSubmit": "Import",
|
|
143
|
+
"editor.importHint": "A JSON file of nested texts, as Export gives it. Texts that match what ships are skipped; unknown keys are listed, never stored.",
|
|
144
|
+
"editor.imported": "Imported {imported}; {unchanged} unchanged, {kept} kept, {unknown} unknown, {refused} refused.",
|
|
145
|
+
"editor.export": "Export {catalog}",
|
|
146
|
+
"editor.mainCatalog": "{product}",
|
|
147
|
+
"editor.catalog": "Texts of",
|
|
148
|
+
"editor.allCatalogs": "All texts",
|
|
149
|
+
"editor.status": "Status",
|
|
150
|
+
"editor.statuses.all": "All",
|
|
151
|
+
"editor.statuses.missing": "Missing",
|
|
152
|
+
"editor.statuses.outdated": "Out of date",
|
|
153
|
+
"editor.statuses.translated": "Translated here",
|
|
154
|
+
"editor.statuses.bundled": "Shipped",
|
|
155
|
+
"editor.statuses.source": "English source",
|
|
156
|
+
"editor.search": "Search keys and texts",
|
|
157
|
+
"editor.nothing": "No texts match.",
|
|
158
|
+
"editor.unsaved": "Not saved",
|
|
159
|
+
"editor.reset": "Use the shipped text",
|
|
160
|
+
"editor.translationOf": "Translation of {key}",
|
|
161
|
+
"editor.outdatedHint": "The English text changed after this was translated. Check it and save it again.",
|
|
162
|
+
"editor.previous": "Previous",
|
|
163
|
+
"editor.next": "Next",
|
|
164
|
+
"editor.page": "Page {page} of {pages} \xB7 {count, plural, one {# text} other {# texts}}",
|
|
165
|
+
"editor.file": "File",
|
|
166
|
+
"editor.chooseFile": "Choose a file.",
|
|
167
|
+
"editor.notJson": "That file isn\u2019t JSON.",
|
|
168
|
+
"editor.overwrite": "Replace texts already translated here",
|
|
169
|
+
"editor.memory": "Same English elsewhere:",
|
|
170
|
+
"editor.useMemory": "Use \u201C{text}\u201D",
|
|
171
|
+
"editor.leaveTitle": "Leave without saving?",
|
|
172
|
+
"editor.leaveDescription": "{count, plural, one {# change isn\u2019t saved and will be lost.} other {# changes aren\u2019t saved and will be lost.}}",
|
|
173
|
+
"editor.leave": "Leave"
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/areas/languages/texts.ts
|
|
177
|
+
var useLanguagesTexts = createAreaTexts("languages", { en: en_default, ar: ar_default });
|
|
178
|
+
|
|
179
|
+
// src/areas/languages/LanguagesScreen.tsx
|
|
180
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
181
|
+
var RTL = /* @__PURE__ */ new Set(["ar", "fa", "he", "ur", "ps", "ku", "ckb", "dv", "yi", "sd", "ug"]);
|
|
182
|
+
function LanguagesScreen({ translateHref, onChanged }) {
|
|
183
|
+
const t = useLanguagesTexts();
|
|
184
|
+
const confirm = useConfirm();
|
|
185
|
+
const request = useAreaRequest("languages");
|
|
186
|
+
const data = useApiQuery("languages", "/languages?all=true");
|
|
187
|
+
const [editing, setEditing] = useState(null);
|
|
188
|
+
const languages = data.data?.languages ?? [];
|
|
189
|
+
async function changed() {
|
|
190
|
+
await data.reload();
|
|
191
|
+
await onChanged?.();
|
|
192
|
+
}
|
|
193
|
+
async function change(language, body) {
|
|
194
|
+
try {
|
|
195
|
+
await request(`/languages/${encodeURIComponent(language.code)}`, { method: "PUT", body });
|
|
196
|
+
await changed();
|
|
197
|
+
} catch (e) {
|
|
198
|
+
notify.error(errorText(e));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async function remove(language) {
|
|
202
|
+
const sure = await confirm({ title: t("deleteTitle", { name: language.englishName }), description: t("deleteDescription"), confirmLabel: t("delete"), danger: true });
|
|
203
|
+
if (!sure) return;
|
|
204
|
+
try {
|
|
205
|
+
await request(`/languages/${encodeURIComponent(language.code)}`, { method: "DELETE" });
|
|
206
|
+
await changed();
|
|
207
|
+
} catch (e) {
|
|
208
|
+
notify.error(errorText(e));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const columns = [
|
|
212
|
+
{
|
|
213
|
+
id: "language",
|
|
214
|
+
header: t("language"),
|
|
215
|
+
cell: (l) => /* @__PURE__ */ jsxs(Stack, { gap: "0.5", children: [
|
|
216
|
+
/* @__PURE__ */ jsxs(HStack, { gap: "2", children: [
|
|
217
|
+
/* @__PURE__ */ jsx(Button, { variant: "link", size: "sm", onClick: () => setEditing(l), children: /* @__PURE__ */ jsx("span", { lang: l.code, dir: l.direction, children: l.nativeName }) }),
|
|
218
|
+
l.isDefault && /* @__PURE__ */ jsx(StatusPill, { tone: "info", children: t("default") })
|
|
219
|
+
] }),
|
|
220
|
+
/* @__PURE__ */ jsxs(Text, { textStyle: "caption", color: "fg.muted", children: [
|
|
221
|
+
l.englishName,
|
|
222
|
+
" \xB7 ",
|
|
223
|
+
/* @__PURE__ */ jsx("span", { dir: "ltr", children: l.code }),
|
|
224
|
+
" \xB7 ",
|
|
225
|
+
t(`directions.${l.direction === "rtl" ? "rtl" : "ltr"}`)
|
|
226
|
+
] })
|
|
227
|
+
] })
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "fallback",
|
|
231
|
+
header: t("fallback"),
|
|
232
|
+
cell: (l) => l.fallback ? languages.find((x) => x.code === l.fallback)?.englishName ?? l.fallback : /* @__PURE__ */ jsx(Text, { color: "fg.muted", children: t("defaultFallback") })
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: "progress",
|
|
236
|
+
header: t("translated"),
|
|
237
|
+
cell: (l) => {
|
|
238
|
+
const total = Number(l.total ?? 0);
|
|
239
|
+
const done = Number(l.translated ?? 0);
|
|
240
|
+
const percent = total ? Math.floor(done / total * 100) : 0;
|
|
241
|
+
return /* @__PURE__ */ jsxs(Stack, { gap: "1", minW: "40", children: [
|
|
242
|
+
/* @__PURE__ */ jsx(Progress.Root, { value: percent, size: "xs", colorPalette: percent === 100 ? "green" : "blue", children: /* @__PURE__ */ jsx(Progress.Track, { children: /* @__PURE__ */ jsx(Progress.Range, {}) }) }),
|
|
243
|
+
/* @__PURE__ */ jsx(Text, { textStyle: "caption", color: "fg.muted", children: t("progress", { done, total, percent }) })
|
|
244
|
+
] });
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
id: "enabled",
|
|
249
|
+
header: t("enabled"),
|
|
250
|
+
skeleton: "none",
|
|
251
|
+
cell: (l) => /* @__PURE__ */ jsx(
|
|
252
|
+
SwitchField,
|
|
253
|
+
{
|
|
254
|
+
label: /* @__PURE__ */ jsx(VisuallyHidden, { children: t("enabledLabel", { name: l.englishName }) }),
|
|
255
|
+
checked: l.enabled,
|
|
256
|
+
disabled: l.isDefault,
|
|
257
|
+
onCheckedChange: (v) => change(l, { enabled: v })
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
id: "actions",
|
|
263
|
+
header: "",
|
|
264
|
+
align: "end",
|
|
265
|
+
skeleton: "none",
|
|
266
|
+
cell: (l) => /* @__PURE__ */ jsxs(HStack, { gap: "1", justify: "flex-end", children: [
|
|
267
|
+
/* @__PURE__ */ jsxs(AppLink, { href: translateHref(l.code), fontWeight: "medium", display: "inline-flex", alignItems: "center", gap: "1", children: [
|
|
268
|
+
/* @__PURE__ */ jsx(LanguagesIcon, { size: 14 }),
|
|
269
|
+
t("translate")
|
|
270
|
+
] }),
|
|
271
|
+
!l.isDefault && l.enabled && /* @__PURE__ */ jsx(IconButton, { size: "xs", variant: "ghost", "aria-label": t("makeDefault", { name: l.englishName }), onClick: () => change(l, { isDefault: true }), children: /* @__PURE__ */ jsx(Star, {}) }),
|
|
272
|
+
!l.isDefault && l.code !== "en" && /* @__PURE__ */ jsx(IconButton, { danger: true, size: "xs", variant: "ghost", "aria-label": t("deleteTitle", { name: l.englishName }), onClick: () => remove(l), children: /* @__PURE__ */ jsx(Trash2, {}) })
|
|
273
|
+
] })
|
|
274
|
+
}
|
|
275
|
+
];
|
|
276
|
+
return /* @__PURE__ */ jsxs(Stack, { gap: "section", children: [
|
|
277
|
+
/* @__PURE__ */ jsx(
|
|
278
|
+
PageHeader,
|
|
279
|
+
{
|
|
280
|
+
title: t("title"),
|
|
281
|
+
description: t("description"),
|
|
282
|
+
actions: /* @__PURE__ */ jsxs(HStack, { gap: "2", children: [
|
|
283
|
+
/* @__PURE__ */ jsx(HostSlot, { name: "languages.list.actions" }),
|
|
284
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setEditing("new"), children: t("add") })
|
|
285
|
+
] })
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
/* @__PURE__ */ jsx(Panel, { children: /* @__PURE__ */ jsx(
|
|
289
|
+
DataTable,
|
|
290
|
+
{
|
|
291
|
+
"aria-label": t("title"),
|
|
292
|
+
columns,
|
|
293
|
+
rows: data.data?.languages,
|
|
294
|
+
getRowId: (l) => l.code,
|
|
295
|
+
loading: data.loading && !data.data,
|
|
296
|
+
error: data.error,
|
|
297
|
+
empty: t("none")
|
|
298
|
+
}
|
|
299
|
+
) }),
|
|
300
|
+
editing && /* @__PURE__ */ jsx(
|
|
301
|
+
LanguageDialog,
|
|
302
|
+
{
|
|
303
|
+
language: editing === "new" ? null : editing,
|
|
304
|
+
languages,
|
|
305
|
+
onClose: () => setEditing(null),
|
|
306
|
+
onSaved: async () => {
|
|
307
|
+
setEditing(null);
|
|
308
|
+
await changed();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
)
|
|
312
|
+
] });
|
|
313
|
+
}
|
|
314
|
+
function LanguageDialog({ language, languages, onClose, onSaved }) {
|
|
315
|
+
const t = useLanguagesTexts();
|
|
316
|
+
const request = useAreaRequest("languages");
|
|
317
|
+
const [code, setCode] = useState(language?.code ?? "");
|
|
318
|
+
const [englishName, setEnglishName] = useState(language?.englishName ?? "");
|
|
319
|
+
const [nativeName, setNativeName] = useState(language?.nativeName ?? "");
|
|
320
|
+
const [direction, setDirection] = useState(language?.direction ?? "");
|
|
321
|
+
const [fallback, setFallback] = useState(language?.fallback ?? "");
|
|
322
|
+
const [busy, setBusy] = useState(false);
|
|
323
|
+
const [error, setError] = useState(null);
|
|
324
|
+
const guessed = RTL.has(code.trim().toLowerCase().split("-")[0] ?? "") ? "rtl" : "ltr";
|
|
325
|
+
async function submit() {
|
|
326
|
+
setBusy(true);
|
|
327
|
+
setError(null);
|
|
328
|
+
try {
|
|
329
|
+
const body = {
|
|
330
|
+
code: code.trim(),
|
|
331
|
+
englishName: englishName.trim(),
|
|
332
|
+
nativeName: nativeName.trim() || englishName.trim(),
|
|
333
|
+
direction: direction || null,
|
|
334
|
+
fallback: fallback || null
|
|
335
|
+
};
|
|
336
|
+
if (language) await request(`/languages/${encodeURIComponent(language.code)}`, { method: "PUT", body: { ...body, fallback } });
|
|
337
|
+
else await request("/languages", { method: "POST", body });
|
|
338
|
+
await onSaved();
|
|
339
|
+
} catch (e) {
|
|
340
|
+
setError(errorText(e));
|
|
341
|
+
} finally {
|
|
342
|
+
setBusy(false);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return /* @__PURE__ */ jsxs(
|
|
346
|
+
FormDialog,
|
|
347
|
+
{
|
|
348
|
+
open: true,
|
|
349
|
+
onOpenChange: (o) => !o && onClose(),
|
|
350
|
+
title: language ? t("edit", { name: language.englishName }) : t("add"),
|
|
351
|
+
submitLabel: t("save"),
|
|
352
|
+
onSubmit: submit,
|
|
353
|
+
busy,
|
|
354
|
+
error,
|
|
355
|
+
children: [
|
|
356
|
+
/* @__PURE__ */ jsxs(Grid, { templateColumns: { base: "1fr", sm: "1fr 1fr" }, gap: "field", children: [
|
|
357
|
+
/* @__PURE__ */ jsx(Field, { label: t("code"), required: true, helperText: t("codeHelp"), children: /* @__PURE__ */ jsx(Input, { dir: "ltr", value: code, disabled: language != null, placeholder: t("codePlaceholder"), onChange: (e) => setCode(e.target.value), autoFocus: !language }) }),
|
|
358
|
+
/* @__PURE__ */ jsx(Field, { label: t("englishName"), required: true, children: /* @__PURE__ */ jsx(Input, { value: englishName, placeholder: t("englishNamePlaceholder"), onChange: (e) => setEnglishName(e.target.value) }) }),
|
|
359
|
+
/* @__PURE__ */ jsx(Field, { label: t("nativeName"), helperText: t("nativeNameHelp"), children: /* @__PURE__ */ jsx(Input, { value: nativeName, lang: code || void 0, dir: direction || guessed, placeholder: t("nativeNamePlaceholder"), onChange: (e) => setNativeName(e.target.value) }) }),
|
|
360
|
+
/* @__PURE__ */ jsx(Field, { label: t("direction"), children: /* @__PURE__ */ jsx(
|
|
361
|
+
SelectField,
|
|
362
|
+
{
|
|
363
|
+
value: direction,
|
|
364
|
+
onChange: (e) => setDirection(e.target.value),
|
|
365
|
+
options: [
|
|
366
|
+
{ value: "", label: t("directionAuto", { direction: t(`directions.${guessed}`) }) },
|
|
367
|
+
{ value: "ltr", label: t("directions.ltr") },
|
|
368
|
+
{ value: "rtl", label: t("directions.rtl") }
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
) })
|
|
372
|
+
] }),
|
|
373
|
+
/* @__PURE__ */ jsx(Field, { label: t("fallback"), helperText: t("fallbackHelp"), children: /* @__PURE__ */ jsx(
|
|
374
|
+
SelectField,
|
|
375
|
+
{
|
|
376
|
+
value: fallback,
|
|
377
|
+
onChange: (e) => setFallback(e.target.value),
|
|
378
|
+
options: [
|
|
379
|
+
{ value: "", label: t("defaultFallback") },
|
|
380
|
+
...languages.filter((l) => l.code !== (language?.code ?? code.trim())).map((l) => ({ value: l.code, label: `${l.englishName} \xB7 ${l.code}` }))
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
) }),
|
|
384
|
+
!language && /* @__PURE__ */ jsx(Text, { textStyle: "caption", color: "fg.muted", children: t("afterAdding") })
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/areas/languages/TranslateScreen.tsx
|
|
391
|
+
import { useEffect, useMemo, useRef, useState as useState2 } from "react";
|
|
392
|
+
import { Box, Grid as Grid2, HStack as HStack2, Progress as Progress2, Stack as Stack2, Text as Text2, Textarea } from "@chakra-ui/react";
|
|
393
|
+
import { Download, RotateCcw, Upload } from "lucide-react";
|
|
394
|
+
import {
|
|
395
|
+
boneWidth,
|
|
396
|
+
Button as Button2,
|
|
397
|
+
CheckboxField,
|
|
398
|
+
errorText as errorText2,
|
|
399
|
+
Field as Field2,
|
|
400
|
+
FormDialog as FormDialog2,
|
|
401
|
+
ghostCss,
|
|
402
|
+
IconButton as IconButton2,
|
|
403
|
+
InlineAlert,
|
|
404
|
+
Loading,
|
|
405
|
+
notify as notify2,
|
|
406
|
+
PageHeader as PageHeader2,
|
|
407
|
+
Panel as Panel2,
|
|
408
|
+
SaveBar,
|
|
409
|
+
SearchInput,
|
|
410
|
+
SelectField as SelectField2,
|
|
411
|
+
StatusPill as StatusPill2,
|
|
412
|
+
TextBone,
|
|
413
|
+
TextSlot,
|
|
414
|
+
useApiDownload,
|
|
415
|
+
useApiQuery as useApiQuery2,
|
|
416
|
+
useAreaRequest as useAreaRequest2,
|
|
417
|
+
useConfirm as useConfirm2,
|
|
418
|
+
useNavigate
|
|
419
|
+
} from "@abpjs/ui";
|
|
420
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
421
|
+
var PAGE = 50;
|
|
422
|
+
var STATUSES = ["all", "missing", "outdated", "translated", "bundled"];
|
|
423
|
+
var TONES = { missing: "danger", outdated: "warning", translated: "success", bundled: "info", source: "neutral" };
|
|
424
|
+
var keyOf = (e) => `${e.catalog}:${e.key}`;
|
|
425
|
+
var MARK = "\uE000";
|
|
426
|
+
function TranslateScreen({ code, listHref, onChanged, mainCatalog = "app", catalogName }) {
|
|
427
|
+
const t = useLanguagesTexts();
|
|
428
|
+
const request = useAreaRequest2("languages");
|
|
429
|
+
const languages = useApiQuery2("languages", "/languages?all=true");
|
|
430
|
+
const entries = useApiQuery2("languages", `/texts/${encodeURIComponent(code)}/entries`);
|
|
431
|
+
const language = languages.data?.languages.find((l) => l.code === code);
|
|
432
|
+
const [changes, setChanges] = useState2(/* @__PURE__ */ new Map());
|
|
433
|
+
const [catalog, setCatalog] = useState2("all");
|
|
434
|
+
const [status, setStatus] = useState2("all");
|
|
435
|
+
const [search, setSearch] = useState2("");
|
|
436
|
+
const [page, setPage] = useState2(0);
|
|
437
|
+
const [busy, setBusy] = useState2(false);
|
|
438
|
+
const [importing, setImporting] = useState2(false);
|
|
439
|
+
const download = useApiDownload("languages");
|
|
440
|
+
const dirty = changes.size > 0;
|
|
441
|
+
const all = useMemo(() => entries.data?.entries ?? [], [entries.data]);
|
|
442
|
+
const catalogs = useMemo(() => [...new Set(all.map((e) => e.catalog))], [all]);
|
|
443
|
+
const memory = useMemo(() => {
|
|
444
|
+
const found = /* @__PURE__ */ new Map();
|
|
445
|
+
for (const e of all) {
|
|
446
|
+
const text = (changes.get(keyOf(e)) ?? e.value ?? e.bundled ?? "").trim();
|
|
447
|
+
if (!text) continue;
|
|
448
|
+
if (!found.has(e.source)) found.set(e.source, /* @__PURE__ */ new Set());
|
|
449
|
+
found.get(e.source).add(text);
|
|
450
|
+
}
|
|
451
|
+
return found;
|
|
452
|
+
}, [all, changes]);
|
|
453
|
+
const filtered = useMemo(() => {
|
|
454
|
+
const q = search.trim().toLowerCase();
|
|
455
|
+
return all.filter(
|
|
456
|
+
(e) => (catalog === "all" || e.catalog === catalog) && (status === "all" || e.status === status) && (!q || e.key.toLowerCase().includes(q) || e.source.toLowerCase().includes(q) || (e.value ?? e.bundled ?? "").toLowerCase().includes(q))
|
|
457
|
+
);
|
|
458
|
+
}, [all, catalog, status, search]);
|
|
459
|
+
useEffect(() => setPage(0), [catalog, status, search]);
|
|
460
|
+
useLeaveGuard(changes.size);
|
|
461
|
+
const failed = entries.error ?? languages.error;
|
|
462
|
+
if (failed) return /* @__PURE__ */ jsx2(InlineAlert, { tone: "danger", children: failed });
|
|
463
|
+
const pages2 = Math.max(1, Math.ceil(filtered.length / PAGE));
|
|
464
|
+
const current = Math.min(page, pages2 - 1);
|
|
465
|
+
const shown = filtered.slice(current * PAGE, current * PAGE + PAGE);
|
|
466
|
+
const nameOf = (c) => c === mainCatalog ? t("editor.mainCatalog") : catalogName?.(c) ?? c;
|
|
467
|
+
function edit(e, text) {
|
|
468
|
+
setChanges((prev) => {
|
|
469
|
+
const next = new Map(prev);
|
|
470
|
+
if (text === (e.value ?? "")) next.delete(keyOf(e));
|
|
471
|
+
else next.set(keyOf(e), text);
|
|
472
|
+
return next;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
async function reloadAll() {
|
|
476
|
+
await Promise.all([entries.reload(), languages.reload()]);
|
|
477
|
+
await onChanged?.();
|
|
478
|
+
}
|
|
479
|
+
async function save() {
|
|
480
|
+
setBusy(true);
|
|
481
|
+
const sent = new Map(changes);
|
|
482
|
+
try {
|
|
483
|
+
const texts = [...sent.entries()].map(([k, value]) => {
|
|
484
|
+
const at = k.indexOf(":");
|
|
485
|
+
return { catalog: k.slice(0, at), key: k.slice(at + 1), value: value.trim() ? value : null };
|
|
486
|
+
});
|
|
487
|
+
const result = await request(`/texts/${encodeURIComponent(code)}`, { method: "PUT", body: { texts } });
|
|
488
|
+
setChanges((prev) => {
|
|
489
|
+
const next = new Map(prev);
|
|
490
|
+
for (const [k, value] of sent) if (next.get(k) === value) next.delete(k);
|
|
491
|
+
return next;
|
|
492
|
+
});
|
|
493
|
+
notify2.success(t("editor.saved", { saved: Number(result.saved), removed: Number(result.removed) }));
|
|
494
|
+
await reloadAll();
|
|
495
|
+
} catch (e) {
|
|
496
|
+
notify2.error(errorText2(e));
|
|
497
|
+
} finally {
|
|
498
|
+
setBusy(false);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
async function exportCatalog(name) {
|
|
502
|
+
try {
|
|
503
|
+
await download(`/texts/${encodeURIComponent(code)}/export?catalog=${encodeURIComponent(name)}`, {}, `${name}.${code}.json`);
|
|
504
|
+
} catch (e) {
|
|
505
|
+
notify2.error(errorText2(e));
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const loading = !entries.data || !languages.data;
|
|
509
|
+
const total = Number(language?.total ?? entries.data?.total ?? 0);
|
|
510
|
+
const done = Number(language?.translated ?? entries.data?.translated ?? 0);
|
|
511
|
+
const percent = total ? Math.floor(done / total * 100) : 0;
|
|
512
|
+
const counts = Object.fromEntries(STATUSES.map((s) => [s, s === "all" ? all.length : all.filter((e) => e.status === s).length]));
|
|
513
|
+
const direction = language?.direction ?? "ltr";
|
|
514
|
+
return /* @__PURE__ */ jsx2(Loading, { when: loading, children: /* @__PURE__ */ jsxs2(Stack2, { gap: "section", pb: dirty ? "24" : void 0, children: [
|
|
515
|
+
/* @__PURE__ */ jsx2(
|
|
516
|
+
PageHeader2,
|
|
517
|
+
{
|
|
518
|
+
breadcrumbs: [{ label: t("title"), href: listHref }, { label: language?.englishName ?? code }],
|
|
519
|
+
title: languages.data && t("editor.title", { name: language?.nativeName ?? code }),
|
|
520
|
+
description: t("editor.description"),
|
|
521
|
+
actions: /* @__PURE__ */ jsxs2(Button2, { variant: "secondary", onClick: () => setImporting(true), children: [
|
|
522
|
+
/* @__PURE__ */ jsx2(Upload, {}),
|
|
523
|
+
t("editor.import")
|
|
524
|
+
] })
|
|
525
|
+
}
|
|
526
|
+
),
|
|
527
|
+
/* @__PURE__ */ jsx2(Panel2, { children: /* @__PURE__ */ jsxs2(Stack2, { gap: "3", children: [
|
|
528
|
+
/* @__PURE__ */ jsxs2(HStack2, { justify: "space-between", wrap: "wrap", gap: "3", children: [
|
|
529
|
+
/* @__PURE__ */ jsxs2(Stack2, { gap: "1", minW: "60", flex: "1", children: [
|
|
530
|
+
/* @__PURE__ */ jsx2(Progress2.Root, { value: percent, size: "sm", colorPalette: percent === 100 ? "green" : "blue", css: loading ? ghostCss : void 0, children: /* @__PURE__ */ jsx2(Progress2.Track, { children: /* @__PURE__ */ jsx2(Progress2.Range, {}) }) }),
|
|
531
|
+
/* @__PURE__ */ jsx2(Text2, { textStyle: "caption", color: "fg.muted", children: /* @__PURE__ */ jsx2(TextSlot, { width: 28, children: t("progress", { done, total, percent }) }) })
|
|
532
|
+
] }),
|
|
533
|
+
/* @__PURE__ */ jsx2(HStack2, { gap: "1", wrap: "wrap", children: (loading ? [mainCatalog] : catalogs).map((c) => /* @__PURE__ */ jsxs2(Button2, { size: "xs", variant: "ghost", onClick: () => exportCatalog(c), children: [
|
|
534
|
+
/* @__PURE__ */ jsx2(Download, {}),
|
|
535
|
+
t("editor.export", { catalog: nameOf(c) })
|
|
536
|
+
] }, c)) })
|
|
537
|
+
] }),
|
|
538
|
+
/* @__PURE__ */ jsxs2(Grid2, { templateColumns: { base: "1fr", md: catalogs.length > 1 ? "1fr 1fr 2fr" : "1fr 2fr" }, gap: "2", children: [
|
|
539
|
+
catalogs.length > 1 && /* @__PURE__ */ jsx2(
|
|
540
|
+
SelectField2,
|
|
541
|
+
{
|
|
542
|
+
"aria-label": t("editor.catalog"),
|
|
543
|
+
value: catalog,
|
|
544
|
+
onChange: (e) => setCatalog(e.target.value),
|
|
545
|
+
options: [{ value: "all", label: t("editor.allCatalogs") }, ...catalogs.map((c) => ({ value: c, label: nameOf(c) }))]
|
|
546
|
+
}
|
|
547
|
+
),
|
|
548
|
+
/* @__PURE__ */ jsx2(
|
|
549
|
+
SelectField2,
|
|
550
|
+
{
|
|
551
|
+
"aria-label": t("editor.status"),
|
|
552
|
+
value: status,
|
|
553
|
+
onChange: (e) => setStatus(e.target.value),
|
|
554
|
+
options: STATUSES.map((s) => ({ value: s, label: `${t(`editor.statuses.${s}`)} (${counts[s]})` }))
|
|
555
|
+
}
|
|
556
|
+
),
|
|
557
|
+
/* @__PURE__ */ jsx2(SearchInput, { value: search, onChange: (e) => setSearch(e.target.value), placeholder: t("editor.search"), "aria-label": t("editor.search") })
|
|
558
|
+
] })
|
|
559
|
+
] }) }),
|
|
560
|
+
/* @__PURE__ */ jsxs2(Stack2, { gap: "2", "data-testid": "text-entries", children: [
|
|
561
|
+
loading && Array.from({ length: 8 }, (_, i) => /* @__PURE__ */ jsx2(EntryPlaceholder, { index: i }, i)),
|
|
562
|
+
!loading && shown.length === 0 && /* @__PURE__ */ jsx2(Text2, { color: "fg.muted", children: t("editor.nothing") }),
|
|
563
|
+
shown.map((e) => /* @__PURE__ */ jsx2(
|
|
564
|
+
EntryRow,
|
|
565
|
+
{
|
|
566
|
+
entry: e,
|
|
567
|
+
catalogs: catalogs.length,
|
|
568
|
+
catalogName: nameOf,
|
|
569
|
+
language: code,
|
|
570
|
+
direction,
|
|
571
|
+
value: changes.get(keyOf(e)) ?? e.value ?? "",
|
|
572
|
+
changed: changes.has(keyOf(e)),
|
|
573
|
+
memory: code === "en" ? [] : [...memory.get(e.source) ?? []].filter((text) => text !== (changes.get(keyOf(e)) ?? e.value ?? e.bundled ?? "").trim()).slice(0, 3),
|
|
574
|
+
onChange: (text) => edit(e, text)
|
|
575
|
+
},
|
|
576
|
+
keyOf(e)
|
|
577
|
+
))
|
|
578
|
+
] }),
|
|
579
|
+
pages2 > 1 && /* @__PURE__ */ jsxs2(HStack2, { justify: "center", gap: "2", children: [
|
|
580
|
+
/* @__PURE__ */ jsx2(Button2, { size: "sm", variant: "ghost", disabled: current === 0, onClick: () => setPage(current - 1), children: t("editor.previous") }),
|
|
581
|
+
/* @__PURE__ */ jsx2(Text2, { textStyle: "caption", children: t("editor.page", { page: current + 1, pages: pages2, count: filtered.length }) }),
|
|
582
|
+
/* @__PURE__ */ jsx2(Button2, { size: "sm", variant: "ghost", disabled: current >= pages2 - 1, onClick: () => setPage(current + 1), children: t("editor.next") })
|
|
583
|
+
] }),
|
|
584
|
+
/* @__PURE__ */ jsx2(SaveBar, { open: dirty, count: changes.size, onSave: save, onDiscard: () => setChanges(/* @__PURE__ */ new Map()), busy }),
|
|
585
|
+
importing && /* @__PURE__ */ jsx2(
|
|
586
|
+
ImportDialog,
|
|
587
|
+
{
|
|
588
|
+
code,
|
|
589
|
+
catalogs: catalogs.length ? catalogs : [mainCatalog],
|
|
590
|
+
catalogName: nameOf,
|
|
591
|
+
onClose: () => setImporting(false),
|
|
592
|
+
onImported: async () => {
|
|
593
|
+
setImporting(false);
|
|
594
|
+
await reloadAll();
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
)
|
|
598
|
+
] }) });
|
|
599
|
+
}
|
|
600
|
+
function useLeaveGuard(unsaved) {
|
|
601
|
+
const t = useLanguagesTexts();
|
|
602
|
+
const confirm = useConfirm2();
|
|
603
|
+
const navigate = useNavigate();
|
|
604
|
+
useEffect(() => {
|
|
605
|
+
if (!unsaved) return;
|
|
606
|
+
const warn = (e) => e.preventDefault();
|
|
607
|
+
const click = (e) => {
|
|
608
|
+
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
609
|
+
const link = e.target instanceof Element ? e.target.closest("a[href]") : null;
|
|
610
|
+
if (!link || link.target && link.target !== "_self" || link.hasAttribute("download")) return;
|
|
611
|
+
const to = new URL(link.href, window.location.href);
|
|
612
|
+
const here = window.location;
|
|
613
|
+
if (to.origin !== here.origin || to.pathname === here.pathname && to.search === here.search) return;
|
|
614
|
+
e.preventDefault();
|
|
615
|
+
e.stopPropagation();
|
|
616
|
+
void confirm({ title: t("editor.leaveTitle"), description: t("editor.leaveDescription", { count: unsaved }), confirmLabel: t("editor.leave"), danger: true }).then(
|
|
617
|
+
(leave) => {
|
|
618
|
+
if (leave) navigate(`${to.pathname}${to.search}${to.hash}`);
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
};
|
|
622
|
+
window.addEventListener("beforeunload", warn);
|
|
623
|
+
document.addEventListener("click", click, true);
|
|
624
|
+
return () => {
|
|
625
|
+
window.removeEventListener("beforeunload", warn);
|
|
626
|
+
document.removeEventListener("click", click, true);
|
|
627
|
+
};
|
|
628
|
+
}, [unsaved, t, confirm, navigate]);
|
|
629
|
+
}
|
|
630
|
+
function EntryPlaceholder({ index }) {
|
|
631
|
+
return /* @__PURE__ */ jsxs2(Box, { borderWidth: "1px", borderColor: "border.muted", rounded: "l2", p: "3", children: [
|
|
632
|
+
/* @__PURE__ */ jsxs2(HStack2, { justify: "space-between", gap: "2", mb: "2", wrap: "wrap", children: [
|
|
633
|
+
/* @__PURE__ */ jsx2(Text2, { fontFamily: "mono", textStyle: "caption", children: /* @__PURE__ */ jsx2(TextBone, { width: boneWidth(index, 14, 30) }) }),
|
|
634
|
+
/* @__PURE__ */ jsx2(StatusPill2, {})
|
|
635
|
+
] }),
|
|
636
|
+
/* @__PURE__ */ jsxs2(Grid2, { templateColumns: { base: "1fr", md: "1fr 1fr" }, gap: "3", children: [
|
|
637
|
+
/* @__PURE__ */ jsx2(Text2, { textStyle: "body.sm", children: /* @__PURE__ */ jsx2(TextBone, { width: boneWidth(index, 10, 40) }) }),
|
|
638
|
+
/* @__PURE__ */ jsx2(Textarea, { size: "sm", rows: 1, readOnly: true, tabIndex: -1, "aria-hidden": "true", css: ghostCss })
|
|
639
|
+
] })
|
|
640
|
+
] });
|
|
641
|
+
}
|
|
642
|
+
function EntryRow({ entry, catalogs, catalogName, language, direction, value, changed, memory, onChange }) {
|
|
643
|
+
const t = useLanguagesTexts();
|
|
644
|
+
const long = entry.source.length > 60 || entry.source.includes("\n");
|
|
645
|
+
return /* @__PURE__ */ jsxs2(Box, { borderWidth: "1px", borderColor: changed ? "border.emphasized" : "border.muted", rounded: "l2", p: "3", "data-key": entry.key, "data-status": entry.status, children: [
|
|
646
|
+
/* @__PURE__ */ jsxs2(HStack2, { justify: "space-between", gap: "2", mb: "2", wrap: "wrap", children: [
|
|
647
|
+
/* @__PURE__ */ jsxs2(Text2, { fontFamily: "mono", textStyle: "caption", color: "fg.muted", dir: "ltr", children: [
|
|
648
|
+
catalogs > 1 ? `${catalogName(entry.catalog)} \xB7 ` : "",
|
|
649
|
+
entry.key
|
|
650
|
+
] }),
|
|
651
|
+
/* @__PURE__ */ jsxs2(HStack2, { gap: "1", children: [
|
|
652
|
+
/* @__PURE__ */ jsx2(StatusPill2, { tone: changed ? "warning" : TONES[entry.status] ?? "neutral", children: changed ? t("editor.unsaved") : t(`editor.statuses.${entry.status}`) }),
|
|
653
|
+
(entry.value != null || changed) && /* @__PURE__ */ jsx2(IconButton2, { size: "xs", variant: "ghost", "aria-label": t("editor.reset"), onClick: () => onChange(changed ? entry.value ?? "" : ""), children: /* @__PURE__ */ jsx2(RotateCcw, {}) })
|
|
654
|
+
] })
|
|
655
|
+
] }),
|
|
656
|
+
/* @__PURE__ */ jsxs2(Grid2, { templateColumns: { base: "1fr", md: "1fr 1fr" }, gap: "3", children: [
|
|
657
|
+
/* @__PURE__ */ jsx2(Text2, { textStyle: "body.sm", dir: "ltr", lang: "en", whiteSpace: "pre-wrap", children: entry.source }),
|
|
658
|
+
/* @__PURE__ */ jsx2(
|
|
659
|
+
Textarea,
|
|
660
|
+
{
|
|
661
|
+
size: "sm",
|
|
662
|
+
rows: long ? 3 : 1,
|
|
663
|
+
autoresize: true,
|
|
664
|
+
dir: direction,
|
|
665
|
+
lang: language,
|
|
666
|
+
value,
|
|
667
|
+
placeholder: language === "en" ? entry.source : entry.bundled ?? "",
|
|
668
|
+
"aria-label": t("editor.translationOf", { key: entry.key }),
|
|
669
|
+
onChange: (e) => onChange(e.target.value)
|
|
670
|
+
}
|
|
671
|
+
)
|
|
672
|
+
] }),
|
|
673
|
+
memory.length > 0 && !value.trim() && /* @__PURE__ */ jsxs2(HStack2, { gap: "1", mt: "2", wrap: "wrap", "data-testid": "translation-memory", children: [
|
|
674
|
+
/* @__PURE__ */ jsx2(Text2, { textStyle: "caption", color: "fg.muted", children: t("editor.memory") }),
|
|
675
|
+
memory.map((text) => {
|
|
676
|
+
const [before, after = ""] = t("editor.useMemory", { text: MARK }).split(MARK);
|
|
677
|
+
return /* @__PURE__ */ jsxs2(Button2, { size: "xs", variant: "ghost", onClick: () => onChange(text), children: [
|
|
678
|
+
before,
|
|
679
|
+
/* @__PURE__ */ jsx2("span", { lang: language, dir: direction, children: text }),
|
|
680
|
+
after
|
|
681
|
+
] }, text);
|
|
682
|
+
})
|
|
683
|
+
] }),
|
|
684
|
+
entry.status === "outdated" && /* @__PURE__ */ jsx2(Text2, { textStyle: "caption", color: "fg.warning", mt: "1", children: t("editor.outdatedHint") })
|
|
685
|
+
] });
|
|
686
|
+
}
|
|
687
|
+
function ImportDialog({ code, catalogs, catalogName, onClose, onImported }) {
|
|
688
|
+
const t = useLanguagesTexts();
|
|
689
|
+
const request = useAreaRequest2("languages");
|
|
690
|
+
const file = useRef(null);
|
|
691
|
+
const [catalog, setCatalog] = useState2(catalogs[0]);
|
|
692
|
+
const [overwrite, setOverwrite] = useState2(false);
|
|
693
|
+
const [busy, setBusy] = useState2(false);
|
|
694
|
+
const [error, setError] = useState2(null);
|
|
695
|
+
async function submit() {
|
|
696
|
+
const chosen = file.current?.files?.[0];
|
|
697
|
+
if (!chosen) {
|
|
698
|
+
setError(t("editor.chooseFile"));
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
setBusy(true);
|
|
702
|
+
setError(null);
|
|
703
|
+
try {
|
|
704
|
+
const messages = JSON.parse(await chosen.text());
|
|
705
|
+
const result = await request(`/texts/${encodeURIComponent(code)}/import`, { method: "POST", body: { catalog, messages, overwrite } });
|
|
706
|
+
notify2.success(
|
|
707
|
+
t("editor.imported", {
|
|
708
|
+
imported: Number(result.imported),
|
|
709
|
+
unchanged: Number(result.unchanged),
|
|
710
|
+
kept: Number(result.kept),
|
|
711
|
+
unknown: result.unknown.length,
|
|
712
|
+
refused: result.refused.length
|
|
713
|
+
})
|
|
714
|
+
);
|
|
715
|
+
await onImported();
|
|
716
|
+
} catch (e) {
|
|
717
|
+
setError(e instanceof SyntaxError ? t("editor.notJson") : errorText2(e));
|
|
718
|
+
} finally {
|
|
719
|
+
setBusy(false);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return /* @__PURE__ */ jsxs2(FormDialog2, { open: true, onOpenChange: (o) => !o && onClose(), title: t("editor.import"), submitLabel: t("editor.importSubmit"), onSubmit: submit, busy, error, children: [
|
|
723
|
+
/* @__PURE__ */ jsx2(Text2, { textStyle: "body.sm", color: "fg.muted", children: t("editor.importHint") }),
|
|
724
|
+
catalogs.length > 1 && /* @__PURE__ */ jsx2(Field2, { label: t("editor.catalog"), children: /* @__PURE__ */ jsx2(SelectField2, { value: catalog, onChange: (e) => setCatalog(e.target.value), options: catalogs.map((c) => ({ value: c, label: catalogName(c) })) }) }),
|
|
725
|
+
/* @__PURE__ */ jsx2(Field2, { label: t("editor.file"), required: true, children: /* @__PURE__ */ jsx2("input", { ref: file, type: "file", accept: "application/json,.json", "aria-label": t("editor.file") }) }),
|
|
726
|
+
/* @__PURE__ */ jsx2(CheckboxField, { label: t("editor.overwrite"), checked: overwrite, onCheckedChange: setOverwrite })
|
|
727
|
+
] });
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// src/areas/languages/pages.tsx
|
|
731
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
732
|
+
var pages = /* @__PURE__ */ new Map();
|
|
733
|
+
function pageFor(href, options) {
|
|
734
|
+
const kept = pages.get(href);
|
|
735
|
+
if (kept) {
|
|
736
|
+
kept.options = options;
|
|
737
|
+
return kept.component;
|
|
738
|
+
}
|
|
739
|
+
const entry = { options, component: (() => null) };
|
|
740
|
+
const translateHref = (code) => `${href}/${encodeURIComponent(code)}`;
|
|
741
|
+
const onChanged = () => entry.options.onChanged?.();
|
|
742
|
+
entry.component = function LanguagesPage({ path }) {
|
|
743
|
+
const { mainCatalog, catalogName } = entry.options;
|
|
744
|
+
return path[0] ? /* @__PURE__ */ jsx3(TranslateScreen, { code: path[0], listHref: href, onChanged, mainCatalog, catalogName }, path[0]) : /* @__PURE__ */ jsx3(LanguagesScreen, { translateHref, onChanged });
|
|
745
|
+
};
|
|
746
|
+
pages.set(href, entry);
|
|
747
|
+
return entry.component;
|
|
748
|
+
}
|
|
749
|
+
function languagesPages(options) {
|
|
750
|
+
const href = options.href.replace(/\/$/, "");
|
|
751
|
+
return [
|
|
752
|
+
{
|
|
753
|
+
id: "languages.admin",
|
|
754
|
+
section: options.section,
|
|
755
|
+
weight: options.weight ?? 100,
|
|
756
|
+
title: options.title ?? en_default.title,
|
|
757
|
+
href,
|
|
758
|
+
about: options.about,
|
|
759
|
+
plugin: "languages",
|
|
760
|
+
visible: options.visible ?? (options.host?.can ? () => options.host.can("languages.site.admin") : void 0),
|
|
761
|
+
component: pageFor(href, options)
|
|
762
|
+
}
|
|
763
|
+
];
|
|
764
|
+
}
|
|
765
|
+
export {
|
|
766
|
+
LanguagesScreen,
|
|
767
|
+
TranslateScreen,
|
|
768
|
+
languagesPages,
|
|
769
|
+
useLanguagesTexts
|
|
770
|
+
};
|
|
771
|
+
//# sourceMappingURL=languages.js.map
|