https://github.com/lstrojny/php-cld
PHP bindings for the Chrome Language Detector
https://github.com/lstrojny/php-cld
Last synced: about 2 months ago
JSON representation
PHP bindings for the Chrome Language Detector
- Host: GitHub
- URL: https://github.com/lstrojny/php-cld
- Owner: lstrojny
- License: bsd-2-clause
- Created: 2011-10-22T22:20:27.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-09-03T11:44:19.000Z (almost 11 years ago)
- Last Synced: 2025-04-30T10:48:41.112Z (about 2 months ago)
- Language: PHP
- Homepage: http://code.google.com/p/chromium-compact-language-detector/
- Size: 16.2 MB
- Stars: 52
- Watchers: 6
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Bindings for Chromium Compact Language Detector (CLD)
[](http://travis-ci.org/lstrojny/php-cld)This small extension provides bindings to use the Chromium Compact Language Detector
(http://code.google.com/p/chromium-compact-language-detector/) in PHP.## Installation
1. Checkout Chromium Language Detector from with `hg clone
https://code.google.com/p/chromium-compact-language-detector`
2. Run `./build.sh`
3. Checkout this project
4. Run `phpize && ./configure --with-libcld-dir=... && make && sudo make install`
5. Add `extension=cld.so` to your `php.ini`## Usage
### Procedural API
```php
detectLanguage('Drüben hinterm Dorfe wohnt ein Leiermann. Und mit starren Fingern spielt er was er kann'));$detector->setLanguageHint(CLD\Language::JAPANESE);
$detector->setEncodingHint(CLD\Encoding::JAPANESE_EUC_JP);
$detector->detectLanguage("日[の]本([の]国", false);
```will return
```text
array (
0 =>
array (
'name' => 'GERMAN',
'code' => 'de',
'reliable' => true,
'bytes' => 90,
),
)
array (
0 =>
array (
'name' => 'JAPANESE',
'code' => 'ja',
'reliable' => true,
'bytes' => 22,
),
1 =>
array (
'name' => 'CHINESE',
'code' => 'zh',
'reliable' => true,
'bytes' => 22,
),
)
```