Skip to content

steelywing/PHP-Chinese

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Chinese Conversion

PHP Chinese Conversion, Simple, Lightweight (v0.2 with WikiMedia Library < 400KB)

Installation

Use Composer

composer require steelywing/chinese

Manually install

  • Clone this repo

    git clone https://github.com/steelywing/PHP-Chinese.git
    
  • Generate autoload.php, run on PHP-Chinese folder

    composer dump-autoload
    

Feature

  • Use WikiMedia or OpenCC library
  • Lightweight
  • 使用最長匹配規則

Demo

For more usage, see demo.php

require_once __DIR__ . '/vendor/autoload.php';

use SteelyWing\Chinese\Chinese;

$chinese = new Chinese();

echo $chinese->to(Chinese::ZH_HANS, '轉成簡體中文'); // 转成简体中文
echo $chinese->to(Chinese::ZH_HANT, '转成繁体中文'); // 轉成繁體中文

Switch library

Switch to OpenCC, run the following command in dict folder

git clone https://github.com/BYVoid/OpenCC.git
php import_opencc.php

Switch to WikiMedia, run the following command in dict folder

php import_wikimedia.php

License

MIT

WikiMedia License

OpenCC License

About

PHP Chinese Conversion (中文繁簡轉換)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages