-
Notifications
You must be signed in to change notification settings - Fork 834
feat: Add Global Form Auto-Localization demo to community #1889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sumitsaurabh927
merged 9 commits into
lingodotdev:main
from
saeedsaiyed01:feat/lingo-global-forms
Jan 30, 2026
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
79b5481
feat: Add Global Form Auto-Localization demo to community
saeedsaiyed01 e3211d5
chore: add changeset for community demo
saeedsaiyed01 6349eda
Merge branch 'main' into feat/lingo-global-forms
sumitsaurabh927 ab807d0
Merge branch 'main' into feat/lingo-global-forms
sumitsaurabh927 dc1cf05
Merge branch 'main' into feat/lingo-global-forms
sumitsaurabh927 b82a219
chore: replace with empty changeset
saeedsaiyed01 1c09a30
refactor(lingo-global-forms) Fixes CodeRabbit lint issues:
saeedsaiyed01 959bf03
Merge branch 'main' into feat/lingo-global-forms
sumitsaurabh927 f39ad5d
Merge branch 'main' into feat/lingo-global-forms
sumitsaurabh927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "docs": patch | ||
| --- | ||
|
|
||
| Add global form auto-localization community demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_LINGO_API_KEY=your_lingo_api_key_here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| module.exports = { | ||
| root: true, | ||
| env: { browser: true, es2020: true }, | ||
| extends: [ | ||
| 'eslint:recommended', | ||
| 'plugin:@typescript-eslint/recommended', | ||
| 'plugin:react-hooks/recommended', | ||
| ], | ||
| ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
| parser: '@typescript-eslint/parser', | ||
| plugins: ['react-refresh'], | ||
| rules: { | ||
| 'react-refresh/only-export-components': [ | ||
| 'warn', | ||
| { allowConstantExport: true }, | ||
| ], | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
| lerna-debug.log* | ||
|
|
||
| # Diagnostic reports (https://nodejs.org/api/report.html) | ||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
| *.lcov | ||
|
|
||
| # nyc test coverage | ||
| .nyc_output | ||
|
|
||
| # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
|
|
||
| # Bower dependency directory (https://bower.io/) | ||
| bower_components | ||
|
|
||
| # node-waf configuration | ||
| .lock-wscript | ||
|
|
||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||
| build/Release | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
|
|
||
| # TypeScript v1 declaration files | ||
| typings/ | ||
|
|
||
| # TypeScript cache | ||
| *.tsbuildinfo | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # Microbundle cache | ||
| .rpt2_cache/ | ||
| .rts2_cache_cjs/ | ||
| .rts2_cache_es/ | ||
| .rts2_cache_umd/ | ||
|
|
||
| # Optional REPL history | ||
| .node_repl_history | ||
|
|
||
| # Output of 'npm pack' | ||
| *.tgz | ||
|
|
||
| # Yarn Integrity file | ||
| .yarn-integrity | ||
|
|
||
| # dotenv environment variables file | ||
| .env | ||
| .env.test | ||
|
|
||
| # parcel-bundler cache (https://parceljs.org/) | ||
| .cache | ||
| .parcel-cache | ||
|
|
||
| # Next.js build output | ||
| .next | ||
| out | ||
|
|
||
| # Nuxt.js build / generate output | ||
| .nuxt | ||
| dist | ||
|
|
||
| # Gatsby files | ||
| .cache/ | ||
| # Comment in the public line in if your project uses Gatsby and not Next.js | ||
| # public | ||
|
|
||
| # vuepress build output | ||
| .vuepress/dist | ||
|
|
||
| # Serverless directories | ||
| .serverless/ | ||
|
|
||
| # FuseBox cache | ||
| .fusebox/ | ||
|
|
||
| # DynamoDB Local files | ||
| .dynamodb/ | ||
|
|
||
| # TernJS port file | ||
| .tern-port | ||
|
|
||
| # Stores VSCode versions used for testing VSCode extensions | ||
| .vscode-test | ||
|
|
||
| # yarn v2 | ||
| .yarn/cache | ||
| .yarn/unplugged | ||
| .yarn/build-state.yml | ||
| .yarn/install-state.gz | ||
| .pnp.* | ||
|
|
||
| # IntelliJ | ||
| .idea | ||
|
|
||
| # VSCode | ||
| .vscode | ||
| *.code-workspace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| # π Global Form Auto-Localization | ||
|
|
||
| A demo showcasing **Lingo.dev's** structured object translation for automatic form localization. | ||
|
|
||
|  | ||
|
|
||
| ## Demo | ||
|
|
||
| ### [π₯ Watch the Demo Video](./public/demo-video.mp4) | ||
| *(Click to play)* | ||
|
|
||
| ## What This App Does | ||
|
|
||
| This demo demonstrates a real-world use case: **writing a form once in English and automatically localizing it into multiple languages** using Lingo.dev's SDK. | ||
|
|
||
| Instead of translating plain text, this app translates **structured form content**: | ||
|
|
||
| - Form title and description | ||
| - Field labels | ||
| - Input placeholders | ||
| - Helper text | ||
| - Validation error messages | ||
| - Submit button text | ||
| - **Supported Field Types**: Text, TextArea, Radio Groups, Checkboxes, Dropdowns (Select), Date inputs | ||
| - **Option Translation**: Automatically translates options for choice-based fields | ||
|
|
||
| ## Why This Use Case Matters | ||
|
|
||
| Forms are everywhere in web applicationsβcontact forms, registration flows, checkout pages, surveys. Traditionally, localizing forms requires: | ||
|
|
||
| 1. Extracting all strings into translation files | ||
| 2. Managing keys for every field property | ||
| 3. Coordinating with translators for each language | ||
| 4. Keeping translations in sync as forms evolve | ||
|
|
||
| With Lingo.dev, you can **skip the complexity**. Just pass your form structure to the API, and get back a perfectly translated formβinstantly. | ||
|
|
||
| ## Lingo.dev Features Demonstrated | ||
|
|
||
| | Feature | Description | | ||
| |---------|-------------| | ||
| | **`localizeObject()`** | Translates structured JavaScript objects while preserving structure | | ||
| | **Multi-language Support** | Supports EN, ES, FR, DE, HI (easily extensible) | | ||
| | **Structured Translation** | Translates nested form properties, not just flat strings | | ||
| | **API Key Authentication** | Secure API key configuration via environment variables | | ||
|
|
||
| ## How to Run Locally | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Node.js 18+ installed | ||
| - A [Lingo.dev](https://lingo.dev) API key | ||
|
|
||
| ### Step-by-Step Setup | ||
|
|
||
| 1. **Navigate to the demo directory:** | ||
|
|
||
| ```bash | ||
| cd community/lingo-global-forms | ||
| ``` | ||
|
|
||
| 2. **Install dependencies:** | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| 3. **Configure your API key:** | ||
|
|
||
| Create a `.env` file in the project root: | ||
|
|
||
| ```bash | ||
| cp .env.example .env | ||
| ``` | ||
|
|
||
| Then edit `.env` and add your Lingo.dev API key: | ||
|
|
||
| ``` | ||
| VITE_LINGO_API_KEY=your_actual_api_key_here | ||
| ``` | ||
|
|
||
| > π‘ Get your API key at [lingo.dev](https://lingo.dev) | ||
|
|
||
| 4. **Start the development server:** | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| 5. **Open your browser:** | ||
|
|
||
| Navigate to [http://localhost:3000](http://localhost:3000) | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. **Edit the form** in the left panelβchange labels, placeholders, error messages | ||
| 2. **Select a language** from the dropdown in the preview panel | ||
| 3. **Watch the form translate** automatically | ||
| 4. **Submit the form** with empty required fields to see translated validation errors | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| lingo-global-forms/ | ||
| βββ src/ | ||
| β βββ components/ | ||
| β β βββ FormBuilder.tsx # Form editing panel | ||
| β β βββ FormPreview.tsx # Live preview with validation | ||
| β β βββ LanguageSelect.tsx # Language dropdown | ||
| β βββ lib/ | ||
| β β βββ lingo.ts # Lingo.dev SDK initialization | ||
| β β βββ translateForm.ts # Translation logic with caching | ||
| β βββ types/ | ||
| β β βββ form.ts # TypeScript interfaces | ||
| β βββ App.tsx # Main application | ||
| β βββ main.tsx # Entry point | ||
| β βββ index.css # Styles | ||
| βββ .env.example # Environment variable template | ||
| βββ package.json | ||
| βββ README.md | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| | Variable | Description | Required | | ||
| |----------|-------------|----------| | ||
| | `VITE_LINGO_API_KEY` | Your Lingo.dev API key | Yes | | ||
|
|
||
| ## License | ||
|
|
||
| This project is part of the [Lingo.dev](https://github.com/lingodotdev/lingo.dev) community contributions and is licensed under the Apache-2.0 license. | ||
|
|
||
| --- | ||
|
|
||
| Built with β€οΈ by the community for [Lingo.dev](https://lingo.dev) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <meta name="description" content="Global Form Auto-Localization demo using Lingo.dev - translate form content instantly" /> | ||
| <title>Global Form Localizer | Lingo.dev Demo</title> | ||
| <link rel="preconnect" href="https://fonts.googleapis.com"> | ||
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saeedsaiyed01 there's no need for a patch (it will bump the package version/trigger an NPM release).
Can you please update it to an empty changeset.
Just remove this file and run:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have solved all the missing pieces
have a look @sumitsaurabh927