-
Notifications
You must be signed in to change notification settings - Fork 663
Docs/lingodev cli electron integration #1485
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
base: main
Are you sure you want to change the base?
Docs/lingodev cli electron integration #1485
Conversation
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.
Pull Request Overview
This PR adds comprehensive integration guides for using Lingo.dev CLI with desktop application frameworks Tauri and Electron. The guides walk developers through setting up multilingual applications using React and react-intl for internationalization.
Key Changes:
- Added Tauri integration guide with step-by-step setup for building multilingual desktop apps
- Added Electron integration guide with webpack configuration and IPC-based locale detection
- Both guides include code examples for IntlProvider setup, language switching, and continuous localization workflow
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tauri-integration-guide.md | Complete integration guide for Tauri desktop applications with Lingo.dev CLI, including React/TypeScript setup, locale detection, and optional language switcher component |
| electron-integration-guide.md | Comprehensive Electron integration guide covering webpack configuration, security considerations with IPC, and advanced locale detection using Electron's main process |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const useChangeLocale = () => { | ||
| const [locale, setLocale] = useState<string>('en'); | ||
|
|
||
| const changeLocale = async (newLocale: string) => { | ||
| const messages = await loadMessages(newLocale); | ||
| setLocale(newLocale); | ||
| return messages; | ||
| }; | ||
|
|
||
| return { locale, changeLocale }; | ||
| }; |
Copilot
AI
Nov 12, 2025
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.
The useChangeLocale hook is defined but never used in the guide. It maintains its own separate locale state that is not connected to the IntlProvider's locale state, making it non-functional. Consider removing this unused hook or updating the guide to demonstrate how to properly use it with a context pattern.
| export const useChangeLocale = () => { | |
| const [locale, setLocale] = useState<string>('en'); | |
| const changeLocale = async (newLocale: string) => { | |
| const messages = await loadMessages(newLocale); | |
| setLocale(newLocale); | |
| return messages; | |
| }; | |
| return { locale, changeLocale }; | |
| }; |
| const handleChange = async (newLocale: string) => { | ||
| setLocale(newLocale); | ||
| // Reload the page to apply new locale | ||
| window.location.reload(); | ||
|
|
||
| // Store preference for next session | ||
| localStorage.setItem('locale', newLocale); | ||
| }; |
Copilot
AI
Nov 12, 2025
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.
The LanguageSwitcher component maintains its own local locale state that is not synchronized with the IntlProvider's locale state. When a user selects a language, it updates local state and stores it in localStorage, but the page reload doesn't properly trigger the locale change since the IntlProvider only reads localStorage once on mount. This creates a race condition where the locale may not be properly applied after reload. Consider using a context-based approach where the locale state is managed by the IntlProvider instead.
| nodeIntegration: true, | ||
| contextIsolation: false, |
Copilot
AI
Nov 12, 2025
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.
Setting nodeIntegration: true and contextIsolation: false creates significant security vulnerabilities by allowing renderer processes full access to Node.js APIs and system resources. This exposes the application to XSS attacks where malicious scripts can execute arbitrary code with Node.js privileges. Use contextIsolation: true with a preload script instead, as shown in the "Advanced: IPC for locale detection" section later in the guide.
| nodeIntegration: true, | |
| contextIsolation: false, | |
| nodeIntegration: false, | |
| contextIsolation: true, | |
| preload: path.join(__dirname, 'preload.js'), // Expose safe APIs via contextBridge in preload.js |
| "dev:main": "NODE_ENV=development webpack --config webpack.config.js --watch", | ||
| "build": "NODE_ENV=production webpack --config webpack.config.js", |
Copilot
AI
Nov 12, 2025
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.
The NODE_ENV environment variable setting uses Unix-style syntax that won't work on Windows. This will cause the build to fail for Windows developers. Use cross-env package to set environment variables in a cross-platform way: "dev:main": "cross-env NODE_ENV=development webpack --config webpack.config.js --watch" and "build": "cross-env NODE_ENV=production webpack --config webpack.config.js".
| height: 600, | ||
| webPreferences: { | ||
| preload: path.join(__dirname, '../renderer/preload.js'), | ||
| contextIsolation: true, |
Copilot
AI
Nov 12, 2025
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.
Changing from contextIsolation: false to contextIsolation: true in the advanced section is inconsistent with the initial setup in Step 2 (lines 61-62). This creates confusion as the earlier code examples that rely on nodeIntegration: true and contextIsolation: false won't work with this configuration. The guide should either use secure settings from the start or clearly indicate that this is a migration/update to the earlier code.
|
same here as well @Vidhan-59 |
No description provided.