feat: implement ui i18n support

This commit is contained in:
草师傅 2025-08-11 16:06:14 +08:00
parent 457fb93718
commit 698c411c71
Signed by: gb
GPG key ID: 43330A030E2D6478
13 changed files with 162 additions and 54 deletions

View file

@ -1,8 +1,13 @@
---
import {siteConfig} from "../config";
import { getLangFromUrl, useTranslations, useTranslatedPath } from '../i18n/utils';
const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang);
const translatePath = useTranslatedPath(lang);
const noscript = siteConfig.noClientJavaScript
---
{noscript ? <a href="#top"><button id="toTopBtn" style="display: block" title="Go to top">Top</button></a> : <button id="toTopBtn" title="Go to top">Top</button>
{noscript ? <a href="#top"><button id="toTopBtn" style="display: block" title={t('widget.back_to_top.title')}>{t('widget.back_to_top')}</button></a> : <button id="toTopBtn" title={t('widget.back_to_top.title')}>{t('widget.back_to_top')}</button>
<script>
// Get the button
let toTopButton = document.getElementById("toTopBtn");