Giter Club home page Giter Club logo

laravel-translate-eloquent's People

Contributors

igaster avatar lpmi-13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-translate-eloquent's Issues

HTML tags stripped

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?

Can't use method return value in write context [solved]

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);
    }

[Bug] TranslationTrait disables some SoftDelete functionality

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.

  1. When "soft" deleting a model, the translations get "hard" deleted (so no restore possible).
  2. Model::all() also includes the softdeleted models.

Would love to hear back from you !

A lot of queries ?

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 ?

wrong join queries

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.

Translation deletion on null assignment.

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.

Querying translated models

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.