Points
28
Solutions
0
Before you even get started, you must verify that the INTL extension is installed for your PHP.
One quick check before you deploy
Run this on your server to confirm the intl extension is installed:
Bash:
php -m | grep -i intl
Quickest way to diagnose
Drop this one-line test script in your Sngine root as test_translit.php:
PHP:
<?php
require_once __DIR__ . '/includes/functions.php';
$test = "Трошки згадалося. Початок виходу з боргів";
echo "intl loaded: " . (function_exists('transliterator_transliterate') ? 'YES' : 'NO') . "\n";
echo "Input: {$test}\n";
echo "Output: " . get_url_text($test) . "\n";
Run it:
test_translit.phpYou'll get one of three outcomes:
intl loaded: NO - and empty/garbled slug Install php-intl, then it'll work
intl loaded: YES - and a clean Latin slugCode is fine
Delete
test_translit.php after.
Also, a quick note: this will not convert already existing blog posts. This will only work on newly created blog posts.
The file you need to edit
The slug for blog posts is generated in includes/functions.php, depending on your Sngine version. This is what turns the article title into the URL slug.By default, it strips characters it doesn't recognise as URL-safe, but Cyrillic letters often pass through because the regex uses Unicode-aware matching (\p{L}).
The fix — add a transliteration step
Open includes/functions.php, find the function get_url_text function, and add a transliteration call before the existing slug logic runs.
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;
}
What I changed and why
Added a transliteration block right after the two _decode lines and before the preg_replace. Order matters — you need to convert Cyrillic to Latin first, then let the existing regex strip whatever isn't a letter or digit.
Added strtolower() after the trim. The Lower() rule in the transliterator already handles this, but the fallback path doesn't, so this guarantees lowercase either way. Lowercase URLs are the convention.
Wrapped the conversions in safety checks — if transliterator_transliterate ever returns false (rare, but possible on weird input), the original string survives instead of becoming empty.
How to apply it
- Back up functions.php first — copy it to functions.php.bak on the server.
- Open includes/functions.php in your editor.
- Jump to line 8206 (search for function get_url_text).
- Replace lines 8206–8221 with the block above. (Line numbers might vary depending on updates.)
- Save and upload.
- Test by creating a new blog post with a Cyrillic title — the URL should now be Latin.