Skip to content

fix(translation): route Microsoft Chinese targets correctly#444

Open
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-microsoft-chinese-translation
Open

fix(translation): route Microsoft Chinese targets correctly#444
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-microsoft-chinese-translation

Conversation

@codedogQBY

Copy link
Copy Markdown
Owner

Analysis

Issue #266 reports that Microsoft Translate leaves English text unchanged when translating to Simplified or Traditional Chinese, while Japanese works. The desktop selection popover uses the shared useTranslator hook, but that hook only routed ai and deepl providers, so the default Microsoft provider was not actually handled there. The Microsoft provider also only mapped exact zh-CN / zh-TW codes and built URLs with an empty from= parameter during auto-detection.

Changes

  • Route microsoft through useTranslator so the desktop selection translation popover can use the configured Microsoft provider.
  • Normalize Microsoft Chinese target/source language variants such as zh-cn, zh_Hans, zh, and zh_hant to zh-Hans / zh-Hant.
  • Build Microsoft query strings with URLSearchParams and omit from during auto-detection instead of sending an empty from= parameter.
  • Show the actual non-AI provider name in the desktop translation popover instead of always displaying DeepL.
  • Add provider tests for Chinese language normalization and Microsoft request construction.

Verification

  • pnpm --filter @readany/core test -- providers
  • pnpm --filter @readany/core exec tsc --noEmit
  • pnpm --filter app exec tsc --noEmit
  • pnpm --filter @readany/app-expo exec tsc --noEmit
  • git diff --check
  • Live Microsoft Edge Translate smoke test confirmed zh-Hans, zh-Hant, and ja all translate the same English sentence successfully.

Note: pnpm exec biome check packages/core/src/hooks/useTranslator.ts packages/core/src/translation/providers.ts packages/core/src/translation/providers.test.ts packages/app/src/components/reader/TranslationPopover.tsx still reports existing diagnostics in providers.ts and TranslationPopover.tsx (format/lint issues outside this targeted fix).

Fixes #266

@codedogQBY codedogQBY added bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression area:translation Translation and bilingual reading labels Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:translation Translation and bilingual reading bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 微软翻译错误

1 participant