init 新范式

This commit is contained in:
2025-05-24 09:11:30 +08:00
parent 3057ca121c
commit 7124382c5c
64 changed files with 4074 additions and 16 deletions

27
src/astro/i18n/index.tsx Normal file
View File

@@ -0,0 +1,27 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
// 导入你的翻译资源
import enTranslation from './locales/en/translation.json';
import zhTranslation from './locales/zh/translation.json';
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: {
en: {
translation: enTranslation,
},
zh: {
translation: zhTranslation,
},
},
fallbackLng: 'en',
interpolation: {
escapeValue: false, // React 已经处理了转义
},
});
export default i18n;

View File

@@ -0,0 +1,4 @@
{
"welcome": "Welcome to our site",
"about": "About us"
}

View File

@@ -0,0 +1,4 @@
{
"welcome": "欢迎来到我们的网站",
"about": "关于我们"
}

View File

@@ -0,0 +1,36 @@
---
export interface Props {
children: any;
}
---
<html lang='zh'>
<header>
<meta charset='UTF-8' />
<title>Docs</title>
<link
rel='stylesheet'
href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.8.1/github-markdown-light.min.css'
integrity='sha512-X175XRJAO6PHAUi8AA7GP8uUF5Wiv+w9bOi64i02CHKDQBsO1yy0jLSKaUKg/NhRCDYBmOLQCfKaTaXiyZlLrw=='
crossorigin='anonymous'
referrerpolicy='no-referrer'
/>
</header>
<body>
<header>
<slot name='header'>
<h1>My Site Header</h1>
</slot>
</header>
<main class='markdown-body' style='padding: 1rem'>
<slot />
</main>
<footer>
<slot name='footer'>
<p>Copyrignt &copy; 2025</p>
</slot>
</footer>
</body>
</html>