Skip to content

Commit 8ad4b39

Browse files
committed
feat(i18n): 添加网站国际化支持
1. 新增多语言支持框架,支持中英文切换功能 2. 优化首屏加载语言体验,初始化脚本防止白屏闪烁 3. 添加语言切换器组件及相关工具函数 4. 修复导航栏布局问题,确保菜单左对齐、语言切换器右对齐 5. 增强元数据国际化,动态更新标题和描述
1 parent 9b6f393 commit 8ad4b39

34 files changed

+2384
-283
lines changed

script-hook-website/README.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# JS Script Hook Website
2+
3+
<div align="right">
4+
<a href="README.md">English</a> | <a href="README.md">中文</a>
5+
</div>
6+
7+
## About
8+
9+
This is the official website for the JS Script Hook project, featuring a React-based SPA that showcases the library's features, provides installation instructions, and offers community support resources.
10+
11+
The website is built with React, TypeScript, and supports full internationalization with both English and Chinese languages.
12+
13+
## Features
14+
15+
- Responsive design that works on all devices
16+
- Comprehensive internationalization (i18n) support for English and Chinese
17+
- Optimized SEO metadata with language-specific content
18+
- Interactive UI components to demonstrate the library's capabilities
19+
- Social sharing functionality
20+
21+
## Development
22+
23+
### Prerequisites
24+
25+
- Node.js (v14.0.0 or higher)
26+
- npm or yarn
27+
28+
### Installation
29+
30+
```bash
31+
# Clone the repository
32+
git clone https://github.com/JSREI/js-script-hook.git
33+
cd js-script-hook/script-hook-website
34+
35+
# Install dependencies
36+
npm install
37+
# or
38+
yarn install
39+
```
40+
41+
### Development Server
42+
43+
```bash
44+
# Start the development server
45+
npm start
46+
# or
47+
yarn start
48+
```
49+
50+
The website will be available at `http://localhost:8080`.
51+
52+
### Building for Production
53+
54+
```bash
55+
# Build for production
56+
npm run build
57+
# or
58+
yarn build
59+
```
60+
61+
The compiled website will be available in the `dist` directory.
62+
63+
## Internationalization
64+
65+
The website supports both English and Chinese languages. The language is automatically detected based on the user's browser settings, but can also be manually selected through the language switcher in the header.
66+
67+
Translation files are located in:
68+
- `src/i18n/locales/en.json` (English)
69+
- `src/i18n/locales/zh.json` (Chinese)
70+
71+
## Deployment
72+
73+
The website is deployed to GitHub Pages automatically via GitHub Actions when changes are pushed to the main branch.
74+
75+
---
76+
77+
<div align="center">
78+
<h1>JS Script Hook 网站</h1>
79+
</div>
80+
81+
<div align="right">
82+
<a href="README.md">English</a> | <a href="README.md">中文</a>
83+
</div>
84+
85+
## 简介
86+
87+
这是JS Script Hook项目的官方网站,基于React的单页应用程序,展示了该库的功能特性,提供安装指南,并提供社区支持资源。
88+
89+
该网站使用React和TypeScript构建,支持英文和中文的完整国际化。
90+
91+
## 特性
92+
93+
- 响应式设计,适用于所有设备
94+
- 全面支持英文和中文的国际化(i18n)
95+
- 针对不同语言优化的SEO元数据
96+
- 交互式UI组件,展示库的功能
97+
- 社交媒体分享功能
98+
99+
## 开发
100+
101+
### 环境要求
102+
103+
- Node.js (v14.0.0或更高版本)
104+
- npm或yarn
105+
106+
### 安装
107+
108+
```bash
109+
# 克隆仓库
110+
git clone https://github.com/JSREI/js-script-hook.git
111+
cd js-script-hook/script-hook-website
112+
113+
# 安装依赖
114+
npm install
115+
#
116+
yarn install
117+
```
118+
119+
### 开发服务器
120+
121+
```bash
122+
# 启动开发服务器
123+
npm start
124+
#
125+
yarn start
126+
```
127+
128+
网站将在`http://localhost:8080`可访问。
129+
130+
### 生产环境构建
131+
132+
```bash
133+
# 构建生产版本
134+
npm run build
135+
#
136+
yarn build
137+
```
138+
139+
编译后的网站将在`dist`目录中可用。
140+
141+
## 国际化
142+
143+
该网站支持英文和中文两种语言。语言会根据用户的浏览器设置自动检测,也可以通过页头的语言切换器手动选择。
144+
145+
翻译文件位于:
146+
- `src/i18n/locales/en.json`(英文)
147+
- `src/i18n/locales/zh.json`(中文)
148+
149+
## 部署
150+
151+
当更改推送到主分支时,网站会通过GitHub Actions自动部署到GitHub Pages。

script-hook-website/package-lock.json

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

script-hook-website/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "script-hook-website",
33
"version": "1.0.0",
4-
"description": "JS Script Hook官方网站",
4+
"description": "JS Script Hook官方网站 | JS Script Hook Official Website",
55
"homepage": "https://jsrei.github.io/js-script-hook",
66
"main": "index.js",
77
"scripts": {
@@ -20,12 +20,17 @@
2020
"author": "JSREI",
2121
"license": "MIT",
2222
"dependencies": {
23+
"@types/dompurify": "^3.0.5",
2324
"@types/react": "^18.2.0",
2425
"@types/react-dom": "^18.2.0",
2526
"@types/react-router-dom": "^5.3.3",
2627
"d3": "^7.9.0",
28+
"dompurify": "^3.2.5",
29+
"i18next": "^25.1.3",
30+
"i18next-browser-languagedetector": "^8.1.0",
2731
"react": "^18.2.0",
2832
"react-dom": "^18.2.0",
33+
"react-i18next": "^15.5.1",
2934
"react-medium-image-zoom": "^5.2.14",
3035
"react-router-dom": "^7.6.0",
3136
"react-syntax-highlighter": "^15.6.1",

script-hook-website/public/404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<title>JS Script Hook</title>
66
<script type="text/javascript">
7-
// 重定向所有404请求到首页
7+
// Redirect all 404 requests to the home page
88
var pathSegmentsToKeep = 1;
99

1010
var l = window.location;

0 commit comments

Comments
 (0)