Registry / serialization / zhconv

zhconv

JSON →
library1.4.3pypypi✓ verified 83d ago

A simple implementation of Simplified-Traditional Chinese conversion. Supports zh-Hans, zh-Hant, and regional variants like zh-tw, zh-cn, etc. Based on MediaWiki conversion tables. Current version: 1.4.3. Release cadence is low; maintained as needed.

pip install zhconv
INSTALL
IMPORT
SIG · ZHCONV
Z
zhconv
serializationpythonv1.4.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convert
from zhconv import convert
import zhconv
Direct module import does not expose convert; must import the function explicitly.

Basic usage: convert(text, target_variant). Variants include 'zh-hans', 'zh-hant', 'zh-cn', 'zh-tw', 'zh-hk', 'zh-sg', 'zh-mo', etc.

from zhconv import convert # Convert simplified Chinese to traditional result = convert('我爱编程', 'zh-tw') print(result) # 我愛編程 # Convert traditional to simplified result2 = convert('我愛編程', 'zh-cn') print(result2) # 我爱编程
Debug
Known issues
gotchaThe library does not auto-detect the source variant; you must specify the target variant. If you want to detect the source, use other libraries like opencc or langid.
fix
Always specify target variant explicitly, e.g., 'zh-cn' when converting to simplified Chinese.
affects: all
gotchaConversion is one-way per call; to convert 'back' you need to call convert again with the opposite target. The library does not maintain state.
fix
Call convert(text, 'zh-cn') then convert(result, 'zh-tw') for bidirectional conversion.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'convert' from 'zhconv'
Using import zhconv and then zhconv.convert, but the function is not a module-level attribute when imported as a module.
fix
Use 'from zhconv import convert' instead of 'import zhconv'.
TypeError: convert() missing 1 required positional argument: 'target'
Calling convert() without providing the target variant string.
fix
Provide target variant: convert('text', 'zh-tw')
Upgrade
Version history
1.4.3latest on PyPI · released Oct 31, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
57 hits · last 30 days
node
52
OpenAI (training)
1
Resources
zhconv — pip install zhconv · libregistry