PHPackages                             hamidgh83/language-detection - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hamidgh83/language-detection

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hamidgh83/language-detection
============================

A language detection library for PHP. Detects the language from a given text string.

v3.5.5(4y ago)049MITPHPPHP ^7

Since Dec 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/hamidgh83/language-detection)[ Packagist](https://packagist.org/packages/hamidgh83/language-detection)[ Docs](https://github.com/hamidgh83/language-detection)[ RSS](/packages/hamidgh83-language-detection/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (20)Used By (0)

### The package

[](#the-package)

[![Version](https://camo.githubusercontent.com/39ede7b28acc2e7863d43453861d79dba84656d611bc5ea8deea9f049c25ec86/68747470733a2f2f706f7365722e707567782e6f72672f68616d6964676838332f6c616e67756167652d646574656374696f6e2f76657273696f6e)](//packagist.org/packages/hamidgh83/language-detection)[![Total Downloads](https://camo.githubusercontent.com/782c11f6aaf1f867d8f94f8863a9979e7100a14347f7d9fa16cefc2baac47601/68747470733a2f2f706f7365722e707567782e6f72672f68616d6964676838332f6c616e67756167652d646574656374696f6e2f646f776e6c6f616473)](//packagist.org/packages/hamidgh83/language-detection)[![Dependents](https://camo.githubusercontent.com/8328ea6d68ed78a1ba3425bc73323738818aab91f48e0a460df138bdfb4b8416/68747470733a2f2f706f7365722e707567782e6f72672f68616d6964676838332f6c616e67756167652d646574656374696f6e2f646570656e64656e7473)](//packagist.org/packages/hamidgh83/language-detection)[![License](https://camo.githubusercontent.com/92dac3abddee3a70156fd1762c476a1d094aa6f6817f8067d77ed0905785a414/68747470733a2f2f706f7365722e707567782e6f72672f68616d6964676838332f6c616e67756167652d646574656374696f6e2f6c6963656e7365)](//packagist.org/packages/hamidgh83/language-detection)

language-detection
==================

[](#language-detection)

ُThis is an extension of [language-detection](https://github.com/patrickschur/language-detection) where you can find its documentation.

This library can detect the language of a given text string. It can parse given training text in many different idioms into a sequence of [N-grams](https://en.wikipedia.org/wiki/N-gram) and builds a database file in JSON format to be used in the detection phase. Then it can take a given text and detect its language using the database previously generated in the training phase. The library comes with text samples used for training and detecting text in 110 languages.

Installation with Composer
--------------------------

[](#installation-with-composer)

> **Note:** This library requires the [Multibyte String](https://secure.php.net/manual/en/book.mbstring.php) extension in order to work.

```
$ composer require hamidgh83/language-detection
```

Basic Usage
-----------

[](#basic-usage)

Basic usage of this library is the same as original library but the following methods has beed added:

---

#### `bestResult()`

[](#bestresult)

Returns the best result as a string.

```
$ld->detect('Mag het een onsje meer zijn?')->bestResult();
```

Result:

```
string(2) "nl"

```

---

#### `getSupportLanguages()`

[](#getsupportlanguages)

This method returns a list if supportted languages as an array.

```
$ld->getSupportLanguages();
```

Result:

```
Array
(
    0 => ab
    1 => af
    2 => am
    3 => ar
    4 => ay
    5 => az-Cyrl
    6 => az-Latn
    7 => be
    8 => bg
    9 => bi
    10 => bn
    11 => bo
    12 => br
    [...]
)

```

---

#### getLanguageProps($lang)

[](#getlanguagepropslang)

Every language has their own properties and you can get the it as follow:

```
$lng    = new Language();
$result = $lng->detect('This is an example text.');
$props  = $lng->getLanguageProps($result->bestResult());
```

Result:

```
Array
(
    'props' => Array(
        'language' => 'English',
        'language' => Array (
            'United Kingdom',
            'United States of America'
        ),
        'direction' => 'ltr'
    )
)

```

---

Supported languages
-------------------

[](#supported-languages)

The library currently supports 110 languages. To get an overview of all supported languages please have a look at [here](resources/README.md).

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 75.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~114 days

Recently: every ~325 days

Total

18

Last Release

1523d ago

Major Versions

v1.2 → v2.02017-01-09

v2.1.1 → v3.02017-02-04

PHP version history (2 changes)v1.0PHP ^7.0 || ^7.1

v3.0PHP ^7

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3264788?v=4)[Hamid](/maintainers/hamidgh83)[@hamidgh83](https://github.com/hamidgh83)

---

Top Contributors

[![patrickschur](https://avatars.githubusercontent.com/u/18181635?v=4)](https://github.com/patrickschur "patrickschur (68 commits)")[![hamidghorashi](https://avatars.githubusercontent.com/u/89512189?v=4)](https://github.com/hamidghorashi "hamidghorashi (13 commits)")[![arsonik](https://avatars.githubusercontent.com/u/1333734?v=4)](https://github.com/arsonik "arsonik (4 commits)")[![hamidgh83](https://avatars.githubusercontent.com/u/3264788?v=4)](https://github.com/hamidgh83 "hamidgh83 (2 commits)")[![gradzio](https://avatars.githubusercontent.com/u/32451455?v=4)](https://github.com/gradzio "gradzio (1 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (1 commits)")[![tomasliubinas](https://avatars.githubusercontent.com/u/1522729?v=4)](https://github.com/tomasliubinas "tomasliubinas (1 commits)")

---

Tags

languagedetectiondetect

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hamidgh83-language-detection/health.svg)

```
[![Health](https://phpackages.com/badges/hamidgh83-language-detection/health.svg)](https://phpackages.com/packages/hamidgh83-language-detection)
```

###  Alternatives

[patrickschur/language-detection

A language detection library for PHP. Detects the language from a given text string.

8533.5M20](/packages/patrickschur-language-detection)[phpoption/phpoption

Option Type for PHP

2.7k566.1M169](/packages/phpoption-phpoption)[foroco/php-browser-detection

Ultra fast PHP library to detect browser, OS, platform and device type by User-Agent parsing

1515.3M7](/packages/foroco-php-browser-detection)[nitotm/efficient-language-detector

Fast and accurate natural language detection. Detector written in PHP. Nito-ELD, ELD.

62315.9k8](/packages/nitotm-efficient-language-detector)[unicodeveloper/laravel-identify

A Laravel 5 Package Provider to Identify/detect a user's browser, device, operating system and Language

19222.0k](/packages/unicodeveloper-laravel-identify)[detectlanguage/detectlanguage

Language Detection API PHP Client

50770.5k1](/packages/detectlanguage-detectlanguage)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
