PHPackages                             andrewdwallo/transmatic - 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. andrewdwallo/transmatic

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

andrewdwallo/transmatic
=======================

Automate and streamline real-time text translations in your Laravel applications

v1.2.0(1y ago)5511.6k↑144.4%4[4 PRs](https://github.com/andrewdwallo/transmatic/pulls)MITPHPPHP ^8.1CI passing

Since Oct 27Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/andrewdwallo/transmatic)[ Packagist](https://packagist.org/packages/andrewdwallo/transmatic)[ Docs](https://github.com/andrewdwallo/transmatic)[ RSS](/packages/andrewdwallo-transmatic/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (15)Used By (0)

[![Transmatic Banner](art/transmatic-banner.png)](art/transmatic-banner.png)

 [![Laravel v10.x](https://camo.githubusercontent.com/bfea501efe5759f52cfebee79ebb907199c9e88ae0bd65948d40ba67a1ad73fa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631302e782d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://laravel.com) [![PHP 8.1](https://camo.githubusercontent.com/f828b436a9f10bce9f30864883ab5b07c5f9bd5e21bf275312ad61f37dedce3b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://php.net) [![Latest Version on Packagist](https://camo.githubusercontent.com/6c79c3200860feacbba45746a21d1a37db198e70c2a85c6c271841fa0e46fe67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e647265776477616c6c6f2f7472616e736d617469632e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/andrewdwallo/transmatic) [![Total Downloads](https://camo.githubusercontent.com/cc6ab497d9ff8d4a1f8d9d30220ea12830a6464e38b01fcfd76596f6d5f6ac46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e647265776477616c6c6f2f7472616e736d617469632e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/andrewdwallo/transmatic)

Transmatic is a Laravel package for real-time machine translation, enabling instant and dynamic translation across your entire application. Suitable for projects ranging from simple websites to complex SaaS platforms and more, Transmatic offers customization and flexibility. Using advanced machine translation, it makes your app globally accessible. While [AWS Translate](https://aws.amazon.com/translate/) is the default engine, the package can easily integrate with other translation services.

Common Use Cases
----------------

[](#common-use-cases)

### ⚡️ Application Auto-Translation

[](#️-application-auto-translation)

With this package, developers can automatically translate their entire application to multiple languages using services like AWS Translate. Say goodbye to manually specifying translations for each language and achieve a multilingual platform in minutes.

#### Benefits

[](#benefits)

- **Speed** - Translate your application in minutes.
- **Auto Locale Management** - The package manages and updates the source locale translations based on the provided text.

### 👤 Personalized User Experience

[](#-personalized-user-experience)

Empower users to customize their experience by selecting their preferred language. Once selected, the application dynamically adjusts its locale.

#### Benefits

[](#benefits-1)

- **Enhanced User Experience** - Interact in the user's native language.
- **Real-Time Translation** - Adapt instantly to the user's language selection.

### 🏢 SaaS Tenant-Specific Translations

[](#-saas-tenant-specific-translations)

Optimize the experience for SaaS businesses by offering tenant-specific translations. Each tenant can view their dashboard in their desired language.

#### Benefits

[](#benefits-2)

- **Personalization** - Address each tenant's language choice.
- **Engagement Boost** - Increase interaction by presenting content in the tenant's chosen language.

### 🛍️ E-Commerce for a Global Audience

[](#️-e-commerce-for-a-global-audience)

Position your e-commerce platform or global marketplace for worldwide reach. Offer product descriptions, reviews, and more in numerous languages.

#### Benefits

[](#benefits-3)

- **Global Reach** - Cater to a global audience.
- **Enhanced Sales** - Improve conversion rates by engaging customers in their native language.

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

[](#installation)

Start by installing the package via Composer:

```
composer require andrewdwallo/transmatic
```

After the package is installed, run the following command:

```
php artisan transmatic:install
```

Setting Up Transmatic
---------------------

[](#setting-up-transmatic)

### Queue and Batch Processing Setup

[](#queue-and-batch-processing-setup)

This package utilizes Laravel's queue jobs and batch processing features. The specific setup requirements depend on the queue driver configured in your Laravel application.

#### Database Queue Driver

[](#database-queue-driver)

If you are using the database queue driver, you'll need the following tables in your database:

- `jobs`: For managing queued jobs.
- `job_batches`: For batch processing.

If these tables are not already present in your database, you can create them by running the following commands:

```
php artisan queue:table
php artisan queue:batches-table
```

Once the tables are created, run the following command to migrate them:

```
php artisan migrate
```

For users utilizing other queue drivers (such as redis, sqs, beanstalkd, etc.), refer to the [official Laravel documentation on queues](https://laravel.com/docs/10.x/queues#introduction) for specific setup instructions.

> 🚧 It's important to configure and manage the queue system as per your application's requirements. Proper configuration ensures efficient handling of background jobs and tasks by the package.

### AWS Translate Integration

[](#aws-translate-integration)

By default, the package leverages [AWS Translate](https://aws.amazon.com/translate/). Ensure you've set the necessary configurations as specified in the [AWS Service Provider for Laravel](https://github.com/aws/aws-sdk-php-laravel)documentation, and have the following environment variables:

```
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
AWS_REGION=your-region  # default is us-east-1
```

These are essential for the AWS SDK to authenticate and interact with AWS services. Once these are set, you don't need to do anything else for AWS Translate to work.

### Custom Translation Service Integration

[](#custom-translation-service-integration)

While AWS Translate is the default, Transmatic allows integration with other translation services. For integration, create a class that adheres to the `Wallo\Transmatic\Contracts\Translator` contract and update the `transmatic.php`config file accordingly.

### Configuration Overview

[](#configuration-overview)

Several configuration options are available, including setting the source locale, defining translation storage methods ( cache or JSON files), and specifying batch processing behavior. Refer to the `config/transmatic.php` file for a comprehensive look.

Using Transmatic
----------------

[](#using-transmatic)

### Translating Text

[](#translating-text)

The `translate` method provides an easy way to translate a single string of text. It allows you to optionally specify replacement data for placeholders as well as the target locale. If the target locale is not specified, the application's current locale will be used.

#### Using Traditional Arguments:

[](#using-traditional-arguments)

```
use Wallo\Transmatic\Facades\Transmatic;

$translatedText = Transmatic::translate('Hello World', [], 'es'); // Hola Mundo
```

#### Using Named Arguments (PHP 8.0+):

[](#using-named-arguments-php-80)

```
use Wallo\Transmatic\Facades\Transmatic;

$translatedText = Transmatic::translate(text: 'Hello World', to: 'es'); // Hola Mundo
```

This method also updates the translations in your Source Locale based on the text passed in, ensuring that new strings are stored for future use.

### Translating Multiple Strings

[](#translating-multiple-strings)

For translating multiple strings at once, use the `translateMany` method. This method accepts an array of strings to translate, as well as an optional target locale. If not specified, the application's current locale will be used.

```
use Wallo\Transmatic\Facades\Transmatic;

$texts = ['Hello World', 'Goodbye World'];

$translatedTexts = Transmatic::translateMany(texts: $texts, to: 'fr'); // ['Bonjour le monde', 'Au revoir le monde']
```

Like the `translate` method, this method will also update the translations in your Source Locale based on the text passed in.

### Using Translation Placeholders

[](#using-translation-placeholders)

You may use placeholders in your translations. To do so, use the `:placeholder` syntax in your translation strings. When translating, pass in an array of values to replace the placeholders.

```
use Wallo\Transmatic\Facades\Transmatic;

$translatedText = Transmatic::translate(text: 'Hello :name', replace: ['name' => 'John'], to: 'es'); // Hola John
```

### Fetching Supported Locales

[](#fetching-supported-locales)

To retrieve a list of supported locales, use the `getSupportedLocales` method. This method will return an array of locales supported by your application. For example, if in your specified file path for storing translations you have a `fr.json` file, this method will return `['en', 'fr']`.

```
use Wallo\Transmatic\Facades\Transmatic;

$supportedLocales = Transmatic::getSupportedLocales(); // ['en', 'fr']
```

### Fetching Supported Languages

[](#fetching-supported-languages)

To retrieve a list of supported languages along with their corresponding locales, use the `getSupportedLanguages`method. This method returns an associative array where the key is the locale and the value is the displayable name of the language. You can also pass a display locale as an optional parameter to get the language names in a specific language. If no display locale is specified, the application's current locale is used.

```
use Wallo\Transmatic\Facades\Transmatic;

$supportedLanguages = Transmatic::getSupportedLanguages();
// Output: ['en' => 'English', 'fr' => 'French']

$supportedLanguages = Transmatic::getSupportedLanguages(displayLocale: 'fr');
// Output: ['en' => 'Anglais', 'fr' => 'Français']
```

### Getting Language from Locale

[](#getting-language-from-locale)

You can get the displayable name of a language from a locale using the `getLanguage` method. This method takes in the locale you're interested in and an optional display locale parameter. If no display locale is specified, it defaults to the application's current locale.

```
use Wallo\Transmatic\Facades\Transmatic;

$language = Transmatic::getLanguage(locale: 'de');
// Output: 'Deutsch'

$language = Transmatic::getLanguage(locale: 'de', displayLocale: 'en');
// Output: 'German'
```

### Global Helper

[](#global-helper)

For quick and easy translations, you may use the `translate()` and `translateMany()` helper functions.

```
$translatedText = translate(text: 'Hello World', to: 'es'); // Hola Mundo

$translatedTexts = translateMany(texts: ['Hello World', 'Goodbye World'], to: 'fr'); // ['Bonjour le monde', 'Au revoir le monde']
```

Overriding the Global Locale
----------------------------

[](#overriding-the-global-locale)

If you want to override the default locale for all translation methods that do not have a specified `$to` parameter, you can use the `setGlobalLocale` method. This will set a global locale override, ensuring that the provided locale is used as the default for translations.

### Setting the Global Locale in a Service Provider

[](#setting-the-global-locale-in-a-service-provider)

In your Service Provider's `boot` method, you can call the `setGlobalLocale` method to set the global locale override.

```
use Wallo\Transmatic\Facades\Transmatic;

public function boot()
{
    Transmatic::setGlobalLocale(locale: 'fr');
}
```

When you use the translation methods after setting this global locale, they will default to this overridden locale unless another locale is specified.

#### Example

[](#example)

```
use Wallo\Transmatic\Facades\Transmatic;

Transmatic::setGlobalLocale(locale: 'fr');

$translatedText = Transmatic::translate(text: 'Hello World'); // Bonjour le monde
```

Remember, specifying a locale in the translation methods will always take precedence over the global locale override.

```
use Wallo\Transmatic\Facades\Transmatic;

Transmatic::setGlobalLocale(locale: 'fr');

$translatedText = Transmatic::translate(text: 'Hello World', to: 'es'); // Hola Mundo
```

Processing Missing Translations
-------------------------------

[](#processing-missing-translations)

To ensure all your translations are up-to-date, especially when there are missing translations for certain locales, you can utilize the functionality to process missing translations. This will help in generating the missing translations for all the supported locales excluding the source locale.

### Using the Facade in a Service Provider

[](#using-the-facade-in-a-service-provider)

In your Service Provider's `boot` method, you have two options when calling the facade to process missing translations:

#### Specifying Locales

[](#specifying-locales)

You can process missing translations for a specific list of locales using the `processMissingTranslationsFor` method.

```
use Wallo\Transmatic\Facades\Transmatic;

public function boot()
{
    Transmatic::processMissingTranslationsFor(locales: ['fr', 'de']);
}
```

#### Processing All Supported Locales

[](#processing-all-supported-locales)

You can process all the missing translations for all the supported locales excluding the source locale using the processMissingTranslations method.

```
use Wallo\Transmatic\Facades\Transmatic;

public function boot()
{
    Transmatic::processMissingTranslations();
}
```

### Using the Artisan Command

[](#using-the-artisan-command)

If you would prefer to manually trigger the processing of missing translations, you may use the console command `transmatic:process-missing-translations`. This command will provide you with a list of all the supported locales excluding the source locale, and you can choose which locales you would like to process. You may choose to process all the locales at once by selecting the `All` option.

This command is especially useful during development when you're adding new translations to your source locale and want to process the missing translations for all the supported locales.

```
php artisan transmatic:process-missing-translations
```

### Cleaning Translations

[](#cleaning-translations)

You can use the `transmatic:clean-translations` command to remove keys from translation files that are no longer present in the source locale. This helps keep your translations consistent and avoids unused entries.

Run the command with:

```
php artisan transmatic:clean-translations
```

This will clean all supported locales, excluding the source locale.

Behind the Scenes
-----------------

[](#behind-the-scenes)

### Managing Translations

[](#managing-translations)

When you call the `translate` or `translateMany` methods, Transmatic will first check to see if the translation already exists in your application's source locale. If it does, it will process and return the translations for the specified target locale. If not, it will update your source locale's translations with the new text, and then continue with the translation process.

Transmatic checks if a batch translation process is running for the target locale you specify. If a batch is running, the package fetches the translations from either cache or JSON language files, depending on your configuration.

### New vs. Existing Translations

[](#new-vs-existing-translations)

For new target locales, Transmatic initiates a queued batch translation process managed by the underlying `TranslateService` class. This allows the package to efficiently handle large volumes of text for translation in one go, thanks to a queuing mechanism.

For existing target locales where most translations are already in place, the `dispatchSync` method is used for immediate, synchronous translation.

### Importance of a Robust Source Locale

[](#importance-of-a-robust-source-locale)

To make the most out of the batch processing feature for new target locales, it's recommended to have a well-populated source locale language file. While the code ensures that the source locale is up-to-date before proceeding with translations, having a robust set of translations in the source locale maximizes the efficiency of the batch processing for new languages.

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

[](#contributing)

Thank you for considering contributing to Transmatic! Follow these steps to get started:

1. **Fork the Repository**: Fork this repository to your GitHub account.
2. **Create a Fresh Laravel Project**: If you don't already have a Laravel project set up, create one.
3. **Clone Your Forked Repository**: Clone your forked Transmatic repository into your Laravel application's root directory.

```
git clone https://github.com/your-github-username/transmatic.git
```

4. **Create a New Branch**: Inside the '/transmatic' directory, create a branch for your fix or feature. For instance, if you're working on an error message fix, you might name your branch `fix/error-message`.

```
git checkout -b fix/error-message
```

5. **Install the Package Locally**: Update your application's `composer.json` file to include the local package. Use the `dev` prefix followed by your branch's name:

```
{
    // ...
    "require": {
        "andrewdwallo/transmatic": "dev-fix/error-message"
    },
    "repositories": [
        {
            "type": "path",
            "url": "transmatic/"
        }
    ],
    // ...
}
```

6. **Update Composer**: Run `composer update` to install the local version of the package in your Laravel project.

Once you've made your changes, commit them, push to your branch, and then create a pull request. Your contributions are highly valued and appreciated!

Need Help?
----------

[](#need-help)

Thank you for your interest in Transmatic! Whether you're just getting started, have spotted a bug, or are thinking of a new feature, here's how you can get help:

### 🐛 Spotted a Bug?

[](#-spotted-a-bug)

If you think you've found a bug in Transmatic:

1. First, check the [Issues](https://github.com/andrewdwallo/transmatic/issues) section to see if someone else has already reported the same problem.
2. If it's an unreported bug, please open a new issue, providing as much detail as possible, including steps to reproduce the issue.
3. Feel free to fix the bug yourself! Follow the [Contributing](#contributing) guidelines to get started.

### 🙋‍♂️ Have a Question or Feature Request?

[](#‍️-have-a-question-or-feature-request)

If you have questions about how to use Transmatic or ideas for new features:

1. Start by checking the [Documentation](#installation) to see if your question is already answered.
2. For specific questions or general discussion, visit [Discussions](https://github.com/andrewdwallo/transmatic/discussions).
    - Have a question? Head over to [Q&amp;A](https://github.com/andrewdwallo/transmatic/discussions/categories/q-a).
    - Want to share an idea or feature request? Share it in [Feature Requests](https://github.com/andrewdwallo/transmatic/discussions/categories/feature-requests).

### 🔐 Discovered a Security Vulnerability?

[](#-discovered-a-security-vulnerability)

Security is a top priority. If you discover any issue regarding security:

1. Please **DO NOT** open an issue on GitHub. Disclosing security vulnerabilities publicly can be harmful.
2. Instead, review the [Security Policy](../../security/policy) for instructions on how to report a security vulnerability.
3. I'm dedicated to keeping users safe and will address valid security concerns diligently.

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

48

—

FairBetter than 94% of packages

Maintenance68

Regular maintenance activity

Popularity38

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.3% 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 ~54 days

Recently: every ~121 days

Total

10

Last Release

443d ago

### Community

Maintainers

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

---

Top Contributors

[![andrewdwallo](https://avatars.githubusercontent.com/u/104294090?v=4)](https://github.com/andrewdwallo "andrewdwallo (58 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

laravellocalizationawstranslationstranslationandrewdwallotransmatic

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/andrewdwallo-transmatic/health.svg)

```
[![Health](https://phpackages.com/badges/andrewdwallo-transmatic/health.svg)](https://phpackages.com/packages/andrewdwallo-transmatic)
```

###  Alternatives

[kkomelin/laravel-translatable-string-exporter

Translatable String Exporter for Laravel

3291.4M10](/packages/kkomelin-laravel-translatable-string-exporter)[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.

590244.8k1](/packages/askdkc-breezejp)[outhebox/laravel-translations

Manage your Laravel translations with a beautiful UI. Add, edit, delete, import, and export translations with ease.

80687.6k](/packages/outhebox-laravel-translations)[laravel-lang/locales

Basic functionality for working with localizations

134.5M12](/packages/laravel-lang-locales)[kenepa/translation-manager

Manage your application's translation strings in Filament.

14583.6k2](/packages/kenepa-translation-manager)[smousss/laravel-globalize

Make Laravel projects translatable in a matter of seconds!

2266.3k](/packages/smousss-laravel-globalize)

PHPackages © 2026

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