worksome/translator

A driver-based translation package for Laravel

Fund package maintenance!
worksome

v0.3.1 2024-02-13 14:45 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status Total Downloads

A driver-based translation package for Laravel.

Installation

You can install the package via composer:

composer require worksome/translator

You can publish the config file with:

php artisan vendor:publish --tag="translator-config"

Usage

$translator = new Worksome\Translator\TranslationManager();

$translator->driver('google_cloud_translate')->translate('Text to translate', 'en', 'da'); // TranslationDTO
$translator->driver('google_cloud_translate')->detectLanguage('Text to detect'); // DetectedLanguageDTO

// Via the Facade
use Worksome\Translator\Facades\Translator;

Translator::translate(''); // Use the default driver
Translator::driver('google_cloud_translate')->translate('', 'en', 'da'); // Use a custom driver

Test suites can utilise the null driver, this will always return the same string value as provided for translations.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.