Package Data | |
---|---|
Maintainer Username: | deargonaut |
Maintainer Contact: | mail@deargonauten.com (Jason de Ridder) |
Package Create Date: | 2016-06-29 |
Package Last Update: | 2016-07-05 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-22 03:17:33 |
Package Statistics | |
---|---|
Total Downloads: | 23 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
[![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
deArgonauten\TransLaravel\TransLaravelServiceProvider::class,
An artisan command is now available. Run it.
$ php artisan translaravel:install
And... DONE!
First add a language by doing:
Lang::addLanguage('locale');
// en, nl, de, fr, et cetera
See full list: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
trans('A string, even with <b>some</b> HTML');
Lang::get('A string, even with <b>some</b> HTML');
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');
In your routes file you can use the translations as follow:
Route::get(
Lang::route('/this-is-a-page'), function()
{
return view('pages.contact');
});
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.
untranslateURL('url');
// 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](https://github.com/deargonauten/TransLaravel/blob/master/CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/deargonauten/TransLaravel/blob/master/CONTRIBUTING.md) and [CONDUCT](https://github.com/deargonauten/TransLaravel/blob/master/CONDUCT.md) for details.
## Security
If you discover any security related issues, please email mail@deargonauten.com instead of using the issue tracker.
## Credits
- [Jason de Ridder][http://deargonauten.com]
## License
The MIT License (MIT). Please see [License File](https://github.com/deargonauten/TransLaravel/blob/master/LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/deArgonauten/TransLaravel.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/deArgonauten/TransLaravel/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/deArgonauten/TransLaravel.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/deArgonauten/TransLaravel.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/deArgonauten/TransLaravel.svg?style=flat-square
[link-packagist]: https://packagist.org/packages/deArgonauten/TransLaravel
[link-travis]: https://travis-ci.org/deArgonauten/TransLaravel
[link-scrutinizer]: https://scrutinizer-ci.com/g/deArgonauten/TransLaravel/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/deArgonauten/TransLaravel
[link-downloads]: https://packagist.org/packages/deArgonauten/TransLaravel