LinguaLens is an intelligent translation assistant that supports bidirectional translation between Chinese and other languages. It adapts to different contexts and scenarios such as email, online meetings, technical support, and more. The tool intelligently selects the tone, formality, and style of the translation based on the chosen scene, ensuring accurate and contextually appropriate translations.
- Bidirectional Translation: Automatically translates Chinese to English and any non-Chinese language (e.g., English, French, German) to Chinese.
- Scene-based Context: Tailors translations based on the context of specific work-related scenarios like online meetings, emails, Teams chats, and technical support.
- Custom Scene Management: Create, edit, delete, and reorder your own custom translation scenes with a user-friendly interface. All custom scenes are saved in your browser's localStorage.
- Multilingual Support: Supports bidirectional translation between Chinese and a wide range of languages, including English, French, German, Dutch, Spanish, Indonesian, Thai, Vietnamese, Burmese, and Malay. Both the interface and translation engine support these languages.
- Internationalization: Implements full internationalization (i18n) with language switcher and locale-based routing. Supported interface and translation languages:
- 简体中文 (Chinese)
- English
- Deutsch (German)
- Français (French)
- Español (Spanish)
- Nederlands (Dutch)
- Bahasa Indonesia (Indonesian)
- ไทย (Thai)
- Tiếng Việt (Vietnamese)
- မြန်မာ (Burmese)
- Bahasa Melayu (Malay)
- Customizable User Interface: Easily switch between different scenes for translations, ensuring the tone and style fit the specific use case.
- User-Friendly Design: Built with Next.js and ShadCN UI, making the interface simple and intuitive.
- Supports Gemini 2.5 Flash Preview 04-17: You can choose the Gemini 2.5 Flash Preview 04-17 model, which provides excellent translation quality.
- Frontend: Next.js 15 (App Router)
- UI Components: Shadcn/UI
- State Management: Zustand (for lightweight state management and history tracking)
- AI Translation Service: Powered by Google Gemini or any other AI model, providing accurate translations based on the context and input language.
- Backend: API integration with AI services for streaming responses up to 30 seconds.
- CSS: Tailwind CSS for styling
- Language Detection: Automatically detects the language of input text and translates it to the appropriate target language.
- Language Detection: The AI detects the language of the input text. If the input is in Chinese, it translates it into English. If the input is in any other language (e.g., English, French, German), it translates it into Chinese.
- Scene Selection: Users can select the translation scene (e.g., Email, Online Meeting, Technical Support). The AI adjusts the tone and formality of the translation based on the selected scene.
- Custom Scene Creation: Users can create their own custom translation scenes by clicking the "自定义场景" (Custom Scene) button and using the scene management interface.
- Real-Time Translation: The translation process takes place in real-time, providing instant feedback for quick and accurate translations.
Below are the translation scenes I believe are most commonly used in the workplace:
- Daily Communication: Casual, friendly exchanges between colleagues or friends, using common vocabulary and simple grammar.
- Email: For professional business email communication.
- News Article: For translating news reports or informational articles. Maintains objectivity, neutrality, and accuracy.
- Word Explanation: For simple, memorable explanations and practical example sentences of a word or phrase, in both English and Chinese.
- Technical Documentation: For translating developer technical documentation or API references. Uses a professional tone, consistent terminology, and clear, structured presentation.
- Social Media Post (X/Reddit): For engaging posts on X (Twitter) or Reddit.
- Technical Support: For technical support communication in systems like TOPdesk, focusing on Salesforce, JavaScript, .NET, or SAP.
- Meeting Invitation: For formal meeting invitation messages.
- Requirement Discussion: For discussions about## Scenes
To run LinguaLens locally, follow these steps:
git clone https://github.com/neozhu/lingualens.git
cd lingualens
Use pnpm
or npm
to install the project dependencies.
pnpm install
# Or if you're using npm:
npm install
Create a .env.local
file in the root directory and add your environment-specific variables, such as API keys for the AI translation service.
Note: These API keys can be obtained for free by registering an account, or you can use a paid account if you need higher usage limits.
GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_key
GROQ_API_KEY=your_groq_api_key
OPENAI_API_KEY=<your API key>
MISTRAL_API_KEY=<your API key>
After setting up the environment variables, you can start the development server:
pnpm dev
# Or if you're using npm:
npm run dev
Visit http://localhost:3000
in your browser to access the app.
You can deploy LinguaLens using Docker for easy setup and consistent environments.
git pull
sudo docker build . -t lingualens:ver
Replace ver
with your desired version tag (e.g., v0.24
).
Below is an example docker-compose.yml
file for running LinguaLens:
version: '3.8'
services:
lingualens:
image: lingualens:v0.24
# Map external port 4010 to internal port 3000
ports:
- "4010:3000"
# Set environment variables
environment:
- NODE_ENV=production
- NEXT_PUBLIC_GA_ID=<your tag id>
- GROQ_API_KEY=<your api key>
- GOOGLE_GENERATIVE_AI_API_KEY=<your api key>
- OPENAI_API_KEY=<your API key>
- MISTRAL_API_KEY=<your API key>
restart: unless-stopped
sudo docker compose up -d
Visit http://localhost:4010
in your browser to access the app running in Docker.
- Select a Scene: Choose the context for the translation (e.g., Online Meeting, Email) or create your own custom scenes.
- Input Text: Type or paste the text you want to translate in either Chinese or another language.
- Receive Translation: The AI will process the translation and output the result in the target language (English for Chinese input, or Chinese for other language inputs).
The new custom scene management feature allows you to:
- Create Custom Scenes: Create your own translation scenes with specific prompts, names, and descriptions.
- Edit Existing Scenes: Modify any custom scene to fine-tune the translation style and context.
- Delete Scenes: Remove any custom scenes you no longer need.
- Reorder Scenes: Drag and drop to reorder your scenes according to your preference.
- Reset to Default: Return to the default set of scenes at any time.
All custom scenes are automatically saved in your browser's localStorage and will be available when you return to the application.
If you want to add support for more languages (for both translation and the interface), follow these steps:
- Add the locale code to the
locales
array inmiddleware.ts
and update the language switcher incomponents/language-switcher.tsx
. - Create a new translation file in the
messages/
directory, e.g.,messages/ja.json
for Japanese. Use the structure ofen.json
as a template and provide translations for all keys. - (Optional) Add scene prompt logic: If your new language requires special translation logic, update the prompt generation in
app/api/chat/route.ts
. - Restart the development server to apply the changes.
This will enable both UI and translation support for the new language.
We welcome contributions to LinguaLens! If you’d like to improve the project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a clear explanation of the changes.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the AI SDK for providing the AI services used in the project.
- Inspired by Shadcn/UI for building responsive and customizable UI components.
- Special thanks to the Google Gemini team for their AI-powered translation capabilities.