Skip to content

feat(i18n): add i18n-localization skill with checker script#660

Draft
bijinfeng wants to merge 2 commits intoiflytek:mainfrom
bijinfeng:chore/i18n-skills
Draft

feat(i18n): add i18n-localization skill with checker script#660
bijinfeng wants to merge 2 commits intoiflytek:mainfrom
bijinfeng:chore/i18n-skills

Conversation

@bijinfeng
Copy link
Copy Markdown
Contributor

📝 Pull Request 描述 | Description

Add new skill for internationalization and localization best practices. Includes comprehensive documentation, best practices guide, and a Python script to detect hardcoded strings and verify locale completeness.

🎯 变更类型 | Change Type

  • ✨ 新功能 | New Feature
  • 🐛 Bug 修复 | Bug Fix
  • 📚 文档更新 | Documentation
  • 🎨 代码格式/样式 | Code Style
  • ♻️ 重构 | Refactoring
  • ⚡ 性能优化 | Performance
  • ✅ 测试相关 | Tests
  • 🔧 配置变更 | Configuration
  • 🔨 构建/CI | Build/CI
  • 🌐 国际化 | Internationalization
  • ⬆️ 依赖升级 | Dependencies Update

🔗 相关 Issue | Related Issues

  • Closes #
  • Related to #

📋 变更内容 | Changes Made

主要变更 | Main Changes

技术细节 | Technical Details


🧪 测试 | Testing

测试环境 | Test Environment

  • Windows 10/11
  • Linux
  • macOS
  • Docker

测试步骤 | Test Steps

测试结果 | Test Results


📸 截图/录屏 | Screenshots/Recordings

变更前 | Before

变更后 | After


⚠️ 破坏性变更 | Breaking Changes

  • 此 PR 包含破坏性变更 | This PR contains breaking changes
破坏性变更详情 | Breaking Changes Details

✅ 检查清单 | Checklist

代码质量 | Code Quality

  • 代码遵循项目的编码规范 | Code follows project coding standards
  • 已进行自我代码审查 | Self-reviewed the code
  • 代码有适当的注释(特别是复杂逻辑)| Code has appropriate comments (especially for complex logic)
  • 更新了相关文档 | Updated relevant documentation
  • 没有产生新的警告 | No new warnings generated

测试 | Testing

  • 添加了相应的测试用例 | Added corresponding test cases
  • 所有测试通过 | All tests pass
  • 手动测试验证通过 | Manual testing verification passed

文档 | Documentation

  • 更新了 README(如需要)| Updated README (if needed)
  • 更新了 API 文档(如需要)| Updated API documentation (if needed)
  • 更新了用户指南(如需要)| Updated user guide (if needed)
  • 更新了 CHANGELOG(如需要)| Updated CHANGELOG (if needed)

其他 | Others

  • 已与相关利益方沟通 | Communicated with relevant stakeholders
  • 不影响现有功能 | Does not affect existing functionality
  • 考虑了向后兼容性 | Considered backward compatibility
  • 考虑了性能影响 | Considered performance impact
  • 考虑了安全性 | Considered security

📌 额外说明 | Additional Notes


🙏 致谢 | Acknowledgements


📖 提示 | Tips:

  • 确保 PR 标题简洁明了,使用动词开头(例如:Add, Fix, Update, Remove)
  • Ensure PR title is concise and clear, starting with a verb (e.g., Add, Fix, Update, Remove)
  • 尽量保持 PR 的改动范围小而集中,便于审查
  • Try to keep PR changes small and focused for easier review
  • 遵循项目的分支管理策略
  • Follow the project's branch management strategy

/cc @maintainers

Add new skill for internationalization and localization best practices.
Includes comprehensive documentation, best practices guide, and a Python
script to detect hardcoded strings and verify locale completeness.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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!

This pull request significantly enhances the agent's capabilities by integrating a new skill focused on internationalization and localization. It provides a structured approach to ensuring applications are ready for global audiences, offering detailed guidelines and an automated tool to enforce best practices and identify common i18n issues early in the development cycle.

Highlights

  • New i18n-localization skill: Added a new i18n-localization skill to the agent system, providing comprehensive guidance on internationalization and localization.
  • Comprehensive Best Practices Documentation: Included detailed documentation on internationalization and localization best practices, covering various technical and content-related aspects.
  • Automated i18n Checker Script: Introduced a Python script (i18n_checker.py) designed to automatically detect hardcoded strings in code and verify the completeness and consistency of locale files.
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.

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.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new skill for i18n and localization, including comprehensive documentation and a Python script for detecting hardcoded strings. The documentation is well-structured and provides good best practices. The checker script is a great addition for maintaining i18n hygiene. I've provided some feedback on the Python script to improve its robustness, error handling, and compatibility, as well as a minor formatting suggestion for the documentation.

| Ignoring plurals | "1 items" | Use ICU plural |
| Fixed-width UI | German overflow | Flexible layouts |
| Text in images | Can't translate | Use CSS/SVG |
| Gendered pronouns | Not all languages | Use neutral or select | No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This file is missing a final newline character. It's a standard convention to end text files with a newline to prevent issues with file concatenation and some command-line tools.

Suggested change
| Gendered pronouns | Not all languages | Use neutral or select |
| Gendered pronouns | Not all languages | Use neutral or select |

Comment on lines +71 to +78
patterns = [
"**/locales/**/*.json",
"**/translations/**/*.json",
"**/lang/**/*.json",
"**/i18n/**/*.json",
"**/messages/*.json",
"**/*.po", # gettext
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The find_locale_files function includes a pattern to find .po files, but the rest of the script, particularly check_locale_completeness, only processes .json files. This can be misleading. To avoid confusion, it's better to either add support for .po files or remove the pattern that finds them. Removing it is the simpler fix if .po file support is not planned.

    patterns = [
        "**/locales/**/*.json",
        "**/translations/**/*.json",
        "**/lang/**/*.json",
        "**/i18n/**/*.json",
        "**/messages/*.json",
    ]

def is_probably_locale_code(s: str) -> bool:
return bool(re.match(r'^[a-z]{2,3}(-[A-Z]{2})?$', s))

def detect_language_and_namespace(file_path: Path) -> tuple[str, str] | tuple[None, None]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The type hint tuple[str, str] | tuple[None, None] uses the | operator for union types, which was introduced in Python 3.10. For better compatibility with older Python 3 versions (e.g., 3.9), it's recommended to use Union from the typing module. This also applies to other type hints in this file, like int | None on line 257, which could be Optional[int]. You would need to add from typing import Union, Tuple, Optional at the top of the file.

def detect_language_and_namespace(file_path: Path) -> "Union[Tuple[str, str], Tuple[None, None]]":

Comment on lines +122 to +123
except:
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a bare except: is discouraged because it catches all exceptions, including SystemExit and KeyboardInterrupt, which can make the script difficult to terminate. It's better to catch specific exceptions you anticipate, like json.JSONDecodeError or IOError.

            except (json.JSONDecodeError, IOError):
                continue

def find_hardcoded_in_file(file_path: Path, file_type: str, patterns: list[tuple[str, str]], has_i18n: bool, include_console: bool) -> list[dict]:
issues = []
try:
lines = file_path.read_text(encoding='utf-8', errors='ignore').splitlines()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using errors='ignore' when reading files can hide encoding issues and lead to silent data corruption, potentially causing the checker to miss hardcoded strings. It's safer to use errors='replace', which substitutes problematic bytes with a placeholder, making it clear that an encoding error occurred without stopping the script.

        lines = file_path.read_text(encoding='utf-8', errors='replace').splitlines()

Comment on lines +205 to +206
except:
return issues
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a bare except: is discouraged because it catches all exceptions, including SystemExit and KeyboardInterrupt, which can make the script difficult to terminate. It's better to catch specific exceptions you anticipate, such as IOError for file reading operations.

    except IOError:
        return issues

Comment on lines +311 to +312
except:
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a bare except: is discouraged because it catches all exceptions, including SystemExit and KeyboardInterrupt. If the goal is to catch any potential error during the processing of a single file and continue with the next, it's better to explicitly catch Exception.

        except Exception:
            continue

Add new terminology reference file to standardize translations across the project. Update SKILL.md to include terminology section and update checklist to include glossary verification. This ensures consistent UI naming and prevents translation of product names and code identifiers.
@bijinfeng bijinfeng marked this pull request as draft March 20, 2026 09:57
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.

1 participant