mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 21:28:50 +01:00
🌍 i18n: Add multi-language support for Terms of Service and update modal content
This commit is contained in:
parent
9db00edfc4
commit
b7a6d7caa6
9 changed files with 172 additions and 66 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { useMemo } from 'react';
|
||||
import type { TTermsOfService } from 'librechat-data-provider';
|
||||
import React from 'react';
|
||||
import MarkdownLite from '~/components/Chat/Messages/Content/MarkdownLite';
|
||||
import DialogTemplate from '~/components/ui/DialogTemplate';
|
||||
import { useAcceptTermsMutation } from '~/data-provider';
|
||||
|
|
@ -7,6 +6,15 @@ import { useToastContext } from '~/Providers';
|
|||
import { OGDialog } from '~/components/ui';
|
||||
import { useLocalize } from '~/hooks';
|
||||
|
||||
interface TermsModalProps {
|
||||
open: boolean;
|
||||
onOpenChange: (isOpen: boolean) => void;
|
||||
onAccept: () => void;
|
||||
onDecline: () => void;
|
||||
title?: string;
|
||||
modalContent?: string;
|
||||
}
|
||||
|
||||
const TermsAndConditionsModal = ({
|
||||
open,
|
||||
onOpenChange,
|
||||
|
|
@ -14,17 +22,10 @@ const TermsAndConditionsModal = ({
|
|||
onDecline,
|
||||
title,
|
||||
modalContent,
|
||||
}: {
|
||||
open: boolean;
|
||||
onOpenChange: (isOpen: boolean) => void;
|
||||
onAccept: () => void;
|
||||
onDecline: () => void;
|
||||
title?: string;
|
||||
contentUrl?: string;
|
||||
modalContent?: TTermsOfService['modalContent'];
|
||||
}) => {
|
||||
}: TermsModalProps) => {
|
||||
const localize = useLocalize();
|
||||
const { showToast } = useToastContext();
|
||||
|
||||
const acceptTermsMutation = useAcceptTermsMutation({
|
||||
onSuccess: () => {
|
||||
onAccept();
|
||||
|
|
@ -51,18 +52,6 @@ const TermsAndConditionsModal = ({
|
|||
onOpenChange(isOpen);
|
||||
};
|
||||
|
||||
const content = useMemo(() => {
|
||||
if (typeof modalContent === 'string') {
|
||||
return modalContent;
|
||||
}
|
||||
|
||||
if (Array.isArray(modalContent)) {
|
||||
return modalContent.join('\n');
|
||||
}
|
||||
|
||||
return '';
|
||||
}, [modalContent]);
|
||||
|
||||
return (
|
||||
<OGDialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogTemplate
|
||||
|
|
@ -72,15 +61,13 @@ const TermsAndConditionsModal = ({
|
|||
showCancelButton={false}
|
||||
main={
|
||||
<section
|
||||
// Motivation: This is a dialog, so its content should be focusable
|
||||
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
||||
tabIndex={0}
|
||||
className="max-h-[60vh] overflow-y-auto p-4"
|
||||
aria-label={localize('com_ui_terms_and_conditions')}
|
||||
>
|
||||
<div className="prose dark:prose-invert w-full max-w-none !text-text-primary">
|
||||
{content !== '' ? (
|
||||
<MarkdownLite content={content} />
|
||||
{modalContent ? (
|
||||
<MarkdownLite content={modalContent} />
|
||||
) : (
|
||||
<p>{localize('com_ui_no_terms_content')}</p>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,11 @@ import {
|
|||
import { useAuthContext, useAssistantsMap, useAgentsMap, useFileMap, useSearch } from '~/hooks';
|
||||
import TermsAndConditionsModal from '~/components/ui/TermsAndConditionsModal';
|
||||
import { useUserTermsQuery, useGetStartupConfig } from '~/data-provider';
|
||||
import { getTermsMarkdown } from '~/terms/termsContent';
|
||||
import { Nav, MobileNav } from '~/components/Nav';
|
||||
import { Banner } from '~/components/Banners';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import store from '~/store';
|
||||
|
||||
export default function Root() {
|
||||
const navigate = useNavigate();
|
||||
|
|
@ -29,6 +32,9 @@ export default function Root() {
|
|||
const fileMap = useFileMap({ isAuthenticated });
|
||||
const search = useSearch({ isAuthenticated });
|
||||
|
||||
const lang = useRecoilValue(store.lang);
|
||||
const modalContent = getTermsMarkdown(lang);
|
||||
|
||||
const { data: config } = useGetStartupConfig();
|
||||
const { data: termsData } = useUserTermsQuery({
|
||||
enabled: isAuthenticated && config?.interface?.termsOfService?.modalAcceptance === true,
|
||||
|
|
@ -78,7 +84,7 @@ export default function Root() {
|
|||
onAccept={handleAcceptTerms}
|
||||
onDecline={handleDeclineTerms}
|
||||
title={config.interface.termsOfService.modalTitle}
|
||||
modalContent={config.interface.termsOfService.modalContent}
|
||||
modalContent={modalContent}
|
||||
/>
|
||||
)}
|
||||
</AssistantsMapContext.Provider>
|
||||
|
|
|
|||
45
client/src/terms/termsContent.ts
Normal file
45
client/src/terms/termsContent.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import terms_en from './terms_en.md?raw';
|
||||
import terms_de from './terms_de.md?raw';
|
||||
import terms_fr from './terms_fr.md?raw';
|
||||
|
||||
/**
|
||||
* A mapping of language codes to their respective terms markdown content.
|
||||
*
|
||||
* You can add both base language codes (e.g. 'en') and full codes (e.g. 'pt-BR') if needed.
|
||||
*
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const markdownMap: Record<string, string> = {
|
||||
en: terms_en,
|
||||
de: terms_de,
|
||||
fr: terms_fr,
|
||||
// For example, to support Brazilian Portuguese, you could add:
|
||||
// 'pt-BR': terms_ptBR,
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the terms markdown content for the specified language.
|
||||
*
|
||||
* The function first checks if an exact language code match exists in the markdown map.
|
||||
* If not, it attempts to extract the base language (e.g., 'pt' from 'pt-BR') and checks again.
|
||||
* If no match is found, it falls back to English.
|
||||
*
|
||||
* @param {string} lang - The language code, which may include a region (e.g., 'pt-BR', 'en-US').
|
||||
* @returns {string} The markdown content corresponding to the language,
|
||||
* or the English version if no matching language is found.
|
||||
*/
|
||||
export function getTermsMarkdown(lang: string): string {
|
||||
// Check for exact language code match (e.g., 'pt-BR').
|
||||
if (lang in markdownMap) {
|
||||
return markdownMap[lang];
|
||||
}
|
||||
|
||||
// Extract the base language (e.g., 'pt' from 'pt-BR') and check again.
|
||||
const baseLang = lang.split('-')[0];
|
||||
if (baseLang in markdownMap) {
|
||||
return markdownMap[baseLang];
|
||||
}
|
||||
|
||||
// Fall back to English if no match is found.
|
||||
return markdownMap['en'];
|
||||
}
|
||||
35
client/src/terms/terms_de.md
Normal file
35
client/src/terms/terms_de.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Nutzungsbedingungen für LibreChat
|
||||
|
||||
*Gültig ab: 18. Februar 2024*
|
||||
|
||||
Willkommen bei LibreChat, der Informationsseite für die Open-Source-AI-Chat-Plattform, verfügbar unter [https://librechat.ai](https://librechat.ai). Diese Nutzungsbedingungen ("Bedingungen") regeln Ihre Nutzung unserer Webseite sowie der von uns angebotenen Dienste. Mit dem Zugriff auf oder der Nutzung der Webseite erklären Sie sich mit diesen Bedingungen und unserer Datenschutzrichtlinie, die unter [https://librechat.ai/privacy](https://librechat.ai/privacy) abrufbar ist, einverstanden.
|
||||
|
||||
## 1. Eigentum
|
||||
|
||||
Beim Kauf eines Pakets von LibreChat erhalten Sie das Recht, den Code für den Zugriff auf ein Admin-Panel von LibreChat herunterzuladen und zu verwenden. Obwohl Sie den heruntergeladenen Code besitzen, ist es Ihnen ausdrücklich untersagt, diesen ohne ausdrückliche Genehmigung von LibreChat an Dritte weiterzuverkaufen, weiterzugeben oder anderweitig zu übertragen.
|
||||
|
||||
## 2. Benutzerdaten
|
||||
|
||||
Wir erheben personenbezogene Daten, wie Ihren Namen, Ihre E-Mail-Adresse und Zahlungsinformationen, wie in unserer Datenschutzrichtlinie beschrieben. Diese Informationen werden erhoben, um unsere Dienste bereitzustellen und zu verbessern, Transaktionen abzuwickeln und mit Ihnen zu kommunizieren.
|
||||
|
||||
## 3. Erhebung nicht-personenbezogener Daten
|
||||
|
||||
Die Webseite verwendet Cookies, um die Benutzererfahrung zu verbessern, die Nutzung der Seite zu analysieren und bestimmte Funktionalitäten zu ermöglichen. Durch die Nutzung der Webseite stimmen Sie der Verwendung von Cookies gemäß unserer Datenschutzrichtlinie zu.
|
||||
|
||||
## 4. Nutzung der Webseite
|
||||
|
||||
Sie verpflichten sich, die Webseite ausschließlich für rechtmäßige Zwecke zu nutzen und in einer Weise, die nicht die Rechte anderer beeinträchtigt, einschränkt oder deren Nutzung und Freude an der Webseite behindert. Zu den verbotenen Verhaltensweisen zählen das Belästigen oder das Zufügen von Unannehmlichkeiten, das Übermitteln obszöner oder anstößiger Inhalte sowie das Stören des normalen Dialogflusses innerhalb der Webseite.
|
||||
|
||||
## 5. Anwendbares Recht
|
||||
|
||||
Diese Bedingungen unterliegen den Gesetzen der Vereinigten Staaten und werden in Übereinstimmung mit diesen ausgelegt, ohne dass Prinzipien des Kollisionsrechts Anwendung finden.
|
||||
|
||||
## 6. Änderungen der Bedingungen
|
||||
|
||||
Wir behalten uns das Recht vor, diese Bedingungen jederzeit zu ändern. Wir werden die Nutzer per E-Mail über etwaige Änderungen informieren. Ihre fortgesetzte Nutzung der Webseite nach Bekanntgabe solcher Änderungen gilt als Zustimmung zu den geänderten Bedingungen.
|
||||
|
||||
## 7. Kontaktinformationen
|
||||
|
||||
Wenn Sie Fragen zu diesen Bedingungen haben, kontaktieren Sie uns bitte unter [contact@librechat.ai](mailto:contact@librechat.ai).
|
||||
|
||||
Durch die Nutzung der Webseite bestätigen Sie, dass Sie diese Nutzungsbedingungen gelesen haben und an diese gebunden sind.
|
||||
35
client/src/terms/terms_en.md
Normal file
35
client/src/terms/terms_en.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Terms and Conditions for LibreChat
|
||||
|
||||
*Effective Date: February 18, 2024*
|
||||
|
||||
Welcome to LibreChat, the informational website for the open-source AI chat platform, available at [https://librechat.ai](https://librechat.ai). These Terms of Service ("Terms") govern your use of our website and the services we offer. By accessing or using the Website, you agree to be bound by these Terms and our Privacy Policy, accessible at [https://librechat.ai/privacy](https://librechat.ai/privacy).
|
||||
|
||||
## 1. Ownership
|
||||
|
||||
Upon purchasing a package from LibreChat, you are granted the right to download and use the code for accessing an admin panel for LibreChat. While you own the downloaded code, you are expressly prohibited from reselling, redistributing, or otherwise transferring the code to third parties without explicit permission from LibreChat.
|
||||
|
||||
## 2. User Data
|
||||
|
||||
We collect personal data, such as your name, email address, and payment information, as described in our Privacy Policy. This information is collected to provide and improve our services, process transactions, and communicate with you.
|
||||
|
||||
## 3. Non-Personal Data Collection
|
||||
|
||||
The Website uses cookies to enhance user experience, analyze site usage, and facilitate certain functionalities. By using the Website, you consent to the use of cookies in accordance with our Privacy Policy.
|
||||
|
||||
## 4. Use of the Website
|
||||
|
||||
You agree to use the Website only for lawful purposes and in a manner that does not infringe the rights of, restrict, or inhibit anyone else's use and enjoyment of the Website. Prohibited behavior includes harassing or causing distress or inconvenience to any person, transmitting obscene or offensive content, or disrupting the normal flow of dialogue within the Website.
|
||||
|
||||
## 5. Governing Law
|
||||
|
||||
These Terms shall be governed by and construed in accordance with the laws of the United States, without giving effect to any principles of conflicts of law.
|
||||
|
||||
## 6. Changes to the Terms
|
||||
|
||||
We reserve the right to modify these Terms at any time. We will notify users of any changes by email. Your continued use of the Website after such changes have been notified will constitute your consent to such changes.
|
||||
|
||||
## 7. Contact Information
|
||||
|
||||
If you have any questions about these Terms, please contact us at [contact@librechat.ai](mailto:contact@librechat.ai).
|
||||
|
||||
By using the Website, you acknowledge that you have read these Terms of Service and agree to be bound by them.
|
||||
35
client/src/terms/terms_fr.md
Normal file
35
client/src/terms/terms_fr.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Conditions Générales pour LibreChat
|
||||
|
||||
*Date d'entrée en vigueur : 18 février 2024*
|
||||
|
||||
Bienvenue sur LibreChat, le site d'information dédié à la plateforme de chat IA open source, accessible à l'adresse [https://librechat.ai](https://librechat.ai). Les présentes Conditions d'Utilisation ("Conditions") régissent votre usage de notre site et des services que nous proposons. En accédant ou en utilisant le site, vous acceptez d'être lié par ces Conditions ainsi que par notre Politique de Confidentialité, disponible à [https://librechat.ai/privacy](https://librechat.ai/privacy).
|
||||
|
||||
## 1. Propriété
|
||||
|
||||
Lors de l'achat d'un package auprès de LibreChat, vous obtenez le droit de télécharger et d'utiliser le code permettant d'accéder à un panneau d'administration de LibreChat. Bien que vous soyez propriétaire du code téléchargé, il vous est expressément interdit de revendre, redistribuer ou transférer ce code à des tiers sans l'autorisation explicite de LibreChat.
|
||||
|
||||
## 2. Données Utilisateurs
|
||||
|
||||
Nous collectons des données personnelles telles que votre nom, votre adresse e-mail et vos informations de paiement, comme indiqué dans notre Politique de Confidentialité. Ces informations sont collectées afin de fournir et d'améliorer nos services, de traiter les transactions et de communiquer avec vous.
|
||||
|
||||
## 3. Collecte de Données Non-Personnelles
|
||||
|
||||
Le site utilise des cookies pour améliorer l'expérience utilisateur, analyser l'utilisation du site et faciliter certaines fonctionnalités. En utilisant le site, vous consentez à l'utilisation des cookies conformément à notre Politique de Confidentialité.
|
||||
|
||||
## 4. Utilisation du Site
|
||||
|
||||
Vous vous engagez à utiliser le site uniquement à des fins légales et d'une manière qui ne porte pas atteinte aux droits d'autrui, ne restreint pas ou n'entrave pas l'utilisation et le plaisir que d'autres peuvent avoir du site. Les comportements interdits incluent le harcèlement, la création de désagréments, la transmission de contenus obscènes ou offensants, ainsi que la perturbation du déroulement normal des échanges sur le site.
|
||||
|
||||
## 5. Loi Applicable
|
||||
|
||||
Les présentes Conditions sont régies et interprétées conformément aux lois des États-Unis, sans égard aux principes de conflits de lois.
|
||||
|
||||
## 6. Modifications des Conditions
|
||||
|
||||
Nous nous réservons le droit de modifier ces Conditions à tout moment. Les utilisateurs seront informés des modifications par e-mail. Votre utilisation continue du site après notification des modifications vaudra acceptation de ces changements.
|
||||
|
||||
## 7. Informations de Contact
|
||||
|
||||
Si vous avez des questions concernant ces Conditions, veuillez nous contacter à [contact@librechat.ai](mailto:contact@librechat.ai).
|
||||
|
||||
En utilisant le site, vous reconnaissez avoir lu ces Conditions d'Utilisation et acceptez d'en être lié.
|
||||
|
|
@ -21,42 +21,6 @@ interface:
|
|||
openNewTab: true
|
||||
modalAcceptance: true
|
||||
modalTitle: "Terms of Service for LibreChat"
|
||||
modalContent: |
|
||||
# Terms and Conditions for LibreChat
|
||||
|
||||
*Effective Date: February 18, 2024*
|
||||
|
||||
Welcome to LibreChat, the informational website for the open-source AI chat platform, available at https://librechat.ai. These Terms of Service ("Terms") govern your use of our website and the services we offer. By accessing or using the Website, you agree to be bound by these Terms and our Privacy Policy, accessible at https://librechat.ai//privacy.
|
||||
|
||||
## 1. Ownership
|
||||
|
||||
Upon purchasing a package from LibreChat, you are granted the right to download and use the code for accessing an admin panel for LibreChat. While you own the downloaded code, you are expressly prohibited from reselling, redistributing, or otherwise transferring the code to third parties without explicit permission from LibreChat.
|
||||
|
||||
## 2. User Data
|
||||
|
||||
We collect personal data, such as your name, email address, and payment information, as described in our Privacy Policy. This information is collected to provide and improve our services, process transactions, and communicate with you.
|
||||
|
||||
## 3. Non-Personal Data Collection
|
||||
|
||||
The Website uses cookies to enhance user experience, analyze site usage, and facilitate certain functionalities. By using the Website, you consent to the use of cookies in accordance with our Privacy Policy.
|
||||
|
||||
## 4. Use of the Website
|
||||
|
||||
You agree to use the Website only for lawful purposes and in a manner that does not infringe the rights of, restrict, or inhibit anyone else's use and enjoyment of the Website. Prohibited behavior includes harassing or causing distress or inconvenience to any person, transmitting obscene or offensive content, or disrupting the normal flow of dialogue within the Website.
|
||||
|
||||
## 5. Governing Law
|
||||
|
||||
These Terms shall be governed by and construed in accordance with the laws of the United States, without giving effect to any principles of conflicts of law.
|
||||
|
||||
## 6. Changes to the Terms
|
||||
|
||||
We reserve the right to modify these Terms at any time. We will notify users of any changes by email. Your continued use of the Website after such changes have been notified will constitute your consent to such changes.
|
||||
|
||||
## 7. Contact Information
|
||||
|
||||
If you have any questions about these Terms, please contact us at contact@librechat.ai.
|
||||
|
||||
By using the Website, you acknowledge that you have read these Terms of Service and agree to be bound by them.
|
||||
|
||||
endpointsMenu: true
|
||||
modelSelect: true
|
||||
|
|
|
|||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -41152,7 +41152,7 @@
|
|||
"packages/data-schemas": {
|
||||
"name": "@librechat/data-schemas",
|
||||
"version": "0.0.2",
|
||||
"license": "ISC",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mongoose": "^8.9.5"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -454,7 +454,6 @@ const termsOfServiceSchema = z.object({
|
|||
openNewTab: z.boolean().optional(),
|
||||
modalAcceptance: z.boolean().optional(),
|
||||
modalTitle: z.string().optional(),
|
||||
modalContent: z.string().or(z.array(z.string())).optional(),
|
||||
});
|
||||
|
||||
export type TTermsOfService = z.infer<typeof termsOfServiceSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue