Skip to content

Commit d884a04

Browse files
committed
Fix preview i18n
1 parent 631cf98 commit d884a04

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

packages/astro/src/default/utils/content/default-localization.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const DEFAULT_LOCALIZATION = {
88
webcontainerLinkText: 'Powered by WebContainers',
99
filesTitleText: 'Files',
1010
prepareEnvironmentTitleText: 'Preparing Environment',
11+
previewTitleText: 'Preview',
1112
toggleTerminalButtonText: 'Toggle Terminal',
1213
solveButtonText: 'Solve',
1314
resetButtonText: 'Reset',

packages/components/react/src/Panels/PreviewPanel.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export const PreviewPanel = memo(
122122
first={index === 0}
123123
last={index === previews.length - 1}
124124
toggleTerminal={toggleTerminal}
125+
i18n={i18n}
125126
/>
126127
</Panel>,
127128
);
@@ -143,9 +144,10 @@ interface PreviewProps {
143144
first?: boolean;
144145
last?: boolean;
145146
toggleTerminal?: () => void;
147+
i18n: I18n;
146148
}
147149

148-
function Preview({ preview, iframe, previewCount, first, last, toggleTerminal }: PreviewProps) {
150+
function Preview({ preview, iframe, previewCount, first, last, toggleTerminal, i18n }: PreviewProps) {
149151
const previewContainerRef = useRef<HTMLDivElement>(null);
150152

151153
useEffect(() => {
@@ -169,7 +171,7 @@ function Preview({ preview, iframe, previewCount, first, last, toggleTerminal }:
169171
>
170172
<div className="panel-title">
171173
<div className="panel-icon i-ph-globe-duotone"></div>
172-
<span className="text-sm truncate">{previewTitle(preview, previewCount)}</span>
174+
<span className="text-sm truncate">{previewTitle(preview, previewCount, i18n)}</span>
173175
</div>
174176
{last && (
175177
<button
@@ -178,7 +180,7 @@ function Preview({ preview, iframe, previewCount, first, last, toggleTerminal }:
178180
onClick={() => toggleTerminal?.()}
179181
>
180182
<div className="panel-button-icon i-ph-terminal-window-duotone"></div>
181-
<span className="text-sm">Toggle Terminal</span>
183+
<span className="text-sm">{i18n.toggleTerminalButtonText}</span>
182184
</button>
183185
)}
184186
</div>
@@ -207,13 +209,13 @@ function requestAnimationFrameLoop(loop: () => void): () => void {
207209
};
208210
}
209211

210-
function previewTitle(preview: PreviewInfo, previewCount: number) {
212+
function previewTitle(preview: PreviewInfo, previewCount: number, i18n: I18n) {
211213
if (preview.title) {
212214
return preview.title;
213215
}
214216

215217
if (previewCount === 1) {
216-
return 'Preview';
218+
return i18n.previewTitleText;
217219
}
218220

219221
return `Preview on port ${preview.port}`;

packages/types/src/schemas/i18n.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ export const i18nSchema = z.object({
5656
*/
5757
prepareEnvironmentTitleText: z.string().optional().describe('Text shown on top of the steps section.'),
5858

59+
/**
60+
* Text shown on top of the preview section.
61+
*
62+
* @default 'Preview'
63+
*/
64+
previewTitleText: z.string().optional().describe('Text shown on top of the preview section.'),
65+
5966
/**
6067
* Text for the toggle terminal button.
6168
*

0 commit comments

Comments
 (0)