A Laravel package which translates all. Routes, models (trait) and strings (gettext-style).

1.0.3 2016-07-05 10:23 UTC

This package is not auto-updated.

Last update: 2021-04-17 00:44:57 UTC


[![Latest Version on Packagist][ico-version]][link-packagist] ![Software License][ico-license] [![Build Status][ico-travis]][link-travis] [![Coverage Status][ico-scrutinizer]][link-scrutinizer] [![Quality Score][ico-code-quality]][link-code-quality] [![Total Downloads][ico-downloads]][link-downloads]


Via Composer

$ composer require deArgonauten/TransLaravel

Add the ServiceProvider in: config/app.php


An artisan command is now available. Run it.

$ php artisan translaravel:install

And... DONE!


First add a language by doing:

// en, nl, de, fr, et cetera

See full list:

String Translations

trans('A string, even with <b>some</b> HTML');
Lang::get('A string, even with <b>some</b> HTML');

Model translations

In your models use the Translations Trait like this:

use deArgonauten\TransLaravel\Translations;

class YourModel extends Model
	use Translations;
	private $translatable = ['attribute1', 'attribute2']

Use the variable $translatable to fill an array with translatable attributes.

Now you can use:

$model->name; // It will automaticly fetch the translation set in Application.
$model->getTranslationFor('attribute', 'locale');

Route translations

In your routes file you can use the translations as follow:

	Lang::route('/this-is-a-page'), function()
		return view('');

Helper functions

We hook you up with some helper functions

translateURL('url', 'locale');
// Returns a link in the requested locale.
// By omiting the locale parameter it will fetch the current set language.

// Returns a link in the default language

translateLink('url', 'name', [parameters], locale);
// Returns something like this: <a href="translateURL('url')" class="this and that">trans('name')</a>

## Change log

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

## Contributing

Please see [CONTRIBUTING]( and [CONDUCT]( for details.

## Security

If you discover any security related issues, please email instead of using the issue tracker.

## Credits

- [Jason de Ridder][]

## License

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