Skip to content

Commit e605b20

Browse files
feat: Add LingoLens App for Community Sprint (#1922)
* Lingo-lens * Unwanted Folder Created * Advance Features Added * test: verification * Testing * Going to re add Lingo-lens * Lingo-lens * feat: add changeset for LingoLens * coderabbit feedback * Env Variable changed * fix(community/lingo-lens): resolve PR feedback and add changeset * fix(community/lingo-lens): resolve PR feedback and add changeset * fix(community/lingo-lens): resolve PR feedback and add changeset * fix(community/lingo-lens): address reviewer feedback on README and upload logic * fix(community/lingo-lens): address reviewer feedback on README and upload logic * fix(community/lingo-lens): address reviewer feedback on README * fix: improve translation accuracy and resolve local linting issues - pass detected ocrLang to translation service for better performance - add biome-ignore directives to index.css for Tailwind at-rules - update changeset to be empty as requested by maintainers --------- Co-authored-by: Sumit Saurabh <62152915+sumitsaurabh927@users.noreply.github.com>
1 parent 38bd11c commit e605b20

File tree

22 files changed

+21854
-0
lines changed

22 files changed

+21854
-0
lines changed

.changeset/busy-bars-leave.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

community/Lingo-lens/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
.env

community/Lingo-lens/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# LingoLens 📸
2+
3+
**LingoLens** is a powerful **AI Visual Translator** built for the **Lingo.dev Community Sprint**.
4+
5+
It upgrades standard OCR with **Intelligent Script Detection** and **Lingo.dev's AI Language Inference**. Wrapped in a stunning **Glassmorphism UI**, it allows users to upload images of text (receipts, signs, documents) and automatically detects the language script and translation context in real-time.
6+
7+
## 🎥 Demo & Testing
8+
We have provided resources to help you test the application quickly:
9+
10+
### 1. Watch the Demo
11+
> **[Click here to watch the Demo Video on YouTube 📺](https://youtu.be/ZJFpRb-49eE)**
12+
13+
### 2. Test with Sample Data
14+
I have included a sample receipt image in this repository for you to test with:
15+
* **File:** [`test.png`](./test.png)
16+
* **Usage:** Drag and drop this image into the app to see the Auto-Detection and Translation in action immediately.
17+
18+
## 🚀 Lingo.dev Features Highlighted
19+
This project demonstrates key capabilities of the Lingo.dev ecosystem:
20+
1. **AI Language Inference:** Uses the `sourceLocale: null` feature of the **Lingo.dev SDK** to automatically identify the source language from the text context.
21+
2. **Smart Script Detection:** Implements **Tesseract OSD** (Orientation & Script Detection) to dynamically load the correct OCR alphabet (e.g., Japanese vs. Latin) before reading.
22+
3. **Real-time Localization:** Uses `lingo.localizeText` to provide accurate, context-aware translations for dynamic user content.
23+
4. **Secure Backend Proxy:** Implements a robust Node.js/Express bridge (`server.js`) to handle API authentication securely.
24+
25+
## 🛠️ Setup Instructions
26+
27+
### Prerequisites
28+
* Node.js (v18 or higher)
29+
* A Lingo.dev API Key
30+
31+
### 1. Installation
32+
Navigate to the project directory and install dependencies:
33+
```bash
34+
cd community/Lingo-lens
35+
npm install
36+
```
37+
38+
### 2. Configuration
39+
Create a .env file in the root of the Lingo-lens directory and add your API key:
40+
```bash
41+
LINGO_API_KEY=link_your_actual_api_key_here
42+
```
43+
44+
### 3. Running the App
45+
46+
This application requires **both the backend server** (to communicate with Lingo.dev) and the **frontend client** (React) to run simultaneously.
47+
48+
---
49+
50+
### Terminal 1 — Backend Server
51+
52+
```bash
53+
node server.js
54+
```
55+
56+
You should see: `✅ Proxy Server running on http://localhost:3001`
57+
58+
59+
### Terminal 2 — Frontend Client
60+
61+
```bash
62+
npm run dev
63+
```
64+
65+
Open the URL shown in the terminal: `(usually: http://localhost:5173)`
66+
67+
## 📖 How It Works
68+
69+
1. **Upload & Detect** User uploads an image. The app first runs **Tesseract OSD** to detect the script (e.g., "Han" for Chinese, "Latin" for English).
70+
71+
2. **Extract (OCR)** Based on the script, the app loads the optimized OCR model (e.g., `chi_sim` or `eng`) and extracts the raw text from the image.
72+
73+
3. **Inference** The frontend sends the text to the server with `sourceLang: 'auto'`.
74+
75+
4. **Translate** The **Lingo.dev SDK** analyzes the text content, infers the source language, and generates a context-aware translation.
76+
77+
5. **Result** The original text and the translation appear instantly on the animated Glassmorphism interface.
78+
79+

community/Lingo-lens/demo.mp4

19.5 MB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import { defineConfig, globalIgnores } from 'eslint/config'
6+
7+
export default defineConfig([
8+
globalIgnores(['dist']),
9+
{
10+
files: ['**/*.{js,jsx}'],
11+
extends: [
12+
js.configs.recommended,
13+
reactHooks.configs.flat.recommended,
14+
reactRefresh.configs.vite,
15+
],
16+
languageOptions: {
17+
ecmaVersion: 2020,
18+
globals: globals.browser,
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
ecmaFeatures: { jsx: true },
22+
sourceType: 'module',
23+
},
24+
},
25+
rules: {
26+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
27+
},
28+
},
29+
])

community/Lingo-lens/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>lingo-lens</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)