Comments (16)
Comming soon. Stay tuned!
from laravel-translatable.
Hello Dimitious,
When are you planning to release it? Just to know, because have a project that I'm migrating to v5.0, and this is one of the packages that I'm waiting for. If there is something that can help, just let me know it.
Thank you and best regards,
Pedro
from laravel-translatable.
Hello folks,
I created a laravel 5 branch of this package. Can you try it and tell me how it works?
from laravel-translatable.
Hi,
Right now I'm testing it, but I'm dealing with an error "Trait 'Dimsav\Translatable\Translatable' not found". But I keep trying, because I just imported a little portion of my project and maybe is my fault the error.
Thank you and Best Regards,
Pedro
from laravel-translatable.
Sorry,
As I installed it from git, had to add the package path to autoload. Now continue testing it.
Best Regards and thank you
Pedro
from laravel-translatable.
Thanks for the info. I will check the autoloading issue and keep you up to date
from laravel-translatable.
Hello,
For me it is working very well. I was having another issue, but was related to my key field name that is language_id. But I overwrited it in the model and everything now works fine.
Best regards and thank you
from laravel-translatable.
@plmarcelo thanks for the feedback.
@nWidart please write here if you have any issues with L5.
from laravel-translatable.
For what I've tested until now:
-
The getters work fine
$model->property
-
The mass assignment setters do not work. Ie:
$model->create([ 'fr' => ['name' => 'Grèce'], 'en' => ['name' => 'Greek'], ]);
I had to loop over the properties in the different languages.
from laravel-translatable.
Hi, I did this and it worked fine for me:
$data = array(
'show_order' => 4,
'en' => array('label' => 'Category 4'),
'es' => array('label' => 'Categoría 4'),
);
$category = FaqCategory::create($data);
Maybe, you have a required field on main table and you are not filling it. Could be?
from laravel-translatable.
Hm I don't think so. I'll give it another shot tonight and give a heads up here.
from laravel-translatable.
Now with this, doing $category->update($data)
returns preg_replace(): Parameter mismatch, pattern is a string while replacement is an array
.
Same with Category::create($data)
.
My Category
model:
<?php namespace Modules\Blog\Entities;
use Dimsav\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
use Translatable;
public $translatedAttributes = ['name', 'slug'];
protected $fillable = ['name', 'slug'];
public function posts()
{
return $this->belongsToMany('Post');
}
}
My Category translation model:
<?php namespace Modules\Blog\Entities;
use Illuminate\Database\Eloquent\Model;
class CategoryTranslation extends Model
{
public $timestamps = false;
protected $fillable = ['name', 'slug'];
}
from laravel-translatable.
You should be having any other problem, I reproduced your models and it works fine for me. What are you tables fields?
My Models
<?php namespace Gnikoob\Models;
use Dimsav\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;
/*
Table fields
id INT(11) NOT NULL AUTO_INCREMENT,
*/
class Category extends Model {
use Translatable;
public $translatedAttributes = ['name', 'slug'];
protected $fillable = ['name', 'slug'];
public $timestamps = false;
}
Translation model:
<?php namespace Gnikoob\Models;
use Illuminate\Database\Eloquent\Model;
/*
Table fields
category_id INT(11) NOT NULL,
locale CHAR(2) NOT NULL,
name VARCHAR(100) NOT NULL,
slug VARCHAR(100) NOT NULL,
*/
class CategoryTranslation extends Model {
protected $fillable = ['name', 'slug'];
public $timestamps = false;
}
Route file for testing:
Route::get('/', function ()
{
$data = [
'_method' => 'PUT',
'_token' => 'lkasndnfakjsdhnfklaksdmnfaisubdnflajnsdf',
'en' => ['name' => 'Category 2', 'slug' => 'category_2'],
'es' => ['name' => 'Categoría 2', 'slug' => 'categoria_2'],
];
$category = \Gnikoob\Models\Category::create($data);
return $category->translate('en')->name . '(' . $category->translate('en')->slug . ')'; // Category 4
});
The result was this:
Category 2(category_2)
from laravel-translatable.
Oh, that's weird...
My DB structure looks like this:
Table categories
id INT(10) PRI NOT NULL
created at TIMESTAMP
updated at TIMESTAMP
Table category_translations
id INT(10) PRI NOT NULL
name VARCHAR(255) NOT NULL
slug VARCHAR(255) NOT NULL
category_id INT(10) PRI NOT NULL
locale VARCHAR(255) NOT NULL
from laravel-translatable.
The issue sounds to be related to #38. Can you please compare your mysql versions?
from laravel-translatable.
Laravel 5 is now supported in the development branch. If you have any problems please create a new issue.
from laravel-translatable.
Related Issues (20)
- Add Laravel 5.8 support HOT 1
- Saving in translated model instead of saving in original model HOT 4
- Fetching Model by translated field and determine locale HOT 3
- Extra Fields or Properties For Translated Text HOT 2
- Can't translate to Portuguese HOT 3
- Display translated attribute even if no translation for current locale and fallback locale? HOT 3
- Has this package a possibility to get translations of related models HOT 2
- Ability to save in both languages HOT 8
- ID coming back with different data HOT 4
- Query where locale not working properly HOT 2
- What would be the best way to handle admin panel with translations? HOT 4
- how i can custom $translatedAttributes from outside model HOT 2
- Multiple Databases HOT 2
- Fallback to default locale with numeric field is not working as expected HOT 3
- get all and Fallback if translation is missing #23 HOT 2
- Wrong column name HOT 2
- Problem with relations HOT 3
- Prefix for default language HOT 6
- When I change local I don't get the translation HOT 7
- how to change the category translation on the fly? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-translatable.