mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 02:40:14 +01:00
Feature Localization (i18n) Support (#557)
* init localization * Update defaul to en * Fix merge issue and import path. * Set default to en * Change jsx to tsx * Update the password max length string. * Remove languageContext as using the recoil instead.
This commit is contained in:
parent
13627c7f4f
commit
47e5493744
15 changed files with 29076 additions and 115 deletions
|
|
@ -2,8 +2,12 @@ import { useState } from 'react';
|
|||
import { useForm } from 'react-hook-form';
|
||||
import { useResetPasswordMutation, TResetPassword } from '@librechat/data-provider';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import store from '~/store';
|
||||
import { localize } from '~/localization/Translation';
|
||||
|
||||
function ResetPassword() {
|
||||
const lang = useRecoilValue(store.lang);
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
|
|
@ -28,19 +32,19 @@ function ResetPassword() {
|
|||
return (
|
||||
<div className="flex min-h-screen flex-col items-center justify-center bg-white pt-6 sm:pt-0">
|
||||
<div className="mt-6 w-96 overflow-hidden bg-white px-6 py-4 sm:max-w-md sm:rounded-lg">
|
||||
<h1 className="mb-4 text-center text-3xl font-semibold">Password Reset Success</h1>
|
||||
<h1 className="mb-4 text-center text-3xl font-semibold">{localize(lang, 'com_auth_reset_password_success')}</h1>
|
||||
<div
|
||||
className="relative mb-8 mt-4 rounded border border-green-400 bg-green-100 px-4 py-3 text-center text-green-700"
|
||||
role="alert"
|
||||
>
|
||||
You may now login with your new password.
|
||||
{localize(lang, 'com_auth_login_with_new_password')}
|
||||
</div>
|
||||
<button
|
||||
onClick={() => navigate('/login')}
|
||||
aria-label="Sign in"
|
||||
aria-label={localize(lang, 'com_auth_sign_in')}
|
||||
className="w-full transform rounded-sm bg-green-500 px-4 py-3 tracking-wide text-white transition-colors duration-200 hover:bg-green-600 focus:bg-green-600 focus:outline-none"
|
||||
>
|
||||
Continue
|
||||
{localize(lang, 'com_auth_continue')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -49,17 +53,17 @@ function ResetPassword() {
|
|||
return (
|
||||
<div className="flex min-h-screen flex-col items-center justify-center bg-white pt-6 sm:pt-0">
|
||||
<div className="mt-6 w-96 overflow-hidden bg-white px-6 py-4 sm:max-w-md sm:rounded-lg">
|
||||
<h1 className="mb-4 text-center text-3xl font-semibold">Reset your password</h1>
|
||||
<h1 className="mb-4 text-center text-3xl font-semibold">{localize(lang, 'com_auth_reset_password')}</h1>
|
||||
{resetError && (
|
||||
<div
|
||||
className="relative mt-4 rounded border border-red-400 bg-red-100 px-4 py-3 text-red-700"
|
||||
role="alert"
|
||||
>
|
||||
This password reset token is no longer valid.{' '}
|
||||
{localize(lang, 'com_auth_error_invalid_reset_token')}{' '}
|
||||
<a className="font-semibold text-green-600 hover:underline" href="/forgot-password">
|
||||
Click here
|
||||
{localize(lang, 'com_auth_click_here')}
|
||||
</a>{' '}
|
||||
to try again.
|
||||
{localize(lang, 'com_auth_to_try_again')}
|
||||
</div>
|
||||
)}
|
||||
<form
|
||||
|
|
@ -88,16 +92,16 @@ function ResetPassword() {
|
|||
type="password"
|
||||
id="password"
|
||||
autoComplete="current-password"
|
||||
aria-label="Password"
|
||||
aria-label={localize(lang, 'com_auth_password')}
|
||||
{...register('password', {
|
||||
required: 'Password is required',
|
||||
required: localize(lang, 'com_auth_password_required'),
|
||||
minLength: {
|
||||
value: 8,
|
||||
message: 'Password must be at least 8 characters'
|
||||
message: localize(lang, 'com_auth_password_min_length')
|
||||
},
|
||||
maxLength: {
|
||||
value: 128,
|
||||
message: 'Password must be 128 characters or less'
|
||||
message: localize(lang, 'com_auth_password_max_length')
|
||||
}
|
||||
})}
|
||||
aria-invalid={!!errors.password}
|
||||
|
|
@ -108,7 +112,7 @@ function ResetPassword() {
|
|||
htmlFor="password"
|
||||
className="absolute left-2.5 top-4 z-10 origin-[0] -translate-y-4 scale-75 transform text-sm text-gray-500 duration-300 peer-placeholder-shown:translate-y-0 peer-placeholder-shown:scale-100 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:text-green-500"
|
||||
>
|
||||
Password
|
||||
{localize(lang, 'com_auth_password')}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
|
@ -124,14 +128,14 @@ function ResetPassword() {
|
|||
<input
|
||||
type="password"
|
||||
id="confirm_password"
|
||||
aria-label="Confirm Password"
|
||||
aria-label={localize(lang, 'com_auth_password_confirm')}
|
||||
// uncomment to prevent pasting in confirm field
|
||||
onPaste={(e) => {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}}
|
||||
{...register('confirm_password', {
|
||||
validate: (value) => value === password || 'Passwords do not match'
|
||||
validate: (value) => value === password || localize(lang, 'com_auth_password_not_match')
|
||||
})}
|
||||
aria-invalid={!!errors.confirm_password}
|
||||
className="peer block w-full appearance-none rounded-t-md border-0 border-b-2 border-gray-300 bg-gray-50 px-2.5 pb-2.5 pt-5 text-sm text-gray-900 focus:border-green-500 focus:outline-none focus:ring-0"
|
||||
|
|
@ -141,7 +145,7 @@ function ResetPassword() {
|
|||
htmlFor="confirm_password"
|
||||
className="absolute left-2.5 top-4 z-10 origin-[0] -translate-y-4 scale-75 transform text-sm text-gray-500 duration-300 peer-placeholder-shown:translate-y-0 peer-placeholder-shown:scale-100 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:text-green-500"
|
||||
>
|
||||
Confirm Password
|
||||
{localize(lang, 'com_auth_password_confirm')}
|
||||
</label>
|
||||
</div>
|
||||
{errors.confirm_password && (
|
||||
|
|
@ -167,10 +171,10 @@ function ResetPassword() {
|
|||
<button
|
||||
disabled={!!errors.password || !!errors.confirm_password}
|
||||
type="submit"
|
||||
aria-label="Submit registration"
|
||||
aria-label={localize(lang, 'com_auth_submit_registration')}
|
||||
className="w-full transform rounded-sm bg-green-500 px-4 py-3 tracking-wide text-white transition-colors duration-200 hover:bg-green-600 focus:bg-green-600 focus:outline-none"
|
||||
>
|
||||
Continue
|
||||
{localize(lang, 'com_auth_continue')}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue