create-expo-updates-server 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/template/Dockerfile +4 -6
- package/dist/template/README.md +5 -10
- package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
- package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
- package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
- package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
- package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
- package/dist/template/app/api/admin/updates/route.test.ts +21 -0
- package/dist/template/app/api/admin/updates/route.ts +12 -1
- package/dist/template/app/globals.css +65 -68
- package/dist/template/app/login/page.tsx +66 -42
- package/dist/template/app/updates/[encodedKey]/page.tsx +382 -248
- package/dist/template/app/updates/devices/page.tsx +187 -145
- package/dist/template/app/updates/embedded/page.tsx +80 -34
- package/dist/template/app/updates/emergency-redirects/page.tsx +138 -71
- package/dist/template/app/updates/layout.tsx +2 -1
- package/dist/template/app/updates/page.tsx +385 -274
- package/dist/template/app/updates/releases.test.tsx +156 -0
- package/dist/template/components/admin/admin-role.ts +5 -0
- package/dist/template/components/admin/admin-shell.tsx +166 -95
- package/dist/template/components/admin/confirm-action.tsx +123 -0
- package/dist/template/components/admin/language-switcher.tsx +27 -16
- package/dist/template/components/admin/release-badges.test.tsx +50 -0
- package/dist/template/components/admin/release-badges.tsx +101 -0
- package/dist/template/components/ui/alert.tsx +10 -3
- package/dist/template/components/ui/avatar.tsx +108 -0
- package/dist/template/components/ui/badge.tsx +2 -2
- package/dist/template/components/ui/breadcrumb.tsx +108 -0
- package/dist/template/components/ui/button.tsx +5 -5
- package/dist/template/components/ui/card.tsx +2 -2
- package/dist/template/components/ui/chart.tsx +1 -1
- package/dist/template/components/ui/collapsible.tsx +7 -0
- package/dist/template/components/ui/dialog.tsx +13 -4
- package/dist/template/components/ui/empty.tsx +103 -0
- package/dist/template/components/ui/field.tsx +248 -0
- package/dist/template/components/ui/input-group.tsx +170 -0
- package/dist/template/components/ui/input.tsx +1 -1
- package/dist/template/components/ui/native-select.tsx +1 -1
- package/dist/template/components/ui/radio-group.tsx +41 -0
- package/dist/template/components/ui/sheet.tsx +6 -2
- package/dist/template/components/ui/sidebar.tsx +62 -17
- package/dist/template/components/ui/status-tones.ts +15 -0
- package/dist/template/components/ui/table.tsx +1 -1
- package/dist/template/components/ui/textarea.tsx +1 -1
- package/dist/template/docs/admin-ui.md +22 -24
- package/dist/template/docs/device-targeting.md +6 -12
- package/dist/template/docs/doctor.md +2 -2
- package/dist/template/docs/expo-app-setup.md +9 -27
- package/dist/template/docs/getting-started.md +3 -4
- package/dist/template/docs/getting-started.ru.md +11 -544
- package/dist/template/docs/index.md +1 -1
- package/dist/template/docs/installation-telemetry.md +6 -12
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
- package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
- package/dist/template/docs/migrations/schema.sql +349 -0
- package/dist/template/docs/npm-installer.md +3 -3
- package/dist/template/docs/operations-guide.md +9 -7
- package/dist/template/docs/ota-client-lifecycle.md +30 -68
- package/dist/template/docs/ota-emergency-recovery.md +34 -57
- package/dist/template/docs/ota-update-policy.md +9 -20
- package/dist/template/docs/ru/admin-ui.md +33 -0
- package/dist/template/docs/ru/device-targeting.md +59 -0
- package/dist/template/docs/ru/doctor.md +98 -0
- package/dist/template/docs/ru/expo-app-setup.md +497 -0
- package/dist/template/docs/ru/getting-started.md +391 -0
- package/dist/template/docs/ru/index.md +50 -0
- package/dist/template/docs/ru/installation-telemetry.md +125 -0
- package/dist/template/docs/ru/npm-installer.md +71 -0
- package/dist/template/docs/ru/operations-guide.md +322 -0
- package/dist/template/docs/ru/ota-client-lifecycle.md +162 -0
- package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/ru/ota-update-policy.md +69 -0
- package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
- package/dist/template/docs/ru/supabase-setup.md +120 -0
- package/dist/template/docs/uk/admin-ui.md +33 -0
- package/dist/template/docs/uk/device-targeting.md +59 -0
- package/dist/template/docs/uk/doctor.md +98 -0
- package/dist/template/docs/uk/expo-app-setup.md +497 -0
- package/dist/template/docs/uk/getting-started.md +391 -0
- package/dist/template/docs/uk/index.md +50 -0
- package/dist/template/docs/uk/installation-telemetry.md +125 -0
- package/dist/template/docs/uk/npm-installer.md +71 -0
- package/dist/template/docs/uk/operations-guide.md +322 -0
- package/dist/template/docs/uk/ota-client-lifecycle.md +162 -0
- package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/uk/ota-update-policy.md +69 -0
- package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
- package/dist/template/docs/uk/supabase-setup.md +120 -0
- package/dist/template/lib/audience-ids.ts +4 -0
- package/dist/template/package-lock.json +46 -0
- package/dist/template/package.json +4 -1
- package/dist/template/scripts/configure-expo-app.mjs +3 -3
- package/dist/template/scripts/create-access-token.mjs +1 -1
- package/dist/template/scripts/lib/doctor.mjs +10 -7
- package/dist/template/scripts/lib/doctor.test.mjs +7 -5
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
- package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
- package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
- package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
- package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
- package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
- package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
- package/dist/template/scripts/tests/e2e/console.mjs +86 -0
- package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
- package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
- package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
- package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
- package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
- package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
- package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
- package/dist/template/scripts/tests/e2e/run.mjs +224 -0
- package/dist/template/scripts/tests/manifest-identity.sql +7 -5
- package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
- package/dist/template/src/client/admin-api.ts +45 -10
- package/dist/template/src/client/admin-types.ts +35 -1
- package/dist/template/src/client/devices/analytics.tsx +169 -219
- package/dist/template/src/client/devices/cohorts.tsx +181 -0
- package/dist/template/src/client/devices/device-name.tsx +37 -21
- package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
- package/dist/template/src/client/devices/registry.tsx +265 -233
- package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
- package/dist/template/src/client/devices/use-devices-report.ts +53 -82
- package/dist/template/src/client/devices/version-adoption-chart.tsx +48 -38
- package/dist/template/src/client/distribution-control.tsx +98 -53
- package/dist/template/src/client/distribution-history.tsx +353 -0
- package/dist/template/src/client/guard-action-catalog.tsx +183 -0
- package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
- package/dist/template/src/client/guard-action-combobox.tsx +134 -234
- package/dist/template/src/client/guard-action-options.ts +4 -6
- package/dist/template/src/client/i18n/en.json +335 -2
- package/dist/template/src/client/i18n/language-switching.test.tsx +233 -0
- package/dist/template/src/client/i18n/messages.test.ts +102 -19
- package/dist/template/src/client/i18n/messages.ts +31 -16
- package/dist/template/src/client/i18n/provider.tsx +6 -3
- package/dist/template/src/client/i18n/ru.json +619 -0
- package/dist/template/src/client/i18n/uk.json +619 -0
- package/dist/template/src/client/i18n/use-formatters.ts +5 -0
- package/dist/template/src/client/logout-button.tsx +3 -3
- package/dist/template/src/client/policy-draft.ts +138 -0
- package/dist/template/src/client/update-audience-editor.tsx +597 -199
- package/dist/template/src/client/update-policy-editor.test.ts +101 -29
- package/dist/template/src/client/update-policy-editor.tsx +466 -307
- package/dist/template/src/client/use-filtered-results.ts +55 -0
- package/dist/template/src/server/controllers/manifest.test.ts +23 -3
- package/dist/template/src/server/controllers/manifest.ts +15 -1
- package/dist/template/src/server/devices/audience.ts +9 -5
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
- package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
- package/dist/template/src/server/lib/admin-updates.ts +160 -534
- package/dist/template/src/server/lib/distribution-history.ts +97 -0
- package/dist/template/src/server/lib/supabase.js +24 -0
- package/dist/template/src/server/lib/supabase.test.ts +38 -1
- package/dist/template/src/server/lib/update-policy.test.ts +20 -0
- package/dist/template/src/server/lib/update-policy.ts +23 -10
- package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
- package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
- package/dist/template/src/server/manifest/manifest-values.ts +21 -13
- package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
- package/dist/template/tsconfig.json +2 -2
- package/dist/template-manifest.json +571 -271
- package/package.json +1 -1
- package/dist/template/scripts/lib/device-identity.test.ts +0 -29
- package/dist/template/scripts/lib/ota-client.test.ts +0 -55
- package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
- package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
- package/dist/template/templates/expo-app/ota-client/README.md +0 -73
- package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
- package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
- package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
- package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
|
@@ -1,40 +1,123 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import ts from "typescript";
|
|
1
4
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createTranslator, resolveLocale } from "./messages";
|
|
5
|
+
import { createTranslator, resolveLocale, type Locale } from "./messages";
|
|
3
6
|
import english from "./en.json";
|
|
7
|
+
import russian from "./ru.json";
|
|
8
|
+
import ukrainian from "./uk.json";
|
|
9
|
+
|
|
10
|
+
const catalogs = { en: english, ru: russian, uk: ukrainian };
|
|
4
11
|
|
|
5
12
|
describe("admin interface language", () => {
|
|
6
|
-
it("
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
it("resolves supported preferences and keeps English as the default", () => {
|
|
14
|
+
for (const locale of ["en", "ru", "uk"]) {
|
|
15
|
+
expect(resolveLocale(locale)).toBe(locale);
|
|
16
|
+
}
|
|
17
|
+
for (const locale of [undefined, "ua", "de", "constructor"]) {
|
|
18
|
+
expect(resolveLocale(locale)).toBe("en");
|
|
19
|
+
}
|
|
11
20
|
});
|
|
12
|
-
|
|
21
|
+
|
|
22
|
+
it("translates labels and English API errors without translating user data", () => {
|
|
13
23
|
expect(createTranslator("en")("Установки")).toBe("Installations");
|
|
14
24
|
expect(createTranslator("ru")("Установки")).toBe("Установки");
|
|
25
|
+
expect(createTranslator("uk")("Установки")).toBe("Встановлення");
|
|
15
26
|
expect(createTranslator("ru")("Invalid credentials")).toBe(
|
|
16
27
|
"Неверные учётные данные",
|
|
17
28
|
);
|
|
29
|
+
expect(createTranslator("uk")("Invalid credentials")).toBe(
|
|
30
|
+
"Неправильні облікові дані",
|
|
31
|
+
);
|
|
32
|
+
expect(
|
|
33
|
+
createTranslator("uk")("fromChannel and toChannel must differ"),
|
|
34
|
+
).toBe("Початковий і цільовий канали мають відрізнятися");
|
|
18
35
|
expect(
|
|
19
|
-
createTranslator("
|
|
20
|
-
).toBe("
|
|
36
|
+
createTranslator("uk")("Канал {0}, {1}", ["Мой канал", "android"]),
|
|
37
|
+
).toBe("Канал Мой канал, android");
|
|
21
38
|
expect(createTranslator("en")("Скопировать {0}", ["$& <script>"])).toBe(
|
|
22
39
|
"Copy $& <script>",
|
|
23
40
|
);
|
|
24
41
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
|
|
43
|
+
it("can render an existing notification in another language", () => {
|
|
44
|
+
const notice = { key: "Policy saved as version {0}.", values: [3] };
|
|
45
|
+
expect(createTranslator("en")(notice)).toBe(
|
|
46
|
+
"Policy saved as version 3.",
|
|
47
|
+
);
|
|
48
|
+
expect(createTranslator("ru")(notice)).toBe(
|
|
49
|
+
"Политика сохранена как версия 3.",
|
|
50
|
+
);
|
|
51
|
+
expect(createTranslator("uk")(notice)).toBe(
|
|
52
|
+
"Політику збережено як версію 3.",
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it.each(Object.keys(catalogs) as Locale[])(
|
|
57
|
+
"keeps %s complete with matching interpolation slots",
|
|
58
|
+
(locale) => {
|
|
59
|
+
const slots = (s: string) =>
|
|
60
|
+
[...s.matchAll(/\{\d+\}/g)].map(([value]) => value).sort();
|
|
61
|
+
expect(Object.keys(catalogs[locale]).sort()).toEqual(
|
|
62
|
+
Object.keys(english).sort(),
|
|
63
|
+
);
|
|
64
|
+
for (const [source, translated] of Object.entries(catalogs[locale])) {
|
|
65
|
+
expect(translated.trim(), source).not.toBe("");
|
|
66
|
+
expect(slots(translated), source).toEqual(slots(source));
|
|
67
|
+
if (locale === "en")
|
|
68
|
+
expect(translated, source).not.toMatch(/[А-Яа-яЁёІіЇїЄєҐґ]/);
|
|
69
|
+
if (locale === "uk")
|
|
70
|
+
expect(translated, source).not.toMatch(/[ыэъёЫЭЪЁ]/);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
it("has translations for every literal UI translation key", () => {
|
|
76
|
+
function files(directory: string): string[] {
|
|
77
|
+
return readdirSync(directory, { withFileTypes: true }).flatMap(
|
|
78
|
+
(entry) => {
|
|
79
|
+
const path = join(directory, entry.name);
|
|
80
|
+
return entry.isDirectory()
|
|
81
|
+
? files(path)
|
|
82
|
+
: /\.tsx?$/.test(path) && !path.includes(".test.")
|
|
83
|
+
? [path]
|
|
84
|
+
: [];
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const keys = new Set([
|
|
89
|
+
...Object.keys(english),
|
|
90
|
+
...Object.values(english),
|
|
91
|
+
]);
|
|
92
|
+
for (const path of ["app", "components", "src/client"].flatMap(files)) {
|
|
93
|
+
const source = ts.createSourceFile(
|
|
94
|
+
path,
|
|
95
|
+
readFileSync(path, "utf8"),
|
|
96
|
+
ts.ScriptTarget.Latest,
|
|
97
|
+
true,
|
|
98
|
+
);
|
|
99
|
+
function visit(node: ts.Node) {
|
|
100
|
+
if (
|
|
101
|
+
ts.isCallExpression(node) &&
|
|
102
|
+
node.expression.getText(source) === "t"
|
|
103
|
+
) {
|
|
104
|
+
const key = node.arguments[0];
|
|
105
|
+
if (key && ts.isStringLiteral(key))
|
|
106
|
+
expect(keys.has(key.text), `${path}: ${key.text}`).toBe(true);
|
|
107
|
+
}
|
|
108
|
+
ts.forEachChild(node, visit);
|
|
109
|
+
}
|
|
110
|
+
visit(source);
|
|
32
111
|
}
|
|
33
112
|
});
|
|
113
|
+
|
|
34
114
|
it("preserves unknown technical errors and incomplete placeholders", () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
115
|
+
for (const locale of Object.keys(catalogs) as Locale[]) {
|
|
116
|
+
const t = createTranslator(locale);
|
|
117
|
+
expect(t("HTTP 503")).toBe("HTTP 503");
|
|
118
|
+
expect(t("constructor")).toBe("constructor");
|
|
119
|
+
expect(t("toString")).toBe("toString");
|
|
120
|
+
}
|
|
38
121
|
expect(createTranslator("en")("Канал {0}, {1}", ["preview"])).toBe(
|
|
39
122
|
"Channel preview, {1}",
|
|
40
123
|
);
|
|
@@ -1,31 +1,46 @@
|
|
|
1
1
|
import english from "./en.json";
|
|
2
|
+
import russian from "./ru.json";
|
|
3
|
+
import ukrainian from "./uk.json";
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
Object.entries(
|
|
5
|
+
const catalogs = {
|
|
6
|
+
en: new Map(Object.entries(english)),
|
|
7
|
+
ru: new Map(Object.entries(russian)),
|
|
8
|
+
uk: new Map(Object.entries(ukrainian)),
|
|
9
|
+
};
|
|
10
|
+
// Also accept English API errors and labels from the original interface.
|
|
11
|
+
const keysByEnglish = new Map(
|
|
12
|
+
Object.entries(english).map(([key, translated]) => [translated, key]),
|
|
6
13
|
);
|
|
7
14
|
|
|
8
|
-
export type Locale = "en" | "ru";
|
|
15
|
+
export type Locale = "en" | "ru" | "uk";
|
|
16
|
+
export const formatLocales: Record<Locale, string> = {
|
|
17
|
+
en: "en-US",
|
|
18
|
+
ru: "ru-RU",
|
|
19
|
+
uk: "uk-UA",
|
|
20
|
+
};
|
|
21
|
+
type TranslationValues = readonly (string | number | null | undefined)[];
|
|
22
|
+
export type TranslationMessage =
|
|
23
|
+
string | { key: string; values?: TranslationValues };
|
|
9
24
|
export const LOCALE_COOKIE = "ota-locale";
|
|
10
25
|
export const defaultLocale: Locale = "en";
|
|
11
26
|
export function resolveLocale(value: string | undefined): Locale {
|
|
12
|
-
return value === "ru"
|
|
27
|
+
return value === "ru" || value === "uk" ? value : defaultLocale;
|
|
13
28
|
}
|
|
14
29
|
|
|
15
|
-
/**
|
|
30
|
+
/** Translate at render time so existing notices follow language changes too. */
|
|
16
31
|
export function createTranslator(locale: Locale) {
|
|
17
|
-
return (
|
|
18
|
-
message:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
return (message: TranslationMessage, values: TranslationValues = []) => {
|
|
33
|
+
const source = typeof message === "string" ? message : message.key;
|
|
34
|
+
const replacements =
|
|
35
|
+
typeof message === "string" ? values : (message.values ?? []);
|
|
36
|
+
const key = catalogs.en.has(source)
|
|
37
|
+
? source
|
|
38
|
+
: (keysByEnglish.get(source) ?? source);
|
|
39
|
+
const translated = catalogs[locale].get(key) ?? source;
|
|
25
40
|
return translated.replace(/\{(\d+)\}/g, (placeholder, index) =>
|
|
26
|
-
|
|
41
|
+
replacements[Number(index)] === undefined
|
|
27
42
|
? placeholder
|
|
28
|
-
: String(
|
|
43
|
+
: String(replacements[Number(index)]),
|
|
29
44
|
);
|
|
30
45
|
};
|
|
31
46
|
}
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
createTranslator,
|
|
12
12
|
defaultLocale,
|
|
13
|
+
formatLocales,
|
|
13
14
|
LOCALE_COOKIE,
|
|
14
15
|
type Locale,
|
|
15
16
|
} from "./messages";
|
|
16
17
|
|
|
17
18
|
const defaultValue = {
|
|
18
19
|
locale: defaultLocale,
|
|
19
|
-
formatLocale:
|
|
20
|
+
formatLocale: formatLocales[defaultLocale],
|
|
20
21
|
t: createTranslator(defaultLocale),
|
|
21
22
|
setLocale: (_locale: Locale) => {
|
|
22
23
|
void _locale;
|
|
@@ -35,7 +36,7 @@ export function LocaleProvider({
|
|
|
35
36
|
const value = useMemo(
|
|
36
37
|
() => ({
|
|
37
38
|
locale,
|
|
38
|
-
formatLocale: locale
|
|
39
|
+
formatLocale: formatLocales[locale],
|
|
39
40
|
t: createTranslator(locale),
|
|
40
41
|
setLocale(next: Locale) {
|
|
41
42
|
document.cookie = `${LOCALE_COOKIE}=${next}; Path=/; Max-Age=31536000; SameSite=Lax`;
|
|
@@ -46,7 +47,9 @@ export function LocaleProvider({
|
|
|
46
47
|
[locale],
|
|
47
48
|
);
|
|
48
49
|
return (
|
|
49
|
-
<LocaleContext.Provider value={value}>
|
|
50
|
+
<LocaleContext.Provider value={value}>
|
|
51
|
+
{children}
|
|
52
|
+
</LocaleContext.Provider>
|
|
50
53
|
);
|
|
51
54
|
}
|
|
52
55
|
|