Orangescrum / orangescrum-community

Flexible Project Management web application written in CakePHP
https://www.orangescrum.com
Other
431 stars 239 forks source link

Cannot use Chinese word '文' in title, content #179

Open mosluce opened 6 years ago

mosluce commented 6 years ago

In app/Controller/Component/FormatComponent.php comment lines 1326 & 1327, It's solved.

Any better solution for this problem?

evreneter commented 5 years ago

I fixed this problem for Turkish.

You need to edit this files. app/Controller/Component/FormatComponent.php app/View/Helper/FormatHelper.php

function convert_ascii($string) is problematic.

I changed it to;

    function convert_ascii($string){
         $string = $this->sef_tr($string);
    // Replace Single Curly Quotes
    $search[]  = chr(226).chr(128).chr(152);
    $replace[] = "'";
    $search[]  = chr(226).chr(128).chr(153);
    $replace[] = "'";

    // Replace Smart Double Curly Quotes
    $search[]  = chr(226).chr(128).chr(156);
    $replace[] = '\"';
    $search[]  = chr(226).chr(128).chr(157);
    $replace[] = '\"';

    // Replace En Dash
    $search[]  = chr(226).chr(128).chr(147);
    $replace[] = '--';

    // Replace Em Dash
    $search[]  = chr(226).chr(128).chr(148);
    $replace[] = '---';

    // Replace Bullet
    $search[]  = chr(226).chr(128).chr(162);
    $replace[] = '*';

    // Replace Middle Dot
    $search[]  = chr(194).chr(183);
    $replace[] = '*';

    // Replace Ellipsis with three consecutive dots
    $search[]  = chr(226).chr(128).chr(166);
    $replace[] = '...';

    $search[]  = chr(150);
    $replace[] = "-";

    // Apply Replacements
    $string = str_replace($search, $replace, $string);

    // Remove any non-ASCII Characters
    //$string = preg_replace("/[^\x01-\x7F]/","", $string);
       $string = $this->sef_tr_normal($string);
    return $string;
}

    function sef_tr($s)
    {
        $s1 = array('ş', 'Ş', 'ı', 'İ', 'ğ', 'Ğ', 'ü', 'Ü', 'ö', 'Ö', 'Ç', 'ç');
        $s2 = array('*s*', '*S*', '*i*', '*I*', '*g*', '*G*', '*u*', '*U*', '*o*', '*O*', '*C*', '*c*',);
        $s = str_replace($s1, $s2, $s);
        return $s;
    }

    function sef_tr_normal($s)
    {
        $s1 = array('ş', 'Ş', 'ı', 'İ', 'ğ', 'Ğ', 'ü', 'Ü', 'ö', 'Ö', 'Ç', 'ç');
        $s2 = array('*s*', '*S*', '*i*', '*I*', '*g*', '*G*', '*u*', '*U*', '*o*', '*O*', '*C*', '*c*',);
        $s = str_replace($s2,$s1, $s);
        return $s;
    }