overtrue/pinyin

🇨🇳 基于词库的中文转拼音优质解决方案

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 21 minutes ago
Added to GitGenius on September 15th, 2026
Created on July 16th, 2014
Open Issues & Pull Requests: 0 (+0)
GitHub issues: Enabled
Number of forks: 761
Total Stargazers: 4,459 (+0)
Total Subscribers: 144 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 5.6 days
Mean response time: 629.3 days
90th percentile: 2281.1 days
Tracked items: 7

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 0
New in 7 days: 0
Closed in 7 days: 0
Avg open age: N/A days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • todo :spiral_notepad: (3)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Pinyin is a PHP library that converts Chinese characters to their romanized pinyin representation.

The library solves the problem of accurately converting Chinese text to pinyin, with particular attention to polyphonic characters that have multiple pronunciations depending on context. It uses a dictionary-based approach built on the mozillazg/pinyin-data dataset. The tool supports multiple output formats: tone marks as diacritical symbols, numeric tone notation, and toneless output. It can handle full text passages, extract initials for indexing, generate URL-friendly slugs, and includes specialized handling for surnames and passport romanization where certain characters follow different pronunciation rules.

Developers should choose this tool if they need reliable polyphonic character support in a PHP environment. It suits web applications, batch processing, and systems that need to generate searchable indexes or URL slugs from Chinese text. The library offers three conversion strategies with different memory and performance characteristics: a memory-optimized approach using around 400KB suitable for web requests, a cached strategy consuming around 4MB for batch processing where repeated conversions benefit from a 2-3x speed improvement, and a smart strategy that automatically selects the best approach based on text length.

The project maintains active development with regular updates and comprehensive test coverage. The codebase includes well-documented usage examples covering common scenarios like name conversion, abbreviation generation, and permalink creation. The tool provides flexible configuration through both string values and enumeration types for tone style selection, and returns results as collection objects that support multiple access patterns.