kongulov / nova-tab-translatable

This package contains a NovaTabTranslatable class you can use to make any Nova field type translatable with tabs.
MIT License
79 stars 16 forks source link

Search with special characters not working while NovaTabTranslatable. #32

Open webmappsrl opened 1 year ago

webmappsrl commented 1 year ago

Hi, I am using Laravel 9 with Nova 4 and this plugin but search on resource page is not working when i use accented characters like š, č or Ž How can i fix this? I have also used the trait: TranslatableTabToRowTrait but it has not resolved it.

thanks

kongulov commented 1 year ago

Hi @webmappsrl

Can you please describe the problem in more detail?

webmappsrl commented 1 year ago

Hi, I have a model trails where i have defined which database column should be translatable:

 ...
public $translatable = [
    'name'
];
...

Then i have the nova for this model where i use it:

...
  public function fields(NovaRequest $request)
    {
        return [
            NovaTabTranslatable::make([
                Text::make(__('Name'), 'name')->sortable(),
            ])
        ]
    }
...

I have 2 languages for this project: 'EN' and 'IT'; even though it's english every one is writing in their own language like:

But i have an other model without the 'NovaTabTranslatable' with similar names and the search is working:

Screenshot 2022-12-28 at 09 00 48 Screenshot 2022-12-28 at 09 01 05 Screenshot 2022-12-28 at 09 02 03

If it's not enough tell me exactly what you need? Thanks.

kongulov commented 1 year ago

@webmappsrl

I checked the search and it works for me.

Maybe you forgot to include "name" in the "$search" array?

Or it could be a nova issue. my nova version is: 4.19.5

"TranslatableTabToRowTrait" worked for me too (image 4)

image

image

image

image

webmappsrl commented 1 year ago

Hi, My plugins are up to date. The search is correct:

    public static $search = [
        'id','name','ref','member.acronym'
    ];

in the database is see the value for name saved like this:

{"en":"Doli\u010d - Kuzma - Serdi\u0161ki breg","it":"Doli\u010d - Kuzma - Serdi\u0161ki breg"}

The other columns that are not using the NovaTabTranslatable save the value like this in the database: Dolič and again the search works while searching with accents for other columns.

on my database.php file under 'pgsql'=> i have 'charset' => 'utf8'

kongulov commented 1 year ago

@webmappsrl i am using mysql with 'charset' => 'utf8mb4', collate => 'utf8mb4_unicode_ci'

It's strange that I don't do any operations with the character

try to remove "HasTranslations" and "$translatable" in the same model and remove "NovaTabTranslatable::make()", and instead add just a text field, see how it saves to the database.

webmappsrl commented 1 year ago

It saves like this: Koča and nova search works.

kongulov commented 1 year ago

I will install Postgres and try to solve the problem