Reputation: 229
I'm trying to get the multi language feature in Backpack working. I've followed all steps that are present in the documentation. I am able to add the values in the languages I've defined. I can also edit these values except for the default language. I'm getting an undefined index 'nl' error.
The defined languages are following: nl (Dutch), fr (French), en (English).
I've tried changing my default language and see how the applications reacts to it but I'm facing the same issue on the main (defined in config/app.php) language.
I've also downgraded laravel-translatable to v 3.x as the Backpack changelog doesn't mention any support to the v 4.x of that package. Now I'm back on the v4 as it made no difference.
Currently in my composer file I have this: "backpack/base": "^0.9.7", "backpack/crud": "^3.3.0", "backpack/permissionmanager": "^2.1", "backpack/settings": "^2.0", "intervention/image": "^2.4", "laravel/framework": "5.7.*", "spatie/laravel-translatable": "^4.0"
My crud config:
'show_translatable_field_icon' => true,
'translatable_field_icon_position' => 'right',
'locales' => [
'nl',
'fr',
'en'
],
The mode I want to apply translations to:
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
use Backpack\CRUD\ModelTraits\SpatieTranslatable\HasTranslations;
class Supplier extends Model
{
use CrudTrait;
use HasTranslations;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'suppliers';
protected $fillable = [
'name'
];
protected $translatable = ['name'];
A value in my table looks like this: {"nl":"Leverancier x nl","1":"Leverancier x fr"}
I need to also be able to edit the default language. As for now I don't see where it's going wrong.
Upvotes: 1
Views: 961
Reputation: 229
In case someone encounters the same issue... Fairly logic this didn't work.
You should declare locals like this:
'locales' => [
'nl' => 'Dutch',
'fr' => 'French',
'en' => 'English'
],
Upvotes: 2