From 83188e7ea469286990590795ef8a1219d0b7e59b Mon Sep 17 00:00:00 2001 From: GuoQing Liu <842607283@qq.com> Date: Tue, 6 May 2025 22:49:49 +0800 Subject: [PATCH] Add chinese docs (#17954) * add docs chinese i18n * fix some broken links * update some i18n * update chinese docs * add chinese community docs * Change docs i18n chinese label --- README_CN.md | 12 ++++----- docs/docusaurus.config.ts | 19 ++++++++++++++ docs/src/components/LanguageAlert/index.jsx | 25 +++++++++++++++++++ .../LanguageAlert/styles.module.css | 13 ++++++++++ docs/src/theme/Navbar/index.js | 15 +++++++++++ 5 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 docs/src/components/LanguageAlert/index.jsx create mode 100644 docs/src/components/LanguageAlert/styles.module.css create mode 100644 docs/src/theme/Navbar/index.js diff --git a/README_CN.md b/README_CN.md index ff72803a2..efcea3480 100644 --- a/README_CN.md +++ b/README_CN.md @@ -24,11 +24,9 @@ - 通过RTSP重新流传输以减少摄像头的连接数 - 支持WebRTC和MSE,实现低延迟的实时观看 -## 文档(英文) +## 社区中文翻译文档 -你可以在这里查看文档 https://docs.frigate.video - -文档还暂时没有提供翻译,将会在未来提供。 +你可以在这里查看文档 https://docs.frigate-cn.video ## 赞助 @@ -60,5 +58,7 @@ ## 翻译 我们使用 [Weblate](https://hosted.weblate.org/projects/frigate-nvr/) 平台提供翻译支持,欢迎参与进来一起完善。 -## 中文讨论社区 -欢迎加入非官方中文讨论QQ群:1043861059 + +## 非官方中文讨论社区 +欢迎加入中文讨论QQ群:1043861059 +Bilibili:https://space.bilibili.com/3546894915602564 diff --git a/docs/docusaurus.config.ts b/docs/docusaurus.config.ts index 865cb53d2..5e80e844a 100644 --- a/docs/docusaurus.config.ts +++ b/docs/docusaurus.config.ts @@ -17,6 +17,15 @@ const config: Config = { markdown: { mermaid: true, }, + i18n: { + defaultLocale: 'en', + locales: ['en'], + localeConfigs: { + en: { + label: 'English', + } + }, + }, themeConfig: { algolia: { appId: 'WIURGBNBPY', @@ -82,6 +91,16 @@ const config: Config = { label: 'Demo', position: 'right', }, + { + type: 'localeDropdown', + position: 'right', + dropdownItemsAfter: [ + { + label: '简体中文(社区翻译)', + href: 'https://docs.frigate-cn.video', + } + ] + }, { href: 'https://github.com/blakeblackshear/frigate', label: 'GitHub', diff --git a/docs/src/components/LanguageAlert/index.jsx b/docs/src/components/LanguageAlert/index.jsx new file mode 100644 index 000000000..b786c8a93 --- /dev/null +++ b/docs/src/components/LanguageAlert/index.jsx @@ -0,0 +1,25 @@ +import React, { useEffect, useState } from 'react'; +import { useLocation } from '@docusaurus/router'; +import styles from './styles.module.css'; + +export default function LanguageAlert() { + const [showAlert, setShowAlert] = useState(false); + const { pathname } = useLocation(); + + useEffect(() => { + const userLanguage = navigator?.language || 'en'; + const isChineseUser = userLanguage.includes('zh'); + setShowAlert(isChineseUser); + + }, [pathname]); + + if (!showAlert) return null; + + return ( +
+ 检测到您的主要语言为中文,您可以访问由中文社区翻译的 + 中文文档 + 以获得更好的体验 +
+ ); +} \ No newline at end of file diff --git a/docs/src/components/LanguageAlert/styles.module.css b/docs/src/components/LanguageAlert/styles.module.css new file mode 100644 index 000000000..f8d1e8eb2 --- /dev/null +++ b/docs/src/components/LanguageAlert/styles.module.css @@ -0,0 +1,13 @@ +.alert { + padding: 12px; + background: #fff8e6; + border-bottom: 1px solid #ffd166; + text-align: center; + font-size: 15px; + } + + .alert a { + color: #1890ff; + font-weight: 500; + margin-left: 6px; + } \ No newline at end of file diff --git a/docs/src/theme/Navbar/index.js b/docs/src/theme/Navbar/index.js new file mode 100644 index 000000000..4dd3aee15 --- /dev/null +++ b/docs/src/theme/Navbar/index.js @@ -0,0 +1,15 @@ +import React from 'react'; +import NavbarLayout from '@theme/Navbar/Layout'; +import NavbarContent from '@theme/Navbar/Content'; +import LanguageAlert from '../../components/LanguageAlert'; + +export default function Navbar() { + return ( + <> + + + + + + ); +} \ No newline at end of file