Skip to content

Commit

Permalink
chore: Translation Fixes, Lint Error Corrections, and Additional Tran…
Browse files Browse the repository at this point in the history
…slations (danny-avila#788)

* fix translation and small lint error

* changed from localize to useLocalize hook

* changed to useLocalize
  • Loading branch information
berry-13 authored Aug 14, 2023
1 parent b64cc71 commit 74802dd
Show file tree
Hide file tree
Showing 26 changed files with 421 additions and 421 deletions.
2 changes: 0 additions & 2 deletions api/server/routes/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,13 @@ router.get('/', async function (req, res) {
key = require('../../data/auth.json');
} catch (e) {
if (i === 0) {
console.log('No \'auth.json\' file (service account key) found in /api/data/ for PaLM models');
i++;
}
}

if (process.env.PALM_KEY === 'user_provided') {
palmUser = true;
if (i <= 1) {
console.log('User will provide key for PaLM models');
i++;
}
}
Expand Down
22 changes: 9 additions & 13 deletions client/src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ import React, { useEffect } from 'react';
import LoginForm from './LoginForm';
import { useAuthContext } from '~/hooks/AuthContext';
import { useNavigate } from 'react-router-dom';

import { useRecoilValue } from 'recoil';
import store from '~/store';
import { localize } from '~/localization/Translation';
import { useLocalize } from '~/hooks';
import { useGetStartupConfig } from 'librechat-data-provider';
import { GoogleIcon, OpenIDIcon, GithubIcon, DiscordIcon } from '~/components';

function Login() {
const { login, error, isAuthenticated } = useAuthContext();
const { data: startupConfig } = useGetStartupConfig();

const lang = useRecoilValue(store.lang);
const localize = useLocalize();

const navigate = useNavigate();

Expand All @@ -27,23 +23,23 @@ function Login() {
<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">
{localize(lang, 'com_auth_welcome_back')}
{localize('com_auth_welcome_back')}
</h1>
{error && (
<div
className="relative mt-4 rounded border border-red-400 bg-red-100 px-4 py-3 text-red-700"
role="alert"
>
{localize(lang, 'com_auth_error_login')}
{localize('com_auth_error_login')}
</div>
)}
<LoginForm onSubmit={login} />
{startupConfig?.registrationEnabled && (
<p className="my-4 text-center text-sm font-light text-gray-700">
{' '}
{localize(lang, 'com_auth_no_account')}{' '}
{localize('com_auth_no_account')}{' '}
<a href="/register" className="p-1 text-green-500 hover:underline">
{localize(lang, 'com_auth_sign_up')}
{localize('com_auth_sign_up')}
</a>
</p>
)}
Expand All @@ -64,7 +60,7 @@ function Login() {
href={`${startupConfig.serverDomain}/oauth/google`}
>
<GoogleIcon />
<p>{localize(lang, 'com_auth_google_login')}</p>
<p>{localize('com_auth_google_login')}</p>
</a>
</div>
</>
Expand Down Expand Up @@ -96,7 +92,7 @@ function Login() {
href={`${startupConfig.serverDomain}/oauth/github`}
>
<GithubIcon />
<p>{localize(lang, 'com_auth_github_login')}</p>
<p>{localize('com_auth_github_login')}</p>
</a>
</div>
</>
Expand All @@ -110,7 +106,7 @@ function Login() {
href={`${startupConfig.serverDomain}/oauth/discord`}
>
<DiscordIcon />
<p>{localize(lang, 'com_auth_discord_login')}</p>
<p>{localize('com_auth_discord_login')}</p>
</a>
</div>
</>
Expand Down
32 changes: 15 additions & 17 deletions client/src/components/Auth/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { useForm } from 'react-hook-form';
import { useRecoilValue } from 'recoil';
import store from '~/store';
import { localize } from '~/localization/Translation';
import { useLocalize } from '~/hooks';
import { TLoginUser } from 'librechat-data-provider';

type TLoginFormProps = {
onSubmit: (data: TLoginUser) => void;
};

function LoginForm({ onSubmit }: TLoginFormProps) {
const lang = useRecoilValue(store.lang);
const localize = useLocalize();

const {
register,
Expand All @@ -30,20 +28,20 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
type="text"
id="email"
autoComplete="email"
aria-label={localize(lang, 'com_auth_email')}
aria-label={localize('com_auth_email')}
{...register('email', {
required: localize(lang, 'com_auth_email_required'),
required: localize('com_auth_email_required'),
minLength: {
value: 3,
message: localize(lang, 'com_auth_email_min_length'),
message: localize('com_auth_email_min_length'),
},
maxLength: {
value: 120,
message: localize(lang, 'com_auth_email_max_length'),
message: localize('com_auth_email_max_length'),
},
pattern: {
value: /\S+@\S+\.\S+/,
message: localize(lang, 'com_auth_email_pattern'),
message: localize('com_auth_email_pattern'),
},
})}
aria-invalid={!!errors.email}
Expand All @@ -54,7 +52,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
htmlFor="email"
className="absolute left-2.5 top-4 z-10 origin-[0] -translate-y-4 scale-75 transform 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"
>
{localize(lang, 'com_auth_email_address')}
{localize('com_auth_email_address')}
</label>
</div>
{errors.email && (
Expand All @@ -70,16 +68,16 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
type="password"
id="password"
autoComplete="current-password"
aria-label={localize(lang, 'com_auth_password')}
aria-label={localize('com_auth_password')}
{...register('password', {
required: localize(lang, 'com_auth_password_required'),
required: localize('com_auth_password_required'),
minLength: {
value: 8,
message: localize(lang, 'com_auth_password_min_length'),
message: localize('com_auth_password_min_length'),
},
maxLength: {
value: 40,
message: localize(lang, 'com_auth_password_max_length'),
message: localize('com_auth_password_max_length'),
},
})}
aria-invalid={!!errors.password}
Expand All @@ -90,7 +88,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
htmlFor="password"
className="absolute left-2.5 top-4 z-10 origin-[0] -translate-y-4 scale-75 transform 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"
>
{localize(lang, 'com_auth_password')}
{localize('com_auth_password')}
</label>
</div>

Expand All @@ -102,7 +100,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
)}
</div>
<a href="/forgot-password" className="text-sm text-green-500 hover:underline">
{localize(lang, 'com_auth_password_forgot')}
{localize('com_auth_password_forgot')}
</a>
<div className="mt-6">
<button
Expand All @@ -111,7 +109,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
type="submit"
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"
>
{localize(lang, 'com_auth_continue')}
{localize('com_auth_continue')}
</button>
</div>
</form>
Expand Down
Loading

0 comments on commit 74802dd

Please sign in to comment.