Comments (9)
Hi @jufy,
this is an interesting question. Unfortunately, it is not possible with the current version to combine Ardent with Translatable without modifying the Translatable
class. The reason is that both Ardent
and Translatable
classes extend Eloquent
which means that the model will have to extend both, as shown below:
class Country extends \LaravelBook\Ardent\Ardent {
// ...
}
class Country extends \Dimsav\Translatable\Translatable {
// ...
}
Something like that is unfortunately not possible.
I will try to add the Translatable behaviour to a model by implementing an interface instead of extending Translatable
. This way, it would be possible to make it work with Ardent, or any other package that forces the model to extend a class different than Eloquent
.
Thanks for your message :)
from laravel-translatable.
It will be really great. I have made the localization of current project in a few hours, also include https://github.com/mcamara/laravel-localization and it works pretty good. If in next release it will work with Ardent I will include it to my must have list.
from laravel-translatable.
Unfortunately, avoiding the extending of Translatable to Eloquent is not possible at the moment as Laravel doesn't fire an event after a model is being instantiated and the attributes are filled. The solution I had in mind was with the use of this specific event. I am currently waiting for some feedback from the mentioned issue above.
from laravel-translatable.
Probably there is a variant to make your package work in a way used by this package:
https://github.com/cviebrock/eloquent-sluggable
https://github.com/cviebrock/eloquent-sluggable/blob/master/README-Ardent.md
https://github.com/laravelbook/ardent#modelhooks
There are build-in hooks for models. The solution is bit complex and more difficult to make your package run out of the box. However, the result will be great.
from laravel-translatable.
Sorry, I don't plan to add Ardent as a requirement for this package. That's why I am hoping to see these hooks added by the framework itself.
Sluggable doesn't extend Eloquent/Model so the nature of the conflict with Ardent is different.
from laravel-translatable.
Could it be possible to implement Translatable as a trait instead?
That way, translatable and any other -able behavior can be added without conflicting with PHP's single inheritance.
from laravel-translatable.
Good news, new version of the package comes with compatibility to other packages extending Eloquent such as Ardent.
Coming soon in version v2.0.0
Thanks to @torkiljohnsen for the idea of using traits.
from laravel-translatable.
Awesome 👍
from laravel-translatable.
Version updated to 2.0.0. I did a quick test in combination to Adrent and it seemed to work.
Update your composer.json and if there is a problem, feel free to open the issue back :)
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.