Skip to content

Fix the zh_CN tranlation #3110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

MoriMomo
Copy link
Contributor

Chrome Extension Locale Key Naming Issue Report

Issue Summary

The YouTube extension failed to pack due to invalid locale key names in the Chinese (Simplified) locale file (_locales/zh_CN/messages.json). Chrome extensions have strict naming conventions for locale keys that only allow ASCII letters (a-z, A-Z), numbers (0-9), and underscores (_).

Problem Details

Root Cause

Several locale keys in the Chinese locale file contained invalid characters, including:

  • Spaces
  • Apostrophes (')
  • Exclamation marks (!)
  • Parentheses ()
  • Special Unicode characters (⫶)
  • Hyphens (-)

Affected Keys

The following invalid keys were identified and corrected:

Invalid Key Name Corrected Key Name Status
"Disable video playback on hover" "disableThumbnailPlayback" ✅ Fixed
"Dim Youtube's Pages, except what I mouse-over!" "cursorLighting" ✅ Fixed
"Hide AI Summaries" "hideAiSummaries" ✅ Fixed
"Hide Banner Ads (YouTube might deny)" "hideBannerAds" ✅ Fixed
"Hide Pause Overlay" "hidePauseOverlay" ✅ Fixed
"Hide YouTube Logo" "hideYouTubeLogo" ✅ Fixed
"Hide '⫶' (more actions) on thumbnails" "hideMoreActionsOnThumbnails" ✅ Fixed
"Hide watched videos" "hideWatchedVideos" ✅ Fixed
"Remove member only videos" "RemoveMemberOnlyVideos" ✅ Fixed
"Thumbnail Size" "ThumbnailSize" ✅ Fixed
"Youtube-Search" "YoutubeSearch" ✅ Fixed

Technical Requirements

Chrome Extension Locale Key Naming Rules

According to Chrome Extension documentation, locale message keys must:

  1. Only contains ASCII characters
  2. Use letters (a-z, A-Z)
  3. Use numbers (0-9)
  4. Use underscores (_)
  5. NOT contain: spaces, special characters, punctuation, or Unicode characters

Error Messages Encountered

Invalid locale file 'D:\...\zh_CN\messages.json': Name of a key "disable video playback on hover" is invalid. Only ASCII [a-z], [A-Z], [0-9], and "_" are allowed.

Resolution Process

Step 1: Identification

  • Used grep search to identify all keys containing invalid characters
  • Found 11 problematic keys in the Chinese locale file

Step 2: Cross-Reference

  • Checked the English locale file (_locales/en/messages.json) to find correct key names
  • Ensured consistency across locale files

Step 3: Correction

  • Replaced all invalid keys with proper camelCase or underscore-separated names
  • Maintained the original Chinese translations (message values)
  • Preserved the JSON structure and formatting

Step 4: Validation

  • Verified no remaining invalid characters in key names
  • Confirmed all corrections follow Chrome extension naming conventions

Prevention Measures

For Future Development

  1. Validation Script: Consider implementing a pre-build validation script to check locale key names
  2. Naming Convention Documentation: Create a style guide for locale key naming
  3. Code Review Checklist: Add locale key validation to the code review process
  4. Automated Testing: Include locale file validation in the CI/CD pipeline

Recommended Naming Patterns

  • Use camelCase: hideYouTubeLogo, disableThumbnailPlayback
  • Use underscores for compound words: youtube_search, thumbnail_size
  • Avoid spaces and special characters entirely
  • Be consistent with existing key naming patterns

Files Modified

  • _locales/zh_CN/messages.json - All invalid keys corrected

Testing

  • Extension now packages successfully without locale key errors
  • All functionality preserved with corrected key names
  • Chinese translations remain intact

Impact

  • Before: Extension packaging failed with locale validation errors
  • After: Extension packages are successfully installed and maintain all functionality
  • Risk: Low - Only key names changed, not functionality or translations

Yes, I used AI for this MD, but when I was working with this repo and trying to unpack it locally, I came across a translation problem that conflicted with the JSON formatting for Chrome, so I tried to fix it. I hope it helps

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