igaster / laravel-translate-eloquent Goto Github PK
View Code? Open in Web Editor NEWTranslate any column in your Database in Laravel Eloquent Models
License: MIT License
Translate any column in your Database in Laravel Eloquent Models
License: MIT License
My translatable content is actually HTML code (with text that can come in multiple languages of course), however the HTML tags keep getting stripped. Is this actually related to laravel-translate-eloquen, I mean, does it sanitize user input before inserting new rows in it's table?
For people in the same situation:
Get a php error in Translations.php "Can't use method return value in write context" at the public function "has".
On PHP versions below 5.5 empty has limitations this is resolved by changing the function to:
public function has($locale){
$MyLocale = $this->get($locale);
return !empty($MyLocale);
}
I like this package a lot, it makes translations easy & overall it works like a charm.
However, when using SoftDeletes on a model not all functionality works as expected.
Would love to hear back from you !
Hi,
I'm testing your package, it works with no problem :) But it makes a lot of queries: one by $model->key
call.
So if i have a loop :
select * from `translations` where `group_id` = '1247' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1248' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1250' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1251' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1252' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1253' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1254' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1255' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1257' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1258' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1259' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1260' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1261' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1262' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1263' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1264' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1265' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1266' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1267' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1268' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1269' and `locale` = 'fr' limit 1
select * from `translations` where `group_id` = '1270' and `locale` = 'fr' limit 1
Is it normal ?
I'm not sure why this package works for others but it fails for me.
problem is that in the trait the sql to get a translation uses this syntax:
$join->on($this->getTable().".$key", '=', 'translations.group_id') ->on('translations.locale' , '=', $locale);
this fails bacause using the second 'on' expects a reference to a column while it actually should be a where style clause.
so with the second 'on' clause eloquent builder returns the value with backticks and this makes the quey fail.
to fix this the queries should be rerwritten so that the second 'on' clause is renames to 'where'
eg:
$join->on($this->getTable().".$key", '=', 'translations.group_id') ->where('translations.locale' , '=', $locale);
at least for me, that fixes it.
Hello!
I don't understand well why the "value" field should be nullable. I think it would be better if assignment of null/empty value mean deleting of this particular translation.
I currently building an multilingual site, in which admin has ability to enter texts in different languages. If the text for some language wasn't filled by site admin, or was cleared, it obviously means "Translation is not available yet, English text should be used instead", not "Nothing should be displayed in this language". For now I have to handle it in controller, but I think this should be done by translation trait itself.
Hello,
I like your package for its simplicity !
I'm building a simple blog app where articles are translated, and the slug of these articles are translated as well.
So I can call /post/my-awesome-article and find the EN version of the article
And I can call /post/mon-super-article and find the FR version of that same article
However in my ArticleController I cannot do simply
Article::where('slug', $slug)->first();
I think it would be nice to extend your package and make it possible to query the model in a such easy way that you don't even need to worry about the language and don't need to use special-query-methods, just the classic eloquent methods.
I've done it for myself, but think it may be useful for others. You may consider merging my work to your repo. Take a look:
https://github.com/zaycakitayca/laravel-translate-eloquent#step-21-modifying-existing-model-fields
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.