Giter Site home page Giter Site logo

pinyin's Introduction

Pinyin

Chinese to pinyin translator based on CC-CEDICT.

Install

  1. installing via Composer:

    Next, update your project's composer.json file to include Pinyin:

    {
        "require": {
            "joychao/pinyin": "~1.0"
        }
    }
  2. download source file src/Pinyin.php and include it.

Usage

<?php
echo Pinyin::trans('带着希望去旅行,比到达终点更美好');

// dài zhe xī wàng qù lǔ xíng bǐ dào dá zhōng diǎn gèng měi hǎo 

Setting

  • delimiter Separator between each pinyin, default is a space ' '.
  • accent Whether the output tone.

Pinyin::set($setting); or Pinyin::trans($word, $setting)

example:

<?php
$setting = [
			'delimiter' => '-',
		   ];
Pinyin::set($setting);
echo Pinyin::trans('带着希望去旅行,比到达终点更美好');

// dài-zhe-xī-wàng-qù-lǔ-xíng-bǐ-dào-dá-zhōng-diǎn-gèng-měi-hǎo
<?php
$setting = [
			'delimiter' => '-',
			'accent' => false,
		   ];

echo Pinyin::trans('带着希望去旅行,比到达终点更美好', $setting);

// dai-zhe-xi-wang-qu-lu-xing-bi-dao-da-zhong-dian-geng-mei-hao
<?php
$setting = [
			'accent' => false,
		   ];
Pinyin::set($setting);
echo Pinyin::trans('带着希望去旅行,比到达终点更美好');

// dai zhe xi wang qu lu xing bi dao da zhong dian geng mei hao

License

MIT

pinyin's People

Contributors

overtrue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.