PHPackages                             sysoce/laravel-translation - 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. sysoce/laravel-translation

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

sysoce/laravel-translation
==========================

Provides a translation dictionary layer between a translation service and your Laravel application.

v1.0.2(7y ago)015MITPHPPHP &gt;=7.0

Since Sep 10Pushed 7y agoCompare

[ Source](https://github.com/sysoce/laravel-translation)[ Packagist](https://packagist.org/packages/sysoce/laravel-translation)[ Docs](https://github.com/sysoce/laravel-translation)[ RSS](/packages/sysoce-laravel-translation/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (5)Used By (0)

Laravel Translation
===================

[](#laravel-translation)

This package provides a translation dictionary layer between a translation service and your Laravel application. The dictionary layer can be used to avoid cost and speed up reoccurring translations. When you translate text through a translation service the translation is saved to your database and will be used instead of the translation service next time you translate the same text.

- [Installation](#installation)
- [Usage](#usage)
    - [The Client](#the-client)
    - [Using the translation dictionary layer](#using-the-translation-dictionary-layer)
- [Extending](#extending)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

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

[](#installation)

### Laravel

[](#laravel)

This package can be used in Laravel 5.4 or higher.

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in `config/app.php` file:

```
'providers' => [
    // ...
    Sysoce\Translation\TranslationServiceProvider::class,
];
```

You can publish [the migration](https://github.com/sysoce/laravel-translation/blob/master/database/migrations/0000_00_00_000000_create_translations_table.php) with:

```
php artisan vendor:publish --provider="Sysoce\Translation\TranslationServiceProvider" --tag="migrations"
```

After the migration has been published you can create the translations table by running the migration:

```
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Sysoce\Translation\TranslationServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### The Client

[](#the-client)

To use this package you need to connect to a translation service. This package provides a wrapper for [Google Cloud Translate](https://cloud.google.com/translate/) out of the box. To use this translation client you need to install the Google Cloud Translate package:

```
composer require google/cloud-translate
```

Enter the path to your JSON key file obtained from the [Google Cloud Console](https://console.cloud.google.com/) in the published [`config/translation.php` config file](https://github.com/sysoce/laravel-translation/blob/master/config/translation.php) or simply specify the path in your .env file:

```
/*
 * If the client requires a key file, enter its path below.
 */
'keyFilePath' => env('GOOGLE_APPLICATION_CREDENTIALS', ''),
```

You can create a wrapper for other Translation services by implementing the [Sysoce\\Translation\\Contracts\\Client](https://github.com/sysoce/laravel-translation/blob/master/src/Contracts/Client.php) contract.

### Using the translation dictionary layer

[](#using-the-translation-dictionary-layer)

To use the translation dictionary layer

```
// Set source language for translation
app(Translation::class)->setSource('en');
// Set target language for translation
app(Translation::class)->setTarget('ja');

// Translate text
$translation = app(Translation::class)->translate('hello');

// Print translation (outputs 'こんにちは')
echo $translation->text
```

Extending
---------

[](#extending)

If you need to EXTEND the existing `Translation` model note that:

- Your `Translation` model needs to extend the `Sysoce\Translation\Models\Translation` model

If you need to REPLACE the existing `Translation` model you need to keep the following things in mind:

- Your `Translation` model needs to implement the `Sysoce\Translation\Traits\HasHashIdTrait` and `Sysoce\Translation\Traits\TranslationTrait` traits

Whether extending or replacing, you will need to specify your new model in the configuration. To do this you must update the `models.translation` value in the configuration file after publishing the configuration.

### Testing

[](#testing)

```
./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

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 ~1 days

Total

3

Last Release

2739d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e3ac6216e55cf5ed7a412f26a3ffc653ed5ff9e014d7e389d206dccb5ab3ed7?d=identicon)[sysoce](/maintainers/sysoce)

---

Top Contributors

[![sysoce](https://avatars.githubusercontent.com/u/41183516?v=4)](https://github.com/sysoce "sysoce (31 commits)")

---

Tags

laraveltranslationdictionaryautomachinesysoce

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sysoce-laravel-translation/health.svg)

```
[![Health](https://phpackages.com/badges/sysoce-laravel-translation/health.svg)](https://phpackages.com/packages/sysoce-laravel-translation)
```

###  Alternatives

[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[stevegrunwell/lost-in-translation

Uncover missing translations and localization strings in Laravel applications

3635.7k](/packages/stevegrunwell-lost-in-translation)[longman/laravel-multilang

Package to integrate multi language (multi locale) functionality in Laravel 5.x

5514.4k1](/packages/longman-laravel-multilang)[zachleigh/laravel-lang-bundler

Create Laravel translations bundles.

2512.5k](/packages/zachleigh-laravel-lang-bundler)[igaster/laravel-translate-eloquent

Description

403.4k](/packages/igaster-laravel-translate-eloquent)

PHPackages © 2026

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