SurfSense/surfsense_web
Differ f58c7e4602 feat(i18n): Add next-intl framework with full bilingual support (EN/ZH)
- Implement next-intl framework for scalable i18n
- Add complete Chinese (Simplified) localization
- Support 400+ translated strings across all pages
- Add language switcher with persistent preference
- Zero breaking changes to existing functionality

Framework additions:
- i18n routing and middleware
- LocaleContext for client-side state
- LanguageSwitcher component
- Translation files (en.json, zh.json)

Translated components:
- Homepage: Hero, features, CTA, navbar
- Auth: Login, register
- Dashboard: Main page, layout
- Connectors: Management, add page (all categories)
- Documents: Upload, manage, filters
- Settings: LLM configs, role assignments
- Onboarding: Add provider, assign roles
- Logs: Task logs viewer

Adding a new language now requires only:
1. Create messages/<locale>.json
2. Add locale to i18n/routing.ts
2025-10-26 17:18:57 +08:00
..
.vscode Initial formatting using biome 2025-07-27 10:05:37 -07:00
app feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
components feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
content/docs feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
contexts feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
contracts/enums Merge remote-tracking branch 'upstream/main' into feature/elasticsearch-connector 2025-10-17 01:02:29 +05:30
hooks feat: added periodic tasks in backend db and frontend hooks 2025-10-22 16:14:25 -07:00
i18n feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
lib Merge remote-tracking branch 'upstream/main' into feature/elasticsearch-connector 2025-10-16 16:24:37 +05:30
messages feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
public feat: updated homepage and pricing 2025-10-02 18:10:07 -07:00
.cursorrules feat: monorepo 2025-04-07 23:47:06 -07:00
.dockerignore feat: frontend docker to use nextjs production build 2025-10-23 20:37:01 -07:00
.env.example remove github repo & owner env variables 2025-10-19 23:25:23 +02:00
.gitignore feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
biome.json Added config for biome.js 2025-07-26 20:52:13 -07:00
components.json Initial formatting using biome 2025-07-27 10:05:37 -07:00
Dockerfile feat: frontend docker to use nextjs production build 2025-10-23 20:37:01 -07:00
drizzle.config.ts chore: biome checks 2025-10-15 14:38:26 -07:00
eslint.config.mjs Biome: fixes for eslint config 2025-07-27 11:47:38 -07:00
LICENSE feat: monorepo 2025-04-07 23:47:06 -07:00
mdx-components.tsx Initial formatting using biome 2025-07-27 10:05:37 -07:00
middleware.ts feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
next.config.ts feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
package-lock.json feat: monorepo 2025-04-07 23:47:06 -07:00
package.json feat(i18n): Add next-intl framework with full bilingual support (EN/ZH) 2025-10-26 17:18:57 +08:00
pnpm-lock.yaml feat: added elasticsearch connector 2025-10-12 09:39:04 +05:30
postcss.config.mjs Initial formatting using biome 2025-07-27 10:05:37 -07:00
README.md feat: monorepo 2025-04-07 23:47:06 -07:00
source.config.ts Initial formatting using biome 2025-07-27 10:05:37 -07:00
tailwind.config.js Initial formatting using biome 2025-07-27 10:05:37 -07:00
tsconfig.json Initial formatting using biome 2025-07-27 10:05:37 -07:00

Next.js Token Handler Component

This project includes a reusable client component for Next.js that handles token storage from URL parameters.

TokenHandler Component

The TokenHandler component is designed to:

  1. Extract a token from URL parameters
  2. Store the token in localStorage
  3. Redirect the user to a specified path

Usage

import TokenHandler from '@/components/TokenHandler';

export default function AuthCallbackPage() {
  return (
    <div>
      <h1>Authentication Callback</h1>
      <TokenHandler 
        redirectPath="/dashboard" 
        tokenParamName="token" 
        storageKey="auth_token" 
      />
    </div>
  );
}

Props

The component accepts the following props:

  • redirectPath (optional): Path to redirect after storing token (default: '/')
  • tokenParamName (optional): Name of the URL parameter containing the token (default: 'token')
  • storageKey (optional): Key to use when storing in localStorage (default: 'auth_token')

Example URL

After authentication, redirect users to:

https://your-domain.com/auth/callback?token=your-auth-token

Implementation Details

  • Uses Next.js's useSearchParams hook to access URL parameters
  • Uses useRouter for client-side navigation after token storage
  • Includes error handling for localStorage operations
  • Displays a loading message while processing

Security Considerations

  • This implementation assumes the token is passed securely
  • Consider using HTTPS to prevent token interception
  • For enhanced security, consider using HTTP-only cookies instead of localStorage
  • The token in the URL might be visible in browser history and server logs

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.