An open API service indexing awesome lists of open source software.

https://github.com/atomjoy/trans

Laravel translations from the database.
https://github.com/atomjoy/trans

laravel-translation laravel-translations

Last synced: 3 months ago
JSON representation

Laravel translations from the database.

Awesome Lists containing this project

README

        

# Laravel Translations

Laravel translations from database.

## Install

```sh
composer require "atomjoy/trans"

composer update
composer dump-autoload -o
```

## Migrate, locales

```sh
# locales
php artisan lang:publish

# update tables
php artisan migrate

# new tables
php artisan migrate:fresh
```

## Laravel trans

lang/pl.json

```json
{
"This text not exists in db": "Ten tekst nie istnieje w bazie danych"
}
```

## Examples

routes/web.php

```php
setLocale('pl');

// If exists in db
echo "
PL " . trans_db('Hello');

// If not exists in db get translation from default trans() helper
echo "
PL " . trans_db('This text not exists in db');

} catch (Exception $e) {
report($e);
return 'Errors ...';
}
});
```