PHPackages                             oss-tools/laravel-libretranslate - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. oss-tools/laravel-libretranslate

ActiveLibrary[Localization &amp; i18n](/categories/localization)

oss-tools/laravel-libretranslate
================================

Package to introduce a Client for translating text using LibreTranslate in Laravel.

v2.0.0(10mo ago)32.3k11MITPHPPHP ^8.2CI passing

Since Dec 20Pushed 10mo agoCompare

[ Source](https://github.com/oss-tools/laravel-libretranslate)[ Packagist](https://packagist.org/packages/oss-tools/laravel-libretranslate)[ Docs](https://github.com/oss-tools/laravel-libretraslate)[ RSS](/packages/oss-tools-laravel-libretranslate/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (6)Versions (9)Used By (1)

Laravel LibreTranslate
======================

[](#laravel-libretranslate)

[![Latest Version](https://camo.githubusercontent.com/9e3ef9b659e483383cc3873b171301d4472e4ba995c951506a22cdb3d6800d8d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f73732d746f6f6c732f6c61726176656c2d6c696272657472616e736c6174652e7376673f7374796c653d666c61742d737175617265)](https://github.com/oss-tools/laravel-libretranslate/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![GitHub Workflow Status](https://camo.githubusercontent.com/b528264e1a6ecfeb32aaaaaee10f48736f0596b6d4e7d2ba160b638919193ef7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f73732d746f6f6c732f6c61726176656c2d6c696272657472616e736c6174652f72756e2d74657374732e796d6c3f6c6162656c3d7465737473266272616e63683d6d6173746572)](https://camo.githubusercontent.com/b528264e1a6ecfeb32aaaaaee10f48736f0596b6d4e7d2ba160b638919193ef7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f73732d746f6f6c732f6c61726176656c2d6c696272657472616e736c6174652f72756e2d74657374732e796d6c3f6c6162656c3d7465737473266272616e63683d6d6173746572)[![Check & fix styling](https://github.com/oss-tools/laravel-libretranslate/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/oss-tools/laravel-libretranslate/workflows/Check%20&%20fix%20styling/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/9bac8a9de67dc72139226a8e1cb4a7174a79962df82de906f4eed402590fc4e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f73732d746f6f6c732f6c61726176656c2d6c696272657472616e736c6174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oss-tools/laravel-libretranslate)

This package adds a client to translate text in Laravel using LibreTranslate.

What is LibreTranslate?
-----------------------

[](#what-is-libretranslate)

[LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) is a free and open source translation library.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require oss-tools/laravel-libretranslate
```

### Configuration

[](#configuration)

To set up the package, you will need to set the below env variables.

```
LIBRETRANSLATE_HOST=https://mylibretranslateserver.com
LIBRETRANSLATE_API_KEY=your-api-key
LIBRETRANSLATE_DEFAULT_SOURCE=en

```

**Note:** The default value for `LIBRETRANSLATE_HOST` is set to  however, we recommend setting up your own server or using a host that is suitable for your needs for production.

Usage
-----

[](#usage)

```
use OSSTools\LibreTranslate\Client;
use OSSTools\LibreTranslate\Translation\LanguageCodes;

class ExampleController extends Controller
{
    public function translate()
    {
        $client = new Client();

        // Returns an instance of \OSSTools\LibreTranslate\Translation\TranslationCollection
        $result = $client->translate('This is some text', LanguageCodes::SPANISH);

        // Returns an array of \OSSTools\LibreTranslate\Translation\TranslationItem
        $result = $client->translate('This is some text', LanguageCodes::SPANISH)->getAll();

        // Returns a single instance of \OSSTools\LibreTranslate\Translation\TranslationItem
        $result = $client->translate(['This is some text', 'A test'], LanguageCodes::SPANISH)->first();

        // Returns a single instance of \OSSTools\LibreTranslate\Translation\TranslationItem
        $result = $client->translate(['This is some text', 'A test'], LanguageCodes::SPANISH)->last();

        // Returns a single instance of \OSSTools\LibreTranslate\Translation\TranslationItem
        $result = $client->translate(['This is some text', 'A test'], LanguageCodes::SPANISH)->get('A test');

        // Returns "Una prueba"
        $result = $client->translate(['This is some text', 'A test'], LanguageCodes::SPANISH)->last()->getText();
    }
}
```

Detecting a language from some text
===================================

[](#detecting-a-language-from-some-text)

```
use OSSTools\LibreTranslate\Client;

class ExampleController extends Controller
{
    public function translate()
    {
        $client = new Client();

        // Returns an instance of \OSSTools\LibreTranslate\Translation\TranslationDetectionCollection
        $result = $client->detect('This is some text');

        // Returns an array of \OSSTools\LibreTranslate\Translation\TranslationDetectionItem
        $result = $client->detect('This is some text')->getAll();

        // Returns a single instance of \OSSTools\LibreTranslate\Translation\TranslationDetectionItem
        $result = $client->translate('This is some text')->first();

        // Returns "en"
        $result = $client->detect('Some text')->first()->getLanguage();

        // Returns "es"
        $result = $client->detect('Una prueba')->first()->getLanguage();
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance54

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~192 days

Recently: every ~334 days

Total

8

Last Release

311d ago

Major Versions

v0.1.4 → v1.0.02023-06-12

v1.0.1 → v2.0.02025-08-26

PHP version history (3 changes)v0.1.0PHP ^7.1.3|^8.0

v1.0.0PHP ^8.0.2

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/aefdf8ae83cfab5fcfd3d08aa02e9c0c094ee59049dff1b3204a05c0c21de77b?d=identicon)[blessingdube](/maintainers/blessingdube)

---

Top Contributors

[![blessingdube](https://avatars.githubusercontent.com/u/24409039?v=4)](https://github.com/blessingdube "blessingdube (20 commits)")

---

Tags

oss-toolslaravel-libretranslate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oss-tools-laravel-libretranslate/health.svg)

```
[![Health](https://phpackages.com/badges/oss-tools-laravel-libretranslate/health.svg)](https://phpackages.com/packages/oss-tools-laravel-libretranslate)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

268934.9k4](/packages/laravel-cashier-paddle)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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