Skip to content
5 changes: 3 additions & 2 deletions apps/desktop/src/shared/constants/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Available languages and display labels
*/

export type SupportedLanguage = 'en' | 'fr';
export type SupportedLanguage = 'en' | 'fr' | 'zh';

export const AVAILABLE_LANGUAGES = [
{ value: 'en' as const, label: 'English', nativeLabel: 'English' },
{ value: 'fr' as const, label: 'French', nativeLabel: 'Français' }
{ value: 'fr' as const, label: 'French', nativeLabel: 'Français' },
{ value: 'zh' as const, label: 'Chinese', nativeLabel: '中文' }
Comment on lines +6 to +11
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check available Chinese spell check languages in Electron

# Search for Electron spell checker documentation or check the codebase
rg -n "availableSpellCheckerLanguages" -A 5 -B 5 --type=ts

# Also check if there are any existing references to Chinese language codes
rg -n "zh-CN|zh-TW|zh_CN|zh_TW" --type=ts

Repository: AndyMik90/Aperant

Length of output: 2193


🏁 Script executed:

# Check the current state of spellcheck.ts
cat -n apps/desktop/src/shared/constants/spellcheck.ts

Repository: AndyMik90/Aperant

Length of output: 1244


🏁 Script executed:

# Check the context menu behavior in index.ts around lines 303-310
sed -n '295,320p' apps/desktop/src/main/index.ts

Repository: AndyMik90/Aperant

Length of output: 1137


🏁 Script executed:

# Verify the fallback logic in index.ts around lines 269-276
sed -n '260,285p' apps/desktop/src/main/index.ts

Repository: AndyMik90/Aperant

Length of output: 1357


🏁 Script executed:

# Search for comments or documentation about spell checker language codes
rg -n "spell.*check.*lang|Chromium.*spell|availableSpellCheckerLanguages" -B 3 -A 3 --type=ts apps/desktop/src

Repository: AndyMik90/Aperant

Length of output: 9206


🏁 Script executed:

# Check if there are any tests or examples of SPELL_CHECK_LANGUAGE_MAP usage
rg -n "SPELL_CHECK_LANGUAGE_MAP" -B 2 -A 2 --type=ts apps/desktop/src

Repository: AndyMik90/Aperant

Length of output: 2872


🏁 Script executed:

# Check Electron version
cat apps/desktop/package.json | grep -A 2 -B 2 '"electron"'

Repository: AndyMik90/Aperant

Length of output: 212


🏁 Script executed:

# Search for any existing Chinese language references or comments
rg -n "Chinese|中文|zh-" --type=ts --type=json apps/desktop/src

Repository: AndyMik90/Aperant

Length of output: 250


🏁 Script executed:

# Check if there are any language code patterns or documentation in the codebase
rg -n "fr-FR|en-US|en-GB" --type=ts apps/desktop/src

Repository: AndyMik90/Aperant

Length of output: 2194


🌐 Web query:

Electron 40.0 Chromium spell checker available languages zh-CN zh-TW Chinese support

💡 Result:

In Electron 40.0.0 (based on Chromium 144.0.7559.60), the built-in spell checker supports Chinese (Simplified, zh-CN) and Chinese (Traditional, zh-TW) on Windows and Linux via Chromium's Hunspell dictionaries. These languages are part of Chromium's supported spellcheck languages, as Chromium's Hunspell dictionaries include support for numerous languages including zh-CN and zh-TW (evidenced by Chromium's deps/hunspell_dictionaries repo listing extensive language support and Chromium's general multilingual spellcheck capabilities). On macOS, it uses native APIs which automatically detect languages, including Chinese variants. To check available languages in code: webContents.session.availableSpellCheckerLanguages. To set: session.setSpellCheckerLanguages(['zh-CN', 'zh-TW']). Dictionaries are downloaded from Google's CDN by default.

Citations:


🏁 Script executed:

# Check if there are any TODOs or comments related to Chinese language or spell check
rg -n "TODO|FIXME|XXX" -i --type=ts apps/desktop/src/shared/constants/ | head -20

Repository: AndyMik90/Aperant

Length of output: 43


Add Chinese spell check mappings to complete language support.

Adding 'zh' to SupportedLanguage and AVAILABLE_LANGUAGES in apps/desktop/src/shared/constants/i18n.ts without corresponding entries in SPELL_CHECK_LANGUAGE_MAP and ADD_TO_DICTIONARY_LABELS in apps/desktop/src/shared/constants/spellcheck.ts leaves the feature incomplete.

When Chinese is selected:

  • Spell checker will silently fall back to English (via the SPELL_CHECK_LANGUAGE_MAP[language] || [DEFAULT_SPELL_CHECK_LANGUAGE] fallback in apps/desktop/src/main/ipc-handlers/settings-handlers.ts:858)
  • Context menu will display "Add to Dictionary" in English instead of Chinese (via the ADD_TO_DICTIONARY_LABELS[getAppLanguage()] || ADD_TO_DICTIONARY_LABELS['en'] fallback in apps/desktop/src/main/index.ts:305-306)
🛠️ Proposed fix - add Chinese spell check mappings

Add the following entries to apps/desktop/src/shared/constants/spellcheck.ts:

export const SPELL_CHECK_LANGUAGE_MAP: Record<string, string[]> = {
  en: ['en-US', 'en-GB'],
  fr: ['fr-FR', 'fr'],
  zh: ['zh-CN', 'zh-TW'],
};

export const ADD_TO_DICTIONARY_LABELS: Record<string, string> = {
  en: 'Add to Dictionary',
  fr: 'Ajouter au dictionnaire',
  zh: '添加到词典',
};

Both zh-CN and zh-TW are supported by Chromium's spell checker in Electron 40.0.0 on Windows, Linux, and macOS.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/desktop/src/shared/constants/i18n.ts` around lines 6 - 11, Add Chinese
mappings to the spellcheck constants so selecting 'zh' in SupportedLanguage /
AVAILABLE_LANGUAGES has proper spellchecker locales and localized UI; update
SPELL_CHECK_LANGUAGE_MAP to include a 'zh' key mapping to Chromium locales such
as 'zh-CN' and 'zh-TW' and add a 'zh' entry to ADD_TO_DICTIONARY_LABELS with the
Chinese label (e.g., "添加到词典") so lookups that use SPELL_CHECK_LANGUAGE_MAP and
ADD_TO_DICTIONARY_LABELS (and their fallbacks like DEFAULT_SPELL_CHECK_LANGUAGE
and getAppLanguage()) will return correct values when language is 'zh'.

] as const;

export const DEFAULT_LANGUAGE: SupportedLanguage = 'en';
26 changes: 26 additions & 0 deletions apps/desktop/src/shared/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ import frTaskReview from './locales/fr/taskReview.json';
import frTerminal from './locales/fr/terminal.json';
import frErrors from './locales/fr/errors.json';

// Import Chinese translation resources
import zhCommon from './locales/zh/common.json';
import zhNavigation from './locales/zh/navigation.json';
import zhSettings from './locales/zh/settings.json';
import zhTasks from './locales/zh/tasks.json';
import zhWelcome from './locales/zh/welcome.json';
import zhOnboarding from './locales/zh/onboarding.json';
import zhDialogs from './locales/zh/dialogs.json';
import zhGitlab from './locales/zh/gitlab.json';
import zhTaskReview from './locales/zh/taskReview.json';
import zhTerminal from './locales/zh/terminal.json';
import zhErrors from './locales/zh/errors.json';

export const defaultNS = 'common';

export const resources = {
Expand Down Expand Up @@ -55,6 +68,19 @@ export const resources = {
taskReview: frTaskReview,
terminal: frTerminal,
errors: frErrors
},
zh: {
common: zhCommon,
navigation: zhNavigation,
settings: zhSettings,
tasks: zhTasks,
welcome: zhWelcome,
onboarding: zhOnboarding,
dialogs: zhDialogs,
gitlab: zhGitlab,
taskReview: zhTaskReview,
terminal: zhTerminal,
errors: zhErrors
}
Comment on lines +74 to 84
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The new Chinese (zh) language is not added to the SupportedLanguage type and AVAILABLE_LANGUAGES constant, making it unavailable for selection in the UI.
Severity: HIGH

Suggested Fix

Update apps/desktop/src/shared/constants/i18n.ts. Add 'zh' to the SupportedLanguage type. Add a new object for the Chinese language to the AVAILABLE_LANGUAGES array, for example: { value: 'zh' as const, label: 'Chinese', nativeLabel: '中文' }.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: apps/desktop/src/shared/i18n/index.ts#L72-L84

Potential issue: The pull request adds Chinese (`zh`) translation resources but fails to
register the new language in `apps/desktop/src/shared/constants/i18n.ts`. Specifically,
the `SupportedLanguage` type is not updated to include `'zh'`, and the
`AVAILABLE_LANGUAGES` array is missing an entry for Chinese. As a result, the language
selector component will not render an option for Chinese, and the application's type
system will prevent the language from being set, rendering the new translations
inaccessible to users.

Did we get this right? 👍 / 👎 to inform future reviews.

} as const;

Expand Down
Loading
Loading