Problem with upload File with Thai language

When I upload file name ทดสอบภาษาไทย-1234.jpg
Writepath and database will store only -1234.jpg ( Thai language Dissappear )
How can I fix it.

I comment
$filename = preg_replace(“/([^a-zA-Z0-9-_ ]+?){1}/i”, ‘’, $filename);
in UploadHelper is work.

Hello @newdev ,

You can add some extra characters into the file name Transliteration.php which is on: vendor/grocery-crud/enterprise/src/GroceryCrud/Core/Upload/Transliteration.php to also include the Thai letters. For example:

<?php
namespace GroceryCrud\Core\Upload;

class Transliteration {
    public static function convertFilename($filename) {
        $translit_characters = Transliteration::getTranslitCharacters();

        return preg_replace(array_keys($translit_characters), array_values($translit_characters), $filename);
    }

    public static function getTranslitCharacters() {
        return [
            // Thai characters
            '/ก/' => 'k',
            '/ข/' => 'kh',
            '/ฃ/' => 'kh',
            '/ค/' => 'k',
            '/ฅ/' => 'kh',
            '/ฆ/' => 'kh',
            '/ง/' => 'ng',
            '/จ/' => 'j',
            '/ฉ/' => 'ch',
            '/ช/' => 'ch',
            '/ซ/' => 's',
            '/ฌ/' => 'ch',
            '/ญ/' => 'y',
            '/ฎ/' => 'd',
            '/ฏ/' => 't',
            '/ฐ/' => 'th',
            '/ฑ/' => 'th',
            '/ฒ/' => 'th',
            '/ณ/' => 'n',
            '/ด/' => 'd',
            '/ต/' => 't',
            '/ถ/' => 'th',
            '/ท/' => 'th',
            '/ธ/' => 'th',
            '/น/' => 'n',
            '/บ/' => 'b',
            '/ป/' => 'p',
            '/ผ/' => 'ph',
            '/ฝ/' => 'f',
            '/พ/' => 'ph',
            '/ฟ/' => 'f',
            '/ภ/' => 'ph',
            '/ม/' => 'm',
            '/ย/' => 'y',
            '/ร/' => 'r',
            '/ล/' => 'l',
            '/ว/' => 'w',
            '/ศ/' => 's',
            '/ษ/' => 's',
            '/ส/' => 's',
            '/ห/' => 'h',
            '/ฬ/' => 'l',
            '/อ/' => 'o',
            '/ฮ/' => 'h',

            // Other characters within the file
        ];
    }
}

We have added a Transliteration because it is better to have english characters on files we use on the web. But of course it is up to you, if you would like to exclude the transformation you can remove the regular expression.

Regards
Johnny