Where can I set up transliteration?

Yurensiy

Member
Community Supporter
Points 8
Solutions 0
I continue to fill the forum with my sometimes silly questions. And here's the next one: how and where to set up transliteration so that URLs use Latin instead of Cyrillic? This is an article in the blog section.
Снимок экрана 2026-04-30 120305.webp
 
That is going to require quite a bit of code customization in the functions.php. I will share the code later on with you.
 
That is going to require quite a bit of code customization in the functions.php. I will share the code later on with you.
Thank you very much!
 
I continue to fill the forum with my sometimes silly questions. And here's the next one: how and where to set up transliteration so that URLs use Latin instead of Cyrillic? This is an article in the blog section.
View attachment 272

The code will look something like this after you have made the edits.
Code:
function clean($string) {
    // Transliterate Cyrillic (and other non-Latin) to Latin
    if (function_exists('transliterator_transliterate')) {
        $string = transliterator_transliterate(
            'Any-Latin; Latin-ASCII; Lower()',
            $string
        );
    } else {
        // Fallback if intl extension isn't available
        $string = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string);
    }

    // --- existing Sngine logic below ---
    $string = preg_replace('/[^\p{L}\p{N}\-]+/u', '-', $string);
    $string = preg_replace('/-+/', '-', $string);
    $string = trim($string, '-');
    return $string;
}
 
Should it just be inserted? Or should something be replaced?

Don't insert any code yet. I'll give you the full instructions later on tonight.

I have not tested that code yet. I just quickly wrote it, just to give you an example. Let me test it, and then I'll get back to you.
 
Оk. Sorry 🤷‍♂️ 😁
 
Open the includes/function.php and go to line 8206.

How to apply it​

  1. Back up functions.php first — copy it to functions.php.bak on the server.
  2. Open includes/functions.php in your editor.
  3. Jump to line 8206 (search for function get_url_text).
  4. Replace lines 8206–8221 with the block below.
  5. Save and upload.
  6. Test by creating a new blog post with a Cyrillic title — the URL should now be Latin.

What to change​

Replace the function body with this. Lines 8206–8221 become:


PHP:
function get_url_text($string, $length = 10)
{
  $string = html_entity_decode($string, ENT_QUOTES);
  $string = htmlspecialchars_decode($string, ENT_QUOTES);

  // Transliterate Cyrillic / non-Latin to Latin ASCII
  if (function_exists('transliterator_transliterate')) {
    $transliterated = transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $string);
    if ($transliterated !== false && $transliterated !== null) {
      $string = $transliterated;
    }
  } else {
    $fallback = @iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string);
    if ($fallback !== false) {
      $string = $fallback;
    }
  }

  $string = preg_replace('/[^\\pL\d]+/u', '-', $string);
  $string = trim($string, '-');
  $string = strtolower($string);
  $words = explode("-", $string);
  if (count($words) > $length) {
    $string = "";
    for ($i = 0; $i < $length; $i++) {
      $string .= "-" . $words[$i];
    }
    $string = trim($string, '-');
  }
  return $string;
}
 
It doesn't work. I'll send you this file. Maybe I'm doing something wrong...
 
It doesn't work. I'll send you this file. Maybe I'm doing something wrong...
I forgot that the version you are using is a nulled version, so the line number will be different for you than me.
 

Donate: Campaign

Total amount
$0.00
Goal
$60.00

AdSense

Back
Top