Recognize the language in which a text is written.
Language Recognizer for Laravel is a package providing various drivers to recognize the language of a given text.
Currently two drivers are offered:
- A local binary application
- A DeepL based one
You can install the package via composer:
composer require oneofftech/laravel-language-recognizer
You can publish the config file with:
php artisan vendor:publish --provider="Oneofftech\LaravelLanguageRecognizer\LaravelLanguageRecognizerServiceProvider" --tag="laravel-language-recognizer-config"
If you change the path to the Franc binary, as configured in the local driver, ensure that the file is moved or present in that location. You can run
php artisan language-recognizer:install-local-driver
to download the binary in the configured location
The configuration file allows to configure the driver parameter for performing the language recognition.
Local Driver
The language recognition, when performed using the local driver, is done using the Franc library, in particular a packaged version in form on an executable.
To download the executable version run:
php artisan language-recognizer:install-local-driver
DeepL Driver
The DeepL driver requires a valid API key. You can obtain a free key on deepl.com.
After obtaining the key specifiy it via the LANGUAGE_RECOGNIZER_DEEPL_KEY
environment variable.
use Oneofftech\LaravelLanguageRecognizer\Support\Facades\LanguageRecognizer;
LanguageRecognizer::recognize('Which language is used in this string!');
A test suite is available. To execute the tests run:
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.