Skip to content

Commit a7bd2fe

Browse files
committed
chore: update doc
1 parent 6001bfc commit a7bd2fe

2 files changed

Lines changed: 52 additions & 4 deletions

File tree

doc/components/IDESelector.tsx

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,38 @@ export default function IDESelector({
533533
collapseStep1 = false
534534
}: IDESelectorProps) {
535535
const { i18n } = useDocusaurusContext();
536-
const locale = i18n.currentLocale || i18n.defaultLocale || 'zh-CN';
537-
const t = translations[locale] || translations['zh-CN'];
536+
// Normalize locale: zh-Hans -> zh-CN, en -> en
537+
const rawLocale = i18n?.currentLocale || i18n?.defaultLocale || 'zh-CN';
538+
const locale = rawLocale === 'zh-Hans' ? 'zh-CN' : (rawLocale === 'en' ? 'en' : 'zh-CN');
539+
const isEnglish = locale === 'en';
540+
541+
// Get translations with fallback chain
542+
const t = translations[locale] || translations['zh-CN'] || translations['en'] || {};
543+
544+
// Safe helper function to replace {name} placeholder
545+
const getOpenInIDEText = (ideName?: string): string => {
546+
const name = ideName || 'IDE';
547+
// Try to get template from translations
548+
let template = t?.openInIDE;
549+
550+
// Fallback to default based on locale
551+
if (!template || typeof template !== 'string') {
552+
template = isEnglish ? 'Open with {name}' : '用 {name} 打开';
553+
}
554+
555+
// Final safety check
556+
if (typeof template !== 'string') {
557+
return isEnglish ? `Open with ${name}` : `用 ${name} 打开`;
558+
}
559+
560+
// Perform replacement
561+
try {
562+
return template.replace('{name}', name);
563+
} catch (error) {
564+
// Ultimate fallback if replace fails
565+
return isEnglish ? `Open with ${name}` : `用 ${name} 打开`;
566+
}
567+
};
538568

539569
const [selectedIDE, setSelectedIDE] = useState<string>(defaultIDE || 'cursor');
540570
const [isOpen, setIsOpen] = useState(false);
@@ -1273,7 +1303,7 @@ export default function IDESelector({
12731303
<button
12741304
onClick={handleOpenIDE}
12751305
className={styles.openIDEButton}
1276-
title={t.openInIDE.replace('{name}', ide.name) || `用 ${ide.name} 打开`}
1306+
title={getOpenInIDEText(ide?.name)}
12771307
>
12781308
{getIconUrl(ide) && (
12791309
<img
@@ -1282,7 +1312,7 @@ export default function IDESelector({
12821312
className={styles.openIDEIcon}
12831313
/>
12841314
)}
1285-
<span>{t.openInIDE.replace('{name}', ide.name) || `用 ${ide.name} 打开`}</span>
1315+
<span>{getOpenInIDEText(ide?.name)}</span>
12861316
</button>
12871317
)}
12881318
<button

doc/components/TutorialsGrid.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ const tutorials: Tutorial[] = [
119119
type: 'article',
120120
},
121121
// 视频
122+
{
123+
id: 'video-ai-programming-deploy',
124+
title: 'AI编程,一键部署',
125+
description: '腾讯云云开发',
126+
category: '视频教程',
127+
url: 'https://www.bilibili.com/video/BV1Honwz1E64/?share_source=copy_web&vd_source=068decbd00a3d00ff8662b6a358e5e1e',
128+
type: 'video',
129+
thumbnail: 'https://7463-tcb-advanced-a656fc-1257967285.tcb.qcloud.la/video-thumbnails/BV1Honwz1E64.jpg',
130+
},
131+
{
132+
id: 'video-mbti-dating',
133+
title: '我用AI做了个MBTI交友网站:从写代码到部署上线,AI+MCP 全部自己搞定!简直离谱!',
134+
description: '御风大世界',
135+
category: '视频教程',
136+
url: 'https://www.bilibili.com/video/BV1QG3EzjEFZ/?share_source=copy_web&vd_source=068decbd00a3d00ff8662b6a358e5e1e',
137+
type: 'video',
138+
thumbnail: 'https://7463-tcb-advanced-a656fc-1257967285.tcb.qcloud.la/video-thumbnails/BV1QG3EzjEFZ.jpg',
139+
},
122140
{
123141
id: 'video-ai-try-on',
124142
title: 'AI编程:从0到1开发一个AI试衣小程序!免费分享 | 含源码',

0 commit comments

Comments
 (0)