Skip to content

feat(i18n): add internationalization support with Chinese translation#2387

Open
yungle2023 wants to merge 1 commit into
logancyang:masterfrom
yungle2023:feature/i18n-chinese-support
Open

feat(i18n): add internationalization support with Chinese translation#2387
yungle2023 wants to merge 1 commit into
logancyang:masterfrom
yungle2023:feature/i18n-chinese-support

Conversation

@yungle2023

Copy link
Copy Markdown

Summary

  • Add i18n framework with automatic language detection based on Obsidian locale
  • Create translation files for English (en) and Simplified Chinese (zh-CN)
  • Add utility functions for localized messages
  • Update Chat.tsx to use translations for notice messages

Details

This PR implements the foundational i18n (internationalization) infrastructure for the Obsidian Copilot plugin, addressing issue #2037.

New Files

  • src/lang/en.ts - English translations (default)
  • src/lang/zh-CN.ts - Simplified Chinese translations
  • src/lang/i18n.ts - i18n core module with language detection and translation functions
  • src/lang/index.ts - Module exports
  • src/lang/langUtils.ts - Utility functions for localized messages

Modified Files

  • src/components/Chat.tsx - Updated to use t() function for user-facing messages
  • src/constants.ts - Added comment about localized loading messages

Translation Keys

The following categories of strings are now translatable:

  • chat - Chat UI strings (new chat, send, save, etc.)
  • messages - Notice messages (errors, confirmations)
  • loading - Loading state messages
  • project - Project-related messages
  • model - Model selection messages
  • settings - Settings messages
  • errors - Error messages
  • tools - Tool names
  • plus - Copilot Plus related
  • misc - Miscellaneous strings

How It Works

  1. The i18n module automatically detects Obsidian's locale setting
  2. Falls back to English for unsupported languages
  3. Provides a simple t("key.path") function for translations
  4. Supports parameter interpolation: t("key", { name: "value" })

Future Work

  • Extend translations to more components
  • Add more languages (community contributions welcome!)
  • Add a settings option to manually override language

Closes #2037

- Add i18n framework with automatic language detection based on Obsidian locale
- Create translation files for English (en) and Simplified Chinese (zh-CN)
- Add utility functions for localized messages
- Update Chat.tsx to use translations for notice messages
- Add translation keys for common UI strings (chat, messages, loading, project, model, settings, errors, tools)

This addresses issue logancyang#2037 and provides a foundation for community-contributed translations.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c15ed53132

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/lang/i18n.ts
@logancyang

logancyang commented May 9, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR! We are working on a complete revamp of the plugin to move to V4 and many things will change. I'm gonna hold this one until v4 release. Thanks again for the work!

cc @Emt-lin @zeroliu

@logancyang logancyang added hold Blocked by other dependencies labels May 9, 2026
@littledgg

Copy link
Copy Markdown

Thanks for the PR! We are working on a complete revamp of the plugin to move to V4 and many things will change. I'm gonna hold this one until v4 release. Thanks again for the work!谢谢PR!我们正在努力对插件的一个完整的改造移动到V4和许多事情会改变.我要举行这一次,直到V4版本发布.再次感谢的工作!

cc @Emt-lin @zeroliucc @Emt-lin @zeroliu
What exactly is the V4 revamp support? Is it an adaptation like DeepSeek-Reasonix? I'm really looking forward to seeing this PR merged.
请问支持V4的改造是什么呢,是像DeepSeek-Reasonix那样的适配吗,我很期待这个PR的合入

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

Labels

hold Blocked by other dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have you considered adding i18n functionality?

3 participants