mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2026-04-12 10:46:23 +00:00
i18n
This commit is contained in:
@@ -17,18 +17,38 @@ import Scamming from '../components/common/Scamming.jsx';
|
||||
// Comment the line below to disable View Transitions
|
||||
import { ViewTransitions } from 'astro:transitions';
|
||||
|
||||
import { useTranslations, getLocalePaths, LOCALES, DEFAULT_LOCALE, type Lang } from '@/i18n';
|
||||
|
||||
import type { MetaData as MetaDataType } from '~/types';
|
||||
|
||||
export interface Props {
|
||||
metadata?: MetaDataType;
|
||||
i18n?: boolean;
|
||||
}
|
||||
|
||||
const { metadata = {} } = Astro.props;
|
||||
const { metadata = {}, i18n } = Astro.props;
|
||||
const { language, textDirection } = I18N;
|
||||
const t = useTranslations(Astro.currentLocale as Lang);
|
||||
const langs = Object.keys(LOCALES);
|
||||
const baseUrl = import.meta.env.PROD ? Astro.site : '/';
|
||||
const defaultLocale = DEFAULT_LOCALE;
|
||||
const locale = Astro.currentLocale as Lang;
|
||||
|
||||
metadata.description = t({
|
||||
en: "RustDesk offers an open-source remote desktop solution with self-hosted server options. Perfect TeamViewer alternative for secure, private, and customizable remote access. Explore our professional on-premise licenses.",
|
||||
es: "RustDesk ofrece una solución de escritorio remoto de código abierto con opciones de servidor autohospedado. La alternativa perfecta a TeamViewer para un acceso remoto seguro, privado y personalizable. Explore nuestras licencias profesionales locales.",
|
||||
pt: "RustDesk oferece uma solução de desktop remoto de código aberto com opções de servidor auto-hospedado. Alternativa perfeita ao TeamViewer para acesso remoto seguro, privado e personalizável. Explore nossas licenças profissionais locais.",
|
||||
fr: "RustDesk propose une solution de bureau à distance open source avec des options de serveur auto-hébergé. Alternative parfaite à TeamViewer pour un accès à distance sécurisé, privé et personnalisable. Explorez nos licences professionnel.",
|
||||
de: "RustDesk bietet eine Open-Source-Lösung für Remote-Desktops mit selbstgehosteten Serveroptionen. Perfekte TeamViewer-Alternative für sicheren, privaten",
|
||||
it: "RustDesk offre una soluzione open source per desktop remoto con opzioni di server self-hosted. Alternativa perfetta a TeamViewer per un accesso remoto sicuro, privato e personalizzabile. Esplora le nostre licenze professionali on-premise.",
|
||||
ja: "RustDeskは、セルフホスト型サーバーオプションを備えたオープンソースのリモートデスクトップソリューションを提供しています。安全でプライベート、カスタマイズ可能なリモートアクセスのための完璧なTeamViewerの代替です。プロフェッショナルなオンプレミスライセンスをご覧ください。",
|
||||
"zh-cn": "RustDesk提供了一个开源的远程桌面解决方案,具有自托管服务器选项。是安全、私密和可定制的远程访问的完美TeamViewer替代品。探索我们的专业本地许可证。",
|
||||
"zh-tw": "RustDesk 提供了一個開源的遠程桌面解決方案,具有自托管伺服器選項。是安全、私密和可定制的遠程訪問的完美 TeamViewer 替代品。探索我們的專業本地許可證。",
|
||||
});
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang={language} dir={textDirection} class="2xl:text-[20px]">
|
||||
<html lang={LOCALES[locale].lang || locale || language} dir={LOCALES[locale].dir || textDirection} class="2xl:text-[20px]">
|
||||
<head>
|
||||
<CommonMeta />
|
||||
<Favicons />
|
||||
@@ -40,6 +60,41 @@ const { language, textDirection } = I18N;
|
||||
|
||||
<!-- Comment the line below to disable View Transitions -->
|
||||
<ViewTransitions fallback="swap" />
|
||||
{
|
||||
i18n &&
|
||||
getLocalePaths(Astro.url).map(({ path, lang }) => (
|
||||
<link
|
||||
rel="alternate"
|
||||
hreflang={LOCALES[lang].lang || lang}
|
||||
href={Astro.site?.origin + path.replace('/' + defaultLocale, '').replace(/\/$/, '')}
|
||||
/>
|
||||
))
|
||||
}
|
||||
{ i18n && Astro.currentLocale == defaultLocale && <script is:inline define:vars={{ langs, baseUrl, defaultLocale }}>
|
||||
let lang;
|
||||
try {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
lang = urlParams.get('lang');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (lang) {
|
||||
//
|
||||
} else if (localStorage.selectedLang && langs.includes(localStorage.selectedLang)) {
|
||||
lang = localStorage.selectedLang;
|
||||
} else {
|
||||
const browserLang = navigator.language.toLowerCase();
|
||||
|
||||
if (langs.includes(browserLang)) {
|
||||
lang = browserLang;
|
||||
} else if (langs.includes(browserLang.split('-')[0])) {
|
||||
lang = browserLang.split('-')[0];
|
||||
}
|
||||
}
|
||||
if (lang && lang !== defaultLocale) {
|
||||
location.href = `${baseUrl + lang + location.pathname + (location.hash || location.search || '')}`.replace(/\/$/, '');
|
||||
}
|
||||
</script> }
|
||||
</head>
|
||||
|
||||
<body class="antialiased text-default bg-page tracking-tight">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
import Layout from '~/layouts/Layout.astro';
|
||||
import Header from '~/components/widgets/Header.astro';
|
||||
import Footer, {type Props as FD} from '~/components/widgets/Footer.astro';
|
||||
import Footer, { type Props as FD } from '~/components/widgets/Footer.astro';
|
||||
import Announcement from '~/components/widgets/Announcement.astro';
|
||||
|
||||
import { headerData, footerData } from '~/navigation';
|
||||
@@ -10,22 +10,23 @@ import type { MetaData } from '~/types';
|
||||
|
||||
export interface Props {
|
||||
metadata?: MetaData;
|
||||
i18n?: boolean;
|
||||
}
|
||||
|
||||
const { metadata } = Astro.props;
|
||||
const { metadata, i18n } = Astro.props;
|
||||
---
|
||||
|
||||
<Layout metadata={metadata}>
|
||||
<Layout metadata={metadata} i18n={i18n}>
|
||||
<slot name="announcement">
|
||||
<Announcement />
|
||||
</slot>
|
||||
<slot name="header">
|
||||
<Header {...headerData} isSticky showGithubStar showToggleTheme />
|
||||
<Header {...headerData(Astro.currentLocale)} isSticky showGithubStar showToggleTheme i18n={i18n} />
|
||||
</slot>
|
||||
<main>
|
||||
<slot />
|
||||
</main>
|
||||
<slot name="footer">
|
||||
<Footer {...footerData as FD} />
|
||||
<Footer {...footerData(Astro.currentLocale) as FD} />
|
||||
</slot>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user