XF 1.5 Turkish Character problems on Xenforo Tag URL's

maxicep

Active member
Hello everyone, specially to xenforo team :)

We are using the forum in Turkish language. When i enable the "enable romanizer" in xenforo settings then URL's are not fine for us. Some Turkish special characters can't replace exactly. (Like "ü", "ö")

Then we had a solution for that it is ;

Edit xenforo/Link.php

$title = strtr($title, array('´' => '', '"' => '', "'" => '', "Ö" => "o", "ö" => "o", "C" => "c", "c" => "c", "Ğ" => "g", "ğ" => "g", "Ş" => "s", "ş" => "s", "Ü" => "u", "ü" => "u", "İ" => "i", "ı" => "i", "Ç" => "c", "ç" => "c", "é" => "i", "â" => "a", "Ê" => "e", "Â" => "a", "?" => "_", "*" => "_", "." => "_", "," => "_", ";" => "_", ")" => "_", "(" => "_", "{" => "_", "}" => "_", "[" => "_", "]" => "_", "!" => "_", "+" => "_", "%" => "_", "&" => "_", "#" => "_", "$" => "_", "=" => "_", "ê" => "e", "." => "-" ));

So, these lines converting some Turkish character to suitable English characters. We are using the Xenforo for about 2.5 years.

But now, we have upgraded the xenforo 1.5 so added the new tag system. And this process which above, doesn't work on Tag URL's.

For example;
Tag: maxicep rütbe sistemi
Url: http://www.maxicep.com/forum/etiket/maxicep-ruetbe-sistemi/

But it should be
http://www.maxicep.com/forum/etiket/maxicep-rutbe-sistemi/

So, "ü" char should be "u". But it doesn't. It converts like "romanizer enabled urls" (ü => ue)

So, with our way which edited the Link.php file in xenforo, forum hreads and forum titles working well so converting "ü" => "u"

So, How we apply that same process on tag url's too?
Any ideas ?


P.S: I' m so sorry that Xenforo doesn't support still the Turkish Language completely.

Thanks.
 
As I responded in your ticket, romanizing of tag URLs is handled in XenForo_Model_Tag::_getUrlVersionOfTag().

Specifically:

$urlVersion = preg_replace('/[^a-zA-Z0-9_ -]/', '', utf8_romanize(utf8_deaccent($tag)));
$urlVersion = preg_replace('/[ -]+/', '-', $urlVersion);

You would need to edit that code to suit your requirements, or alternatively, you can change the URL versions of tags in the ACP, although it can only be done retroactively and must be done for each tag.
 
As I responded in your ticket, romanizing of tag URLs is handled in XenForo_Model_Tag::_getUrlVersionOfTag().

Specifically:

$urlVersion = preg_replace('/[^a-zA-Z0-9_ -]/', '', utf8_romanize(utf8_deaccent($tag)));
$urlVersion = preg_replace('/[ -]+/', '-', $urlVersion);

You would need to edit that code to suit your requirements, or alternatively, you can change the URL versions of tags in the ACP, although it can only be done retroactively and must be done for each tag.
How can apply for this changes ?
Need a plugin or like ? Or which file i dont understand exactly sorry.
 
I can't modify the wrong "ö" and "ü" characters in Turkish language forum.

I edit the :
library/Xenforo/Model/Tag.php : 439

$urlVersion = preg_replace(array('/ü/', '/ö/'), array('u', 'o'), $urlVersion);

Code:
    protected function _getUrlVersionOfTag($tag)
    {
        $db = $this->_getDb();
     
        $urlVersion = preg_replace(array('/ü/', '/ö/'), array('u', 'o'), $urlVersion);

        $urlVersion = preg_replace('/[^a-zA-Z0-9_ -]/', '', utf8_romanize(utf8_deaccent($tag)));
        $urlVersion = preg_replace('/[ -]+/', '-', $urlVersion);


        if (!strlen($urlVersion))
        {
            $urlVersion = 1 + intval($db->fetchOne("
                SELECT MAX(tag_id)
                FROM xf_tag
            "));
        }
        else
        {
            $existing = $db->fetchRow("
                SELECT *
                FROM xf_tag
                WHERE tag_url = ?
                    OR (tag_url LIKE ? AND tag_url REGEXP ?)
                ORDER BY tag_id DESC
                LIMIT 1
            ", array ($urlVersion, "$urlVersion-%", "^{$urlVersion}-[0-9]+\$"));
            if ($existing)
            {
                $counter = 1;
                if ($existing['tag_url'] != $urlVersion && preg_match('/-(\d+)$/', $existing['tag_url'], $match))
                {
                    $counter = $match[1];
                }

                $testExists = true;
                while ($testExists)
                {
                    $counter++;
                    $testExists = $db->fetchOne("
                        SELECT tag_id
                        FROM xf_tag
                        WHERE tag_url = ?
                    ", "$urlVersion-$counter");
                }

                $urlVersion .= "-$counter";
            }
        }

        return $urlVersion;
    }

They still don't converting to right URL. We are experiencing a problem on just "ö" and "ü" chars now. Xenforo converting them to "oe" and "ue" but we want it to "o" and "u"

Thanks.
 
The Solution;

Open (to edit utf8.php file) /forum/library/Lgpl/utf8.php file. (forum/library/Lgpl/ dizini altındaki utf8.php dosyasını açın.)

Find 'ö' => 'oe', line and change this: 'ö' => 'o', ('ö' => 'oe', satırını bul ve 'ö' => 'o', bununla değiştir)

Find 'Ö' => 'Oe', line and change this: 'Ö' => 'O',

Find 'Ü' => 'Ue', line and change this: 'Ü' => 'U',

Thats all (Denedim çalışıyor).

UTF-8 Türkçe Karakter Karşılıkları (Turkish UTF-8 characters Provisions):

Büyük Harfler İçin UTF-8 Karşılıkları (UTF-8 Provision for Upper Case):

Ü = Ãœ
Ş = Å
Ğ = Ä
Ç = Ç
İ = Ä°
Ö = Ö

Küçük Harfler İçin UTF-8 Karşılıkları (UTF-8 Provision for Lover Case):

ü = ü
ş = ÅŸ
ğ = ÄŸ
ç = ç
ı = ı
ö = ö
 
Last edited:
Top Bottom