PHPackages                             rpwebdevelopment/laravel-translate - 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. rpwebdevelopment/laravel-translate

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

rpwebdevelopment/laravel-translate
==================================

Package for generating translated language files

3.0.0(3mo ago)1763MITPHPPHP ^8.2|^8.3CI passing

Since Nov 27Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/rpwebdevelopment/laravel-translate)[ Packagist](https://packagist.org/packages/rpwebdevelopment/laravel-translate)[ Docs](https://github.com/rpwebdevelopment/laravel-translate)[ GitHub Sponsors](https://github.com/RPWebDevelopment)[ RSS](/packages/rpwebdevelopment-laravel-translate/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (11)Versions (17)Used By (0)

Laravel Translate
=================

[](#laravel-translate)

[![Packagist Version](https://camo.githubusercontent.com/a89267e58ed1dffc504f32d96b38b320351133612637fc9344531cb15633d03a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7270776562646576656c6f706d656e742f6c61726176656c2d7472616e736c617465)](https://camo.githubusercontent.com/a89267e58ed1dffc504f32d96b38b320351133612637fc9344531cb15633d03a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7270776562646576656c6f706d656e742f6c61726176656c2d7472616e736c617465)[![Packagist Downloads](https://camo.githubusercontent.com/f5adb407d23d5568615edca339de2054fb4187e707734c1db7210e8abf6b98cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7270776562646576656c6f706d656e742f6c61726176656c2d7472616e736c617465)](https://camo.githubusercontent.com/f5adb407d23d5568615edca339de2054fb4187e707734c1db7210e8abf6b98cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7270776562646576656c6f706d656e742f6c61726176656c2d7472616e736c617465)[![License: MIT](https://camo.githubusercontent.com/0d72c4cb15193b9e2e0f21dfc6ce0c8a1f49edd2719e2f9550808afd5e329576/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c756576696f6c65742e737667)](https://github.com/DeepLcom/deepl-php/blob/main/LICENSE)

Laravel Translate is a tool intended to automatically generate translated language files. Currently, the package leverages either [DeepL API](https://github.com/DeepLcom/deepl-php), [Amazon Translate](https://aws.amazon.com/translate/) or the amazing [Google Translate](https://github.com/Stichoza/google-translate-php) package from [Stichoza](https://github.com/Stichoza) which allows for zero configuration usage.

The default configuration makes use of Google translations and can be used straight out of the box with no sign-up or configuration. If you would rather use the DeepL translations API you will need to sign up [here](https://www.deepl.com/en/pro#developer); DeepL configuration details described below.

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

[](#installation)

You can install the package via composer:

```
composer require rpwebdevelopment/laravel-translate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="translate-config"
```

This is the contents of the published config file:

```
return [
    'reader' => 'php',
    'default_source' => 'en_GB',
    'target_locales' => [],
    'lang_directory' => base_path('resources/lang'),
    'provider' => 'google',
    'providers' => [
        'google' => [
            'package' => GoogleTranslate::class,
        ],
        'deepl' => [
            'package' => DeeplTranslate::class,
            'token' => env('DEEPL_AUTH_TOKEN', null),
            'model_type' => 'prefer_quality_optimized',
            'formality' => 'default',
        ],
        'aws' => [
            'package' => AwsTranslate::class,
            'credentials' => [
                'key' => env('AWS_ACCESS_KEY_ID', null),
                'secret' => env('AWS_SECRET_ACCESS_KEY', null),
            ],
            'settings' => [
                "Formality" => "FORMAL"
            ],
            "region" => env('AWS_DEFAULT_REGION', "us-east-1"),
            "version" => "latest",
        ],
    ],
    'readers' => [
        'php' => PhpReader::class,
        'json' => JsonReader::class,
    ],
    'writers' => [
        'php' => PhpWriter::class,
        'json' => JsonWriter::class,
    ],
];
```

DeepL Configuration
-------------------

[](#deepl-configuration)

In order to make use of the DeepL API you will need to publish the config file as detailed above and update the provider to `deepl`. You will then need to add your DeepL API auth token to your `.env` file under the env variable `DEEPL_AUTH_TOKEN`.

Amazon Configuration
--------------------

[](#amazon-configuration)

In order to make use of the AWS Translate API you will need to publish the config file as detailed above and update the provider to `aws`. You will then need to ensure that you `.env` file contains the required AWS variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` &amp; `AWS_DEFAULT_REGION`.

#### Note:

[](#note)

You will need to ensure that the AWS IAM role has the permission policy `TranslateFullAccess` .

Defining Locales
----------------

[](#defining-locales)

When configuring target languages it is important to follow the below conventions:

```
'target_locales' => [
    [FILE/DIR PATH] => [
        'lang' => [LANG CODE],
        'formality' => [OPTIONAL FORMALITY]
    ]
],
```

#### Example:

[](#example)

```
'target_locales' => [
    'de_DE_formal' => [
        'lang' => 'de_DE',
    ],
    'de_DE_casual' => [
        'lang' => 'de_DE',
        'formality' => 'less_formal',
    ],
]
```

The above would output two different German language translations; one using more formal language and one using less formal language

#### Note:

[](#note-1)

Formality is currently only available for DeepL and AWS translations. This setting will have no impact when using Google translate.

Usage
-----

[](#usage)

This package is designed to function with as much flexibility as possible, as such it is designed to work for multiple configurations with minimal setup, whether you have a single file or directory per language, or if you are using PHP lang files or JSON lang files.

```
php artisan laravel-translate {target} {--source=?} {--file=?} {--missing-only}
```

### Options:

[](#options)

CommandRequiredDescription`target`requiredSet locale/language to be translated into.`--source=`optionalSet locale/language source being translated from.`--file=`optionalSet specific filename being translated from &amp; into.`--missing-only`optionalFlag only missing values need to be translated/added.### Bulk Processing

[](#bulk-processing)

Rather than processing each target language manually you can add all your target locales to the `target_locales` option in the translations configuration file, this will enable the usage of the bulk translate command:

```
php artisan laravel-translate:bulk {--source=?} {--file=?} {--missing-only}
```

### Options:

[](#options-1)

CommandRequiredDescription`--source=`optionalSet locale/language source being translated from.`--file=`optionalSet specific filename being translated from &amp; into.`--missing-only`optionalFlag only missing values need to be translated/added.### Key Validation

[](#key-validation)

If you simply wish to ascertain if translations are missing from your project you can implement the missing command:

```
php artisan laravel-translate:bulk {--verbose}
```

### Options:

[](#options-2)

CommandRequiredDescription`--verbose`optionalFlag to indicate if full details of missing keys are required.This command can be used in conjunction with git-hooks in order to prevent changes being deployed to your repository with missing translations, this can be done by adding the following bash script to your `.git/hooks/pre-commit`:

```
#! /bin/bash

missing="$( php artisan laravel-translate:missing )"

if [ "$missing" = "translations missing" ];then
  echo "Translations Missing";
  exit 0
fi
```

Example Usages
--------------

[](#example-usages)

### Directory Structure:

[](#directory-structure)

Example directory structure:

```
resources
|----lang
     |----en_GB
          |----auth.php
          |----global.php
```

Assuming the config `default_source` is set to `en_GB`; for the above structure the following command:

```
php artisan laravel-translate fr_FR
```

Would produce the following structure:

```
resources
|----lang
     |----en_GB
     |    |----auth.php
     |    |----global.php
     |----fr_FR
          |----auth.php
          |----global.php
```

Alternately, you can explicitly declare the source locale:

```
php artisan laravel-translate fr_FR --source=en_GB
```

If you are only wanting to replace a specific file you can also pass in the file option (note the file extension is optional):

```
php artisan laravel-translate fr_FR --source=en_GB --file=auth
```

### Single File Structure

[](#single-file-structure)

If you are using a single file per language rather than a directory structure as below:

```
resources
|----lang
     |----en_GB.php
     |----fr_FR.php
```

You can use the exact same command syntax, so the following:

```
php artisan laravel-translate de_DE --source=en_GB
```

Would result in the following output:

```
resources
|----lang
     |----en_GB.php
     |----fr_FR.php
     |----de_DE.php
```

Notes
-----

[](#notes)

- Any existing translations will be overridden, it is recommended that you back-up any previously created lang files to allow for easy restoration if required.
- Translations are a result of machine translation and therefore some translation errors may occur.
- While efforts have been made to persist lang string attributes, their persistence cannot be 100% guaranteed, as such it is recommended to verify your files after production.

Credits
-------

[](#credits)

- [Richard Porter](https://github.com/rpwebdevelopment)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance78

Regular maintenance activity

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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

Recently: every ~100 days

Total

14

Last Release

117d ago

Major Versions

1.3.1 → 2.0.02025-01-24

2.1.0 → 3.0.02026-02-27

PHP version history (2 changes)1.0.0PHP ^8.2

3.0.0PHP ^8.2|^8.3

### Community

Maintainers

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

---

Top Contributors

[![rpwebdevelopment](https://avatars.githubusercontent.com/u/15613749?v=4)](https://github.com/rpwebdevelopment "rpwebdevelopment (14 commits)")

---

Tags

laravelrpwebdevelopmentlaravel translate

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/rpwebdevelopment-laravel-translate/health.svg)

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

###  Alternatives

[lunarstorm/laravel-ddd

A Laravel toolkit for Domain Driven Design patterns

18476.4k](/packages/lunarstorm-laravel-ddd)[askdkc/breezejp

Laravel Starter Kit (Livewire+Breeze+Laravel UI+Jetstream)や標準のバリデーションメッセージを全て一瞬で日本語化し、言語切替機能も提供するパッケージです / This package provides all-in-one Japanese translation for Laravel StarterKit (Livewire StarterKit, Breeze, Laravel UI and Jetstream) packages and validation messages with language switching feature.

593266.8k1](/packages/askdkc-breezejp)[bezhansalleh/filament-language-switch

Zero config Language Switch(Changer/Localizer) plugin for filamentphp admin

3561.2M23](/packages/bezhansalleh-filament-language-switch)[elegantly/laravel-translator

All on one translations management for Laravel

6326.3k](/packages/elegantly-laravel-translator)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[osama-98/laravel-enum-translatable

A Laravel package that provides translatable enum functionality with easy-to-use methods for working with enum values and their translations

561.1k](/packages/osama-98-laravel-enum-translatable)

PHPackages © 2026

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