Skip to content

Conversation

@Vidhan-59
Copy link

No description provided.

Copy link
Contributor

Copilot AI left a 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.

Comment on lines +135 to +145
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 };
};
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +276 to +283
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);
};
Copy link

Copilot AI Nov 12, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +62
nodeIntegration: true,
contextIsolation: false,
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
nodeIntegration: true,
contextIsolation: false,
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js'), // Expose safe APIs via contextBridge in preload.js

Copilot uses AI. Check for mistakes.
Comment on lines +378 to +379
"dev:main": "NODE_ENV=development webpack --config webpack.config.js --watch",
"build": "NODE_ENV=production webpack --config webpack.config.js",
Copy link

Copilot AI Nov 12, 2025

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".

Copilot uses AI. Check for mistakes.
height: 600,
webPreferences: {
preload: path.join(__dirname, '../renderer/preload.js'),
contextIsolation: true,
Copy link

Copilot AI Nov 12, 2025

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.

Copilot uses AI. Check for mistakes.
@sumitsaurabh927
Copy link
Contributor

same here as well @Vidhan-59
please go through the comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants