|
1 | 1 | import React from "react" |
2 | | -import i18next from "i18next" |
3 | | -import { I18nextProvider, initReactI18next } from "react-i18next" |
| 2 | +import { I18nextProvider } from "react-i18next" |
4 | 3 |
|
5 | 4 | import { TranslationContext } from "@src/i18n/TranslationContext" |
6 | 5 | import TelemetryBanner from "../TelemetryBanner" |
7 | | - |
8 | | -const translations: Record<string, string> = { |
9 | | - "welcome:telemetry.helpImprove": "Help Improve Zoo Code", |
10 | | - "welcome:telemetry.helpImproveMessage": |
11 | | - "Zoo Code collects error and usage data, linked to a per-install identifier, to help us fix bugs and improve the extension. This telemetry does not collect your code or prompts. You can turn this off in <settingsLink>settings</settingsLink>.", |
12 | | - "welcome:telemetry.accept": "Accept", |
13 | | - "welcome:telemetry.decline": "Decline", |
14 | | -} |
15 | | - |
16 | | -// Trans reads from its own react-i18next instance rather than the useAppTranslation |
17 | | -// context, so it needs a real (if minimal) i18next init to resolve helpImproveMessage |
18 | | -// and the settingsLink interpolation instead of rendering nothing. |
19 | | -const visualTestI18n = i18next.createInstance() |
20 | | -void visualTestI18n.use(initReactI18next).init({ |
21 | | - lng: "en", |
22 | | - fallbackLng: "en", |
23 | | - ns: ["welcome"], |
24 | | - defaultNS: "welcome", |
25 | | - resources: { |
26 | | - en: { |
27 | | - welcome: { |
28 | | - telemetry: { |
29 | | - helpImprove: translations["welcome:telemetry.helpImprove"], |
30 | | - helpImproveMessage: translations["welcome:telemetry.helpImproveMessage"], |
31 | | - accept: translations["welcome:telemetry.accept"], |
32 | | - decline: translations["welcome:telemetry.decline"], |
33 | | - }, |
34 | | - }, |
35 | | - }, |
36 | | - }, |
37 | | - interpolation: { escapeValue: false }, |
38 | | -}) |
| 6 | +import { visualTestI18n, visualTestTranslations } from "./TelemetryBanner.visual.i18n" |
39 | 7 |
|
40 | 8 | export const TelemetryBannerFixture = () => ( |
41 | 9 | <I18nextProvider i18n={visualTestI18n}> |
42 | 10 | <TranslationContext.Provider |
43 | 11 | value={{ |
44 | | - t: (key) => translations[key] ?? key, |
| 12 | + t: (key) => visualTestTranslations[key] ?? key, |
45 | 13 | i18n: null as unknown as typeof import("../../../i18n/setup").default, |
46 | 14 | }}> |
47 | 15 | <TelemetryBanner /> |
|
0 commit comments