@burdenoff/microfe-i18n 2026.1129.1 → 2026.1129.3

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.
Files changed (46) hide show
  1. package/dist/generated/global-operations.d.ts +292 -0
  2. package/dist/generated/global-operations.js +143 -15
  3. package/dist/generated/global-types.js +3 -1
  4. package/dist/i18n/I18nRoutes.d.ts +5 -3
  5. package/dist/i18n/I18nRoutes.js +48 -47
  6. package/dist/i18n/v2/LanguageDialog.d.ts +17 -0
  7. package/dist/i18n/v2/LanguageDialog.js +193 -0
  8. package/dist/i18n/v2/LanguagesPage.js +82 -53
  9. package/dist/i18n/v2/LanguagesTab.d.ts +3 -1
  10. package/dist/i18n/v2/LanguagesTab.js +31 -26
  11. package/dist/i18n/v2/ReviewRows.js +2 -2
  12. package/dist/i18n/v2/ReviewTab.d.ts +3 -1
  13. package/dist/i18n/v2/ReviewTab.js +27 -26
  14. package/dist/i18n/v2/TabRedirect.d.ts +8 -0
  15. package/dist/i18n/v2/TabRedirect.js +26 -9
  16. package/dist/i18n/v2/language/FormatsTab.d.ts +6 -0
  17. package/dist/i18n/v2/language/FormatsTab.js +93 -0
  18. package/dist/i18n/v2/language/LanguagePage.d.ts +3 -0
  19. package/dist/i18n/v2/language/LanguagePage.js +245 -0
  20. package/dist/i18n/v2/language/TranslateDialog.d.ts +18 -0
  21. package/dist/i18n/v2/language/TranslateDialog.js +101 -0
  22. package/dist/i18n/v2/language/WordsTab.d.ts +11 -0
  23. package/dist/i18n/v2/language/WordsTab.js +190 -0
  24. package/dist/i18n/v2/language/useLanguage.d.ts +23 -0
  25. package/dist/i18n/v2/language/useLanguage.js +22 -0
  26. package/dist/i18n/v2/language/useWords.d.ts +31 -0
  27. package/dist/i18n/v2/language/useWords.js +51 -0
  28. package/dist/i18n/v2/languageModel.d.ts +61 -0
  29. package/dist/i18n/v2/languageModel.js +120 -0
  30. package/dist/i18n/v2/links.d.ts +4 -1
  31. package/dist/i18n/v2/links.js +11 -10
  32. package/dist/i18n/v2/model.d.ts +12 -2
  33. package/dist/i18n/v2/model.js +17 -14
  34. package/dist/i18n/v2/reviewMessages.d.ts +1 -1
  35. package/dist/i18n/v2/useAddLanguage.d.ts +10 -0
  36. package/dist/i18n/v2/useAddLanguage.js +30 -0
  37. package/dist/i18n/v2/useDebouncedValue.d.ts +1 -0
  38. package/dist/i18n/v2/useDebouncedValue.js +10 -0
  39. package/dist/i18n/v2/useReviewActions.d.ts +3 -1
  40. package/dist/i18n/v2/useReviewActions.js +24 -24
  41. package/dist/i18n/v2/useReviewQueue.d.ts +5 -2
  42. package/dist/i18n/v2/useReviewQueue.js +9 -6
  43. package/dist/node_modules/lucide-react/dist/esm/icons/calendar-days.js +49 -0
  44. package/dist/node_modules/lucide-react/dist/esm/icons/eye-off.js +21 -0
  45. package/dist/node_modules/lucide-react/dist/esm/icons/eye.js +12 -0
  46. package/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ import e from "../../../node_modules/lucide-react/dist/esm/icons/languages.js";
2
+ import t from "../../../node_modules/lucide-react/dist/esm/icons/pencil.js";
3
+ import n from "../../../node_modules/lucide-react/dist/esm/icons/search.js";
4
+ import { useTr as r } from "../../hooks/useTr.js";
5
+ import { PRODUCT_PARAM as i, pickProduct as a, translationIn as o } from "../languageModel.js";
6
+ import { useDebouncedValue as s } from "../useDebouncedValue.js";
7
+ import { TranslateDialog as c } from "./TranslateDialog.js";
8
+ import { useWords as l } from "./useWords.js";
9
+ import { useState as u } from "react";
10
+ import { useSearchParams as d } from "react-router";
11
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
+ import { ActionMenu as m, Button as h, DataRows as g, EmptyState as _, Input as v, LoadError as y, Notice as b, Select as x, SelectContent as S, SelectItem as C, SelectTrigger as w, SelectValue as T, StatusChip as E, useNotify as D } from "@burdenoff/fe-libs/ui";
13
+ import { useAppShell as O } from "@burdenoff/fe-libs/shared/providers/shell";
14
+ // src/i18n/v2/language/WordsTab.tsx
15
+ function k({ products: e, current: t }) {
16
+ let n = r(), [a, o] = d();
17
+ return /* @__PURE__ */ p(x, {
18
+ value: t?.id ?? "",
19
+ onValueChange: (e) => {
20
+ let t = new URLSearchParams(a);
21
+ t.set(i, e), o(t, { replace: !0 });
22
+ },
23
+ children: [/* @__PURE__ */ f(w, {
24
+ className: "w-auto min-w-44",
25
+ "aria-label": n("i18n.v3.word.product", "Product"),
26
+ "data-testid": "words-product",
27
+ children: /* @__PURE__ */ f(T, { placeholder: n("i18n.v3.word.product", "Product") })
28
+ }), /* @__PURE__ */ f(S, { children: e.map((e) => /* @__PURE__ */ f(C, {
29
+ value: e.id,
30
+ children: e.displayName
31
+ }, e.id)) })]
32
+ });
33
+ }
34
+ function A({ words: n, state: i, languageCode: a, languageName: s, sourceName: c, rtl: l, onTranslate: u }) {
35
+ let d = r();
36
+ return /* @__PURE__ */ f(g, {
37
+ items: n,
38
+ getId: (e) => e.id,
39
+ label: d("i18n.v3.word.list", "Words"),
40
+ loading: i.loading,
41
+ lead: {
42
+ header: c,
43
+ width: "minmax(0,1.5fr)",
44
+ title: (e) => e.defaultValue ?? "—",
45
+ subtitle: (e) => e.namespace?.displayName
46
+ },
47
+ tone: (e) => o(e, a) ? void 0 : "bad",
48
+ columns: [{
49
+ id: "translation",
50
+ header: s,
51
+ width: "minmax(0,1.5fr)",
52
+ cell: (e) => {
53
+ let t = o(e, a);
54
+ return t ? /* @__PURE__ */ f("span", {
55
+ className: "text-sm text-text-primary",
56
+ lang: a,
57
+ dir: l ? "rtl" : void 0,
58
+ children: t.value
59
+ }) : /* @__PURE__ */ f("span", {
60
+ className: "text-sm text-text-secondary",
61
+ children: d("i18n.v3.word.notYet", "Not translated yet")
62
+ });
63
+ }
64
+ }, {
65
+ id: "status",
66
+ header: d("i18n.v3.col.status", "Status"),
67
+ width: "150px",
68
+ phone: "bare",
69
+ cell: (e) => o(e, a) ? /* @__PURE__ */ f(E, {
70
+ status: "ok",
71
+ children: d("i18n.v3.word.translated", "Translated")
72
+ }) : /* @__PURE__ */ f(E, {
73
+ status: "bad",
74
+ children: d("i18n.v3.word.missing", "Missing")
75
+ })
76
+ }],
77
+ actions: (n) => {
78
+ let r = o(n, a);
79
+ return r ? /* @__PURE__ */ f(m, {
80
+ placement: "row",
81
+ label: d("i18n.v3.word.actionsFor", "Actions for {{text}}", { text: n.defaultValue ?? "" }),
82
+ items: [{
83
+ id: "edit",
84
+ label: d("i18n.v3.word.edit", "Change the translation"),
85
+ icon: t,
86
+ onSelect: () => u({
87
+ word: n,
88
+ translation: {
89
+ id: r.id,
90
+ value: r.value
91
+ }
92
+ })
93
+ }]
94
+ }) : /* @__PURE__ */ p(h, {
95
+ size: "sm",
96
+ variant: "outline",
97
+ onClick: () => u({
98
+ word: n,
99
+ translation: null
100
+ }),
101
+ "aria-label": d("i18n.v3.word.translateThis", "Translate: {{text}}", { text: n.defaultValue ?? "" }),
102
+ children: [/* @__PURE__ */ f(e, { "aria-hidden": "true" }), d("i18n.v3.word.translate", "Translate")]
103
+ });
104
+ },
105
+ footer: i.hasMore ? /* @__PURE__ */ f(h, {
106
+ variant: "outline",
107
+ size: "sm",
108
+ onClick: i.showMore,
109
+ disabled: i.loadingMore,
110
+ "aria-busy": i.loadingMore || void 0,
111
+ children: d("i18n.v3.showMore", "Show more")
112
+ }) : void 0
113
+ });
114
+ }
115
+ function j({ products: t, productsLoading: o, languageCode: m, languageName: h, sourceName: g, rtl: x, onSaved: S }) {
116
+ let C = r(), w = D(), { productName: T } = O(), [E] = d(), j = a(t, E.get(i), T), [M, N] = u(""), P = s(M.trim(), 300), F = l(j?.id ?? null, P), [I, L] = u(null), R = async (e, t) => {
117
+ try {
118
+ let n = await F.save(e.word, m, t, e.translation?.id ?? null);
119
+ return w(n === "live" ? {
120
+ title: C("i18n.v3.word.saved", "Saved. It’s live now."),
121
+ tone: "success"
122
+ } : {
123
+ title: C("i18n.v3.word.savedDraft", "Saved as a draft."),
124
+ description: C("i18n.v3.word.savedDraftBody", "It shows here once someone approves it."),
125
+ tone: "info"
126
+ }), S(), !0;
127
+ } catch {
128
+ return w({
129
+ title: C("i18n.v3.word.saveFailed", "Couldn’t save it. Try again."),
130
+ tone: "error"
131
+ }), !1;
132
+ }
133
+ }, z = /* @__PURE__ */ f(A, {
134
+ words: F.words,
135
+ state: F,
136
+ languageCode: m,
137
+ languageName: h,
138
+ sourceName: g,
139
+ rtl: x,
140
+ onTranslate: L
141
+ });
142
+ return F.error && F.words.length === 0 ? z = /* @__PURE__ */ f(y, {
143
+ what: C("i18n.v3.word.list", "Words"),
144
+ error: F.error,
145
+ onRetry: F.retry
146
+ }) : !o && !j ? z = /* @__PURE__ */ f(_, {
147
+ icon: /* @__PURE__ */ f(e, { "aria-hidden": "true" }),
148
+ title: C("i18n.v3.noProducts", "No products yet"),
149
+ description: C("i18n.v3.noProductsBody", "A product’s words show here once they are ready to translate.")
150
+ }) : !F.loading && j && F.words.length === 0 && (z = /* @__PURE__ */ f(_, {
151
+ kind: P ? "no-results" : "first-use",
152
+ icon: /* @__PURE__ */ f(n, { "aria-hidden": "true" }),
153
+ title: P ? C("i18n.v3.word.noMatch", "No words match") : C("i18n.v3.word.none", "No words yet"),
154
+ description: P ? C("i18n.v3.word.noMatchBody", "Try other words, or another product.") : C("i18n.v3.word.noneBody", "{{product}} has no words to translate yet.", { product: j.displayName })
155
+ })), /* @__PURE__ */ p("div", {
156
+ className: "flex flex-col gap-3",
157
+ children: [
158
+ /* @__PURE__ */ f(b, {
159
+ tone: "info",
160
+ children: C("i18n.v3.word.liveOnly", "Shows words that are live. Words waiting for review appear after they’re approved.")
161
+ }),
162
+ /* @__PURE__ */ p("div", {
163
+ className: "flex flex-wrap items-center gap-2",
164
+ children: [/* @__PURE__ */ f(k, {
165
+ products: t,
166
+ current: j
167
+ }), /* @__PURE__ */ f(v, {
168
+ type: "search",
169
+ value: M,
170
+ onChange: (e) => N(e.target.value),
171
+ placeholder: C("i18n.v3.word.search", "Search words"),
172
+ "aria-label": C("i18n.v3.word.search", "Search words"),
173
+ className: "w-full sm:w-64",
174
+ "data-testid": "words-search"
175
+ })]
176
+ }),
177
+ z,
178
+ /* @__PURE__ */ f(c, {
179
+ target: I,
180
+ sourceName: g,
181
+ languageName: h,
182
+ languageCode: m,
183
+ rtl: x,
184
+ onSave: R,
185
+ onClose: () => L(null)
186
+ })
187
+ ]
188
+ });
189
+ }
190
+ export { j as WordsTab };
@@ -0,0 +1,23 @@
1
+ import { LanguageDirection, LanguageStatus, UpdateLanguageInput } from '../../../generated/global-types';
2
+ export interface LanguageDetail {
3
+ id: string;
4
+ code: string;
5
+ name: string;
6
+ nativeName: string;
7
+ direction: LanguageDirection;
8
+ status: LanguageStatus;
9
+ isDefault: boolean;
10
+ region: string | null;
11
+ dateFormat: string;
12
+ timeFormat: string;
13
+ }
14
+ export declare function useLanguage(code: string): {
15
+ language: LanguageDetail | null;
16
+ loading: boolean;
17
+ error: import('@apollo/client').ErrorLike | undefined;
18
+ /** Asked and answered: no language has this code. */
19
+ missing: boolean;
20
+ retry: () => undefined;
21
+ update: (input: UpdateLanguageInput) => Promise<void>;
22
+ };
23
+ export type LanguageState = ReturnType<typeof useLanguage>;
@@ -0,0 +1,22 @@
1
+ import { useGetI18nLanguageQuery as e, useUpdateI18nLanguageMutation as t } from "../../../generated/global-operations.js";
2
+ import { useCallback as n } from "react";
3
+ // src/i18n/v2/language/useLanguage.ts
4
+ function r(r) {
5
+ let i = e({ variables: { code: r } }), [a] = t(), o = i.data?.languageByCode ?? null, s = o?.id, c = n(async (e) => {
6
+ if (!s) return;
7
+ let t = await a({ variables: {
8
+ id: s,
9
+ input: e
10
+ } });
11
+ if (t.error) throw t.error;
12
+ }, [s, a]);
13
+ return {
14
+ language: o,
15
+ loading: i.loading && !o,
16
+ error: i.error,
17
+ missing: !i.loading && !i.error && !o,
18
+ retry: () => void i.refetch(),
19
+ update: c
20
+ };
21
+ }
22
+ export { r as useLanguage };
@@ -0,0 +1,31 @@
1
+ export interface Word {
2
+ id: string;
3
+ defaultValue: string | null;
4
+ description: string | null;
5
+ characterLimit: number | null;
6
+ namespace: {
7
+ id: string;
8
+ displayName: string;
9
+ } | null;
10
+ translations: Array<{
11
+ id: string;
12
+ languageCode: string;
13
+ value: string;
14
+ }>;
15
+ }
16
+ /** How many words a page shows; Show more adds as many again. */
17
+ export declare const WORDS_PAGE = 50;
18
+ /** What a save ended as. */
19
+ export type SaveOutcome = "live" | "draft";
20
+ export declare function useWords(productId: string | null, search: string): {
21
+ words: Word[];
22
+ total: any;
23
+ hasMore: any;
24
+ loading: boolean;
25
+ loadingMore: boolean;
26
+ error: import('@apollo/client').ErrorLike | undefined;
27
+ retry: () => undefined;
28
+ showMore: () => void;
29
+ save: (word: Word, languageCode: string, value: string, translationId: string | null) => Promise<SaveOutcome>;
30
+ };
31
+ export type WordsState = ReturnType<typeof useWords>;
@@ -0,0 +1,51 @@
1
+ import { useCreateI18nTranslationsMutation as e, useGetI18nWordsQuery as t, useUpdateI18nTranslationMutation as n } from "../../../generated/global-operations.js";
2
+ import { TranslationKeyStatus as r } from "../../../generated/global-types.js";
3
+ import { useCallback as i, useState as a } from "react";
4
+ function o(o, s) {
5
+ let [c, l] = a(50), u = t({
6
+ variables: {
7
+ filter: {
8
+ productId: o ?? "",
9
+ status: r.Active,
10
+ ...s ? { search: s } : {}
11
+ },
12
+ limit: c
13
+ },
14
+ skip: !o,
15
+ notifyOnNetworkStatusChange: !0
16
+ }), [d] = e(), [f] = n(), p = u.data?.translationKeys.items ?? [], { refetch: m } = u, h = i(async (e, t, n, r) => {
17
+ if (r) {
18
+ let e = await f({ variables: {
19
+ id: r,
20
+ input: { value: n }
21
+ } });
22
+ if (e.error) throw e.error;
23
+ return await m(), "live";
24
+ }
25
+ let i = await d({ variables: { translations: [{
26
+ keyId: e.id,
27
+ languageCode: t,
28
+ value: n
29
+ }] } });
30
+ if (i.error) throw i.error;
31
+ let a = i.data?.bulkCreateTranslations;
32
+ if (!a || a.successCount < 1) throw Error("The translation wasn't saved.");
33
+ return ((await m()).data?.translationKeys.items ?? []).find((t) => t.id === e.id)?.translations.some((e) => e.languageCode === t) === !1 ? "draft" : "live";
34
+ }, [
35
+ d,
36
+ m,
37
+ f
38
+ ]);
39
+ return {
40
+ words: p,
41
+ total: u.data?.translationKeys.total ?? 0,
42
+ hasMore: u.data?.translationKeys.hasMore ?? !1,
43
+ loading: !!o && u.loading && p.length === 0,
44
+ loadingMore: u.loading && p.length > 0,
45
+ error: u.error,
46
+ retry: () => void m(),
47
+ showMore: () => l((e) => e + 50),
48
+ save: h
49
+ };
50
+ }
51
+ export { o as useWords };
@@ -0,0 +1,61 @@
1
+ import { ProductRow } from './useLanguagesData';
2
+ /** The date formats offered, in the service's tokens (`YYYY-MM-DD` by default). */
3
+ export declare const DATE_FORMATS: readonly ["DD/MM/YYYY", "MM/DD/YYYY", "YYYY-MM-DD", "DD.MM.YYYY", "D MMM YYYY"];
4
+ /** The time formats offered. */
5
+ export declare const TIME_FORMATS: readonly ["HH:mm", "h:mm A", "H:mm"];
6
+ /**
7
+ * A format written out for the example day: `DD/MM/YYYY` is "26/11/2026".
8
+ * Each token is replaced once, through placeholders, so a written-out value is
9
+ * never read again as a token (the "M" in "Mar", the "A" in "Aug").
10
+ */
11
+ export declare function formatExample(format: string, date?: Date): string;
12
+ /** The formats offered, with the language's own first when it isn't one of them. */
13
+ export declare function formatOptions(offered: readonly string[], current: string | null | undefined): string[];
14
+ /** What a language code says about a new language: its names and direction. */
15
+ export interface CodeFacts {
16
+ /** The code as the service stores it: `pt-BR`, `zh-Hans`. */
17
+ code: string;
18
+ /** Its name in English: "Portuguese (Brazil)". */
19
+ name: string;
20
+ /** Its name in itself: "português (Brasil)". */
21
+ nativeName: string;
22
+ rtl: boolean;
23
+ }
24
+ /**
25
+ * The facts for a typed code, or null when it isn't a language code. Names
26
+ * come from the browser's `Intl.DisplayNames`; a code it doesn't know keeps
27
+ * the code as its name, to be written over.
28
+ */
29
+ export declare function factsForCode(typed: string): CodeFacts | null;
30
+ /** One word as the Words tab shows it, in one language. */
31
+ export interface WordRow {
32
+ id: string;
33
+ defaultValue: string | null;
34
+ translations: ReadonlyArray<{
35
+ id: string;
36
+ languageCode: string;
37
+ value: string;
38
+ }>;
39
+ }
40
+ /** The word's live translation in this language, if it has one. */
41
+ export declare function translationIn<T extends WordRow>(word: T, languageCode: string): T["translations"][number] | undefined;
42
+ /** The product whose words show (`?product=`). */
43
+ export declare const PRODUCT_PARAM = "product";
44
+ /**
45
+ * The product shown first: the one in the address, else the product this app
46
+ * is (by name), else the first.
47
+ */
48
+ export declare function pickProduct(products: readonly ProductRow[], wanted: string | null, appName: string | null | undefined): ProductRow | null;
49
+ export declare const LANGUAGE_TABS: readonly ["words", "review", "formats"];
50
+ export type LanguageTab = (typeof LANGUAGE_TABS)[number];
51
+ /** A language's tabs: Waiting for review only once the service can list it. */
52
+ export declare function shownLanguageTabs(reviewQueue: boolean): LanguageTab[];
53
+ /** `?tab=` on a language's page; anything else, or a hidden tab, is Words. */
54
+ export declare function readLanguageTab(value: string | null, reviewQueue: boolean): LanguageTab;
55
+ /** What's wrong with the code being added, if anything. */
56
+ export declare function codeProblem(typed: string, taken: boolean): "taken" | "badCode" | null;
57
+ /** The language dialog can save: names given, and a good code when adding. */
58
+ export declare function canSaveLanguage(fields: {
59
+ name: string;
60
+ nativeName: string;
61
+ }, facts: CodeFacts | null, adding: boolean): boolean;
@@ -0,0 +1,120 @@
1
+ // src/i18n/v2/languageModel.ts
2
+ var e = [
3
+ "DD/MM/YYYY",
4
+ "MM/DD/YYYY",
5
+ "YYYY-MM-DD",
6
+ "DD.MM.YYYY",
7
+ "D MMM YYYY"
8
+ ], t = [
9
+ "HH:mm",
10
+ "h:mm A",
11
+ "H:mm"
12
+ ], n = new Date(2026, 10, 26, 9, 5), r = [
13
+ "Jan",
14
+ "Feb",
15
+ "Mar",
16
+ "Apr",
17
+ "May",
18
+ "Jun",
19
+ "Jul",
20
+ "Aug",
21
+ "Sep",
22
+ "Oct",
23
+ "Nov",
24
+ "Dec"
25
+ ], i = (e) => String(e).padStart(2, "0"), a = [
26
+ [/YYYY/g, (e) => String(e.getFullYear())],
27
+ [/MMM/g, (e) => r[e.getMonth()] ?? ""],
28
+ [/MM/g, (e) => i(e.getMonth() + 1)],
29
+ [/DD/g, (e) => i(e.getDate())],
30
+ [/D/g, (e) => String(e.getDate())],
31
+ [/HH/g, (e) => i(e.getHours())],
32
+ [/H/g, (e) => String(e.getHours())],
33
+ [/hh/g, (e) => i(e.getHours() % 12 || 12)],
34
+ [/h/g, (e) => String(e.getHours() % 12 || 12)],
35
+ [/mm/g, (e) => i(e.getMinutes())],
36
+ [/A/g, (e) => e.getHours() < 12 ? "AM" : "PM"]
37
+ ];
38
+ function o(e, t = n) {
39
+ let r = [], i = e;
40
+ for (let [e, n] of a) i = i.replace(e, () => (r.push(n(t)), `\uE000${r.length - 1}\uE000`));
41
+ return i.replace(/\uE000(\d+)\uE000/g, (e, t) => r[Number(t)] ?? "");
42
+ }
43
+ function s(e, t) {
44
+ return t && !e.includes(t) ? [t, ...e] : [...e];
45
+ }
46
+ var c = /* @__PURE__ */ new Set([
47
+ "ar",
48
+ "arc",
49
+ "ckb",
50
+ "dv",
51
+ "fa",
52
+ "he",
53
+ "ku",
54
+ "ps",
55
+ "sd",
56
+ "ug",
57
+ "ur",
58
+ "yi"
59
+ ]);
60
+ function l(e) {
61
+ let t = e, n = t.getTextInfo?.().direction ?? t.textInfo?.direction;
62
+ return n ? n === "rtl" : c.has(e.language);
63
+ }
64
+ var u = new Intl.DisplayNames(["en"], { type: "language" }), d = /* @__PURE__ */ new Map();
65
+ function f(e) {
66
+ if (!d.has(e)) {
67
+ let t = null;
68
+ try {
69
+ t = new Intl.DisplayNames([e], { type: "language" });
70
+ } catch {}
71
+ d.set(e, t);
72
+ }
73
+ return d.get(e) ?? null;
74
+ }
75
+ function p(e) {
76
+ let t = e.trim();
77
+ if (!/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(t)) return null;
78
+ let n;
79
+ try {
80
+ n = Intl.getCanonicalLocales(t)[0] ?? "";
81
+ } catch {
82
+ return null;
83
+ }
84
+ if (!n) return null;
85
+ let r = u.of(n) ?? n;
86
+ return {
87
+ code: n,
88
+ name: r,
89
+ nativeName: f(n)?.of(n) ?? r,
90
+ rtl: l(new Intl.Locale(n))
91
+ };
92
+ }
93
+ function m(e, t) {
94
+ return e.translations.find((e) => e.languageCode === t);
95
+ }
96
+ var h = "product";
97
+ function g(e, t, n) {
98
+ let r = e.find((e) => e.id === t);
99
+ if (r) return r;
100
+ let i = n?.trim().toLowerCase();
101
+ return (i ? e.find((e) => e.displayName.toLowerCase() === i) : void 0) ?? e[0] ?? null;
102
+ }
103
+ var _ = [
104
+ "words",
105
+ "review",
106
+ "formats"
107
+ ];
108
+ function v(e) {
109
+ return _.filter((t) => e || t !== "review");
110
+ }
111
+ function y(e, t) {
112
+ return v(t).find((t) => t === e) ?? "words";
113
+ }
114
+ function b(e, t) {
115
+ return t ? "taken" : e.trim() !== "" && p(e) === null ? "badCode" : null;
116
+ }
117
+ function x(e, t, n) {
118
+ return e.name.trim() !== "" && e.nativeName.trim() !== "" && (!n || t !== null);
119
+ }
120
+ export { e as DATE_FORMATS, _ as LANGUAGE_TABS, h as PRODUCT_PARAM, t as TIME_FORMATS, x as canSaveLanguage, b as codeProblem, p as factsForCode, o as formatExample, s as formatOptions, g as pickProduct, y as readLanguageTab, v as shownLanguageTabs, m as translationIn };
@@ -1,11 +1,14 @@
1
1
  import { LanguagesTab } from './model';
2
+ /** `?dialog=` opening Add language over the Languages page. */
3
+ export declare const ADD_LANGUAGE_DIALOG = "addlanguage";
2
4
  export declare function languagesLinks(basePath: string): {
3
5
  page: string;
4
6
  tab: (tab: LanguagesTab) => string;
5
7
  /** The review queue, showing one language. */
6
8
  review: (languageCode: string) => string;
7
- /** One language: today's language settings until C5b. */
9
+ /** One language's own page. */
8
10
  language: (code: string) => string;
11
+ /** Languages with Add language open over it. */
9
12
  addLanguage: string;
10
13
  importWords: string;
11
14
  exportWords: string;
@@ -1,16 +1,17 @@
1
1
  import { joinPath as e } from "../utils/paths.js";
2
2
  import { LANGUAGE_PARAM as t } from "./model.js";
3
3
  // src/i18n/v2/links.ts
4
- function n(n) {
5
- let r = e(n, "languages");
4
+ var n = "addlanguage";
5
+ function r(r) {
6
+ let i = e(r, "languages");
6
7
  return {
7
- page: r,
8
- tab: (e) => e === "languages" ? r : `${r}?tab=${e}`,
9
- review: (e) => `${r}?tab=review&${t}=${encodeURIComponent(e)}`,
10
- language: (t) => e(n, `languages/${encodeURIComponent(t)}`),
11
- addLanguage: e(n, "languages/new"),
12
- importWords: e(n, "import"),
13
- exportWords: e(n, "export")
8
+ page: i,
9
+ tab: (e) => e === "languages" ? i : `${i}?tab=${e}`,
10
+ review: (e) => `${i}?tab=review&${t}=${encodeURIComponent(e)}`,
11
+ language: (t) => e(r, `languages/${encodeURIComponent(t)}`),
12
+ addLanguage: `${i}?dialog=${n}`,
13
+ importWords: e(r, "import"),
14
+ exportWords: e(r, "export")
14
15
  };
15
16
  }
16
- export { n as languagesLinks };
17
+ export { n as ADD_LANGUAGE_DIALOG, r as languagesLinks };
@@ -6,8 +6,18 @@
6
6
  */
7
7
  export declare const LANGUAGES_TABS: readonly ["languages", "products", "review"];
8
8
  export type LanguagesTab = (typeof LANGUAGES_TABS)[number];
9
- /** `?tab=`; anything else is the Languages tab. */
10
- export declare function readLanguagesTab(value: string | null): LanguagesTab;
9
+ /**
10
+ * Whether the service can list translations waiting for review. Today
11
+ * `translations` returns only live ones, whatever status is asked for, so the
12
+ * review queue would show live words as waiting (BOFF-16785's backend list).
13
+ * Until it can, the queue, its tab and its links stay hidden; the waiting
14
+ * counts (from `translationCoverage`) still show, as plain text.
15
+ */
16
+ export declare const REVIEW_QUEUE_LISTS = false;
17
+ /** The tabs shown: the review queue only once the service can list it. */
18
+ export declare function shownTabs(reviewQueue: boolean): LanguagesTab[];
19
+ /** `?tab=`; anything else, or a hidden tab, is the Languages tab. */
20
+ export declare function readLanguagesTab(value: string | null, reviewQueue?: boolean): LanguagesTab;
11
21
  /** The review queue's language filter (`?language=`). */
12
22
  export declare const LANGUAGE_PARAM = "language";
13
23
  /** One language's line of `translationCoverage` for one product. */
@@ -5,25 +5,28 @@ var e = [
5
5
  "review"
6
6
  ];
7
7
  function t(t) {
8
- return e.find((e) => e === t) ?? "languages";
8
+ return e.filter((e) => t || e !== "review");
9
9
  }
10
- var n = "language", r = {
10
+ function n(e, n = !1) {
11
+ return t(n).find((t) => t === e) ?? "languages";
12
+ }
13
+ var r = "language", i = {
11
14
  translated: 0,
12
15
  total: 0,
13
16
  waiting: 0,
14
17
  missing: 0,
15
18
  share: null
16
19
  };
17
- function i(e) {
20
+ function a(e) {
18
21
  return {
19
22
  ...e,
20
23
  share: e.total > 0 ? e.translated / e.total : null
21
24
  };
22
25
  }
23
- function a(e) {
26
+ function o(e) {
24
27
  let t = /* @__PURE__ */ new Map();
25
28
  for (let n of e.values()) for (let e of n) {
26
- let n = t.get(e.languageCode) ?? { ...r };
29
+ let n = t.get(e.languageCode) ?? { ...i };
27
30
  t.set(e.languageCode, {
28
31
  translated: n.translated + e.translatedKeys,
29
32
  total: n.total + e.totalKeys,
@@ -32,28 +35,28 @@ function a(e) {
32
35
  });
33
36
  }
34
37
  let n = /* @__PURE__ */ new Map();
35
- for (let [e, r] of t) n.set(e, i(r));
38
+ for (let [e, r] of t) n.set(e, a(r));
36
39
  return n;
37
40
  }
38
- function o(e, t) {
39
- let n = e.reduce((e, t) => Math.max(e, t.totalKeys), 0), a = e.filter((e) => e.languageCode !== t);
41
+ function s(e, t) {
42
+ let n = e.reduce((e, t) => Math.max(e, t.totalKeys), 0), r = e.filter((e) => e.languageCode !== t);
40
43
  return {
41
- ...i((a.length > 0 ? a : e).reduce((e, t) => ({
44
+ ...a((r.length > 0 ? r : e).reduce((e, t) => ({
42
45
  translated: e.translated + t.translatedKeys,
43
46
  total: e.total + t.totalKeys,
44
47
  waiting: e.waiting + t.pendingReviewKeys,
45
48
  missing: e.missing + t.missingCount
46
- }), { ...r })),
49
+ }), { ...i })),
47
50
  texts: n
48
51
  };
49
52
  }
50
- function s(e) {
53
+ function c(e) {
51
54
  return e.namespace?.displayName || e.product.displayName;
52
55
  }
53
- function c(e) {
56
+ function l(e) {
54
57
  return [...e].sort((e, t) => e.isDefault === t.isDefault ? e.name.localeCompare(t.name) : e.isDefault ? -1 : 1);
55
58
  }
56
- async function l(e, t, n) {
59
+ async function u(e, t, n) {
57
60
  let r = Array(e.length), i = 0;
58
61
  await Promise.all(Array.from({ length: Math.max(1, Math.min(t, e.length)) }, async () => {
59
62
  for (; i < e.length;) {
@@ -84,4 +87,4 @@ async function l(e, t, n) {
84
87
  failed: o
85
88
  };
86
89
  }
87
- export { e as LANGUAGES_TABS, n as LANGUAGE_PARAM, l as eachLimited, a as languageProgress, o as productProgress, t as readLanguagesTab, c as sortLanguages, s as whereItAppears };
90
+ export { e as LANGUAGES_TABS, r as LANGUAGE_PARAM, u as eachLimited, o as languageProgress, s as productProgress, n as readLanguagesTab, t as shownTabs, l as sortLanguages, c as whereItAppears };
@@ -3,7 +3,7 @@ import { ApproveOutcome } from './useReviewQueue';
3
3
  export type Tr = (key: string, fallback: string, params?: Record<string, string | number>) => string;
4
4
  /** After one Approve. */
5
5
  export declare function approvedMessage(tr: Tr, outcome: ApproveOutcome): NotifyOptions;
6
- /** After Approve all shown: how many were approved, and what went wrong. */
6
+ /** After approving every row shown: how many were approved, and what went wrong. */
7
7
  export declare function approvedManyMessage(tr: Tr, outcomes: readonly ApproveOutcome[], failed: number): NotifyOptions;
8
8
  /** After Put them live. */
9
9
  export declare function liveMessage(tr: Tr, done: number, failed: number): NotifyOptions;
@@ -0,0 +1,10 @@
1
+ import { LanguageFields } from './LanguageDialog';
2
+ /** The service said a language with this code is there already. */
3
+ export declare function isTaken(error: unknown): boolean;
4
+ export type AddOutcome = {
5
+ outcome: "saved";
6
+ code: string;
7
+ } | {
8
+ outcome: "taken" | "failed";
9
+ };
10
+ export declare function useAddLanguage(): (fields: LanguageFields) => Promise<AddOutcome>;