PHP code example of blackstone / laravel-model-translations-sync

1. Go to this page and download the library: Download blackstone/laravel-model-translations-sync library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

blackstone / laravel-model-translations-sync example snippets


use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
use BlackstonePro\ModelTranslationsSync\Traits\ModelTranslatable;

class Product extends Model
{
    use HasTranslations;
    use ModelTranslatable;

    protected $fillable = ['title', 'description'];

    public array $translatable = ['title', 'description'];
}

'sync' => [
    'stop_on_error' => true,
    'pipeline' => [
        ['command' => 'translations:export-models', 'enabled' => true],
        ['command' => 'crowdin:upload', 'enabled' => true],
        ['command' => 'crowdin:download', 'enabled' => true],
        ['command' => 'translations:import-models', 'enabled' => true],
        ['command' => 'translations:export-files', 'enabled' => true],
    ],
],

return [
    'product' => [
        12 => [
            'title' => 'iPhone',
            'description' => 'Smartphone',
        ],
    ],
];
bash
php artisan vendor:publish --tag=model-translations-config
text
group = models.product
key = 12.title
text = {"en":"iPhone","fr":"iPhone"}
bash
php artisan translations:export-models {model?} {--fresh} {--chunk=500} {--dry-run}
bash
php artisan translations:export-files {--dry-run}
bash
php artisan translations:sync {--dry-run}
bash
php artisan translations:make-translatable-migration
    {name?}
    {--paths=*}
    {--locale=en}
    {--chunk=500}
    {--force}