Skip to content

std translator - #889

Merged
CppCXY merged 7 commits into
EmmyLuaLs:mainfrom
xuhuanzy:translator
Dec 25, 2025
Merged

CppCXY merged 7 commits into
EmmyLuaLs:mainfrom
xuhuanzy:translator

Conversation

@xuhuanzy

@xuhuanzy xuhuanzy commented Dec 18, 2025 •

Copy link
Copy Markdown
Member
  1. 添加 std i18n 元信息生成工具,该工具会为std库的每个文件生成对应的待翻译yaml与meta.yaml。meta.yaml记录了替换范围与原文哈希,在运行时直接根据meta信息替换文本。
  2. 仅在 emmylua_ls 启动时生成对应语言的std-{locale}文件,与 std 在同一个父目录下。

仅限于 emmylua_ls.
在启动时会根据翻译文件生成对应语言std目录到文件系统中, 例如
resources/std-zh_CN
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @xuhuanzy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求为 emmylua_ls 引入了标准库文档的国际化(i18n)支持。核心改动是新增了一个工具,用于从源代码中提取标准库的元数据和翻译,并在语言服务器启动时根据用户语言动态生成本地化的标准库文件。这一机制取代了之前硬编码的悬停提示逻辑,使得标准库的描述能够以多种语言呈现,极大地提升了用户体验和可维护性。

Highlights

  • 标准库国际化工具引入: 新增了一个名为 std_i18n 的工具,用于生成标准库的国际化(i18n)元信息和翻译文件。这使得标准库的文档和描述可以根据用户的语言环境进行动态翻译。
  • 动态生成本地化标准库文件: 现在,emmylua_ls 语言服务器在启动时会根据当前语言环境,动态生成对应的 std-{locale} 文件。这些文件与标准库位于同一父目录下,确保了本地化内容的及时性和准确性。
  • 旧有标准库悬停提示逻辑移除: 移除了之前硬编码的标准库悬停提示(std_hover)模块及其相关逻辑。新的国际化机制将接管标准库函数和类型的描述显示,提供了更灵活和可维护的翻译方案。
  • 新增多语言元数据和翻译文件: 在 crates/emmylua_ls/std_i18n/ 目录下新增了大量的 meta.yaml 和 zh_CN.yaml 文件。这些文件包含了 Lua 标准库(如 bit、coroutine、math、string、table 等)的元数据和中文翻译内容,为动态生成本地化文件提供了数据源。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

这次的 Pull Request 引入了一套非常完善的 std 库文档国际化方案,值得称赞。通过在语言服务器启动时动态生成带翻译的 std 文件,将翻译逻辑与核心分析逻辑解耦,简化了 hover 和 signature help 等功能的实现。代码整体结构清晰,但我在其中发现了一个会导致编译失败的关键问题,以及两处可以提升代码可读性和可维护性的地方。请查看具体的审查意见。

@xuhuanzy
xuhuanzy requested a review from CppCXY December 19, 2025 02:00
@CppCXY
CppCXY merged commit b45bab4 into EmmyLuaLs:main Dec 25, 2025
@xuhuanzy
xuhuanzy deleted the translator branch December 26, 2025 19:50
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.

2 participants