Add transliteration slug (friendly url)

Post Reply
User avatar
voron
Jr. Bludit
Posts: 4
Joined: Tue Jun 16, 2015 8:28 am

Hi Diego! Can you adding auto transliteration for slug (friendly url)?
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Hi voro,
it implemented, I used iconv (http://php.net/manual/en/book.iconv.php), may be you don't have installed this module.

You have your own server ?

Code: Select all

	public static function cleanUrl($string, $separator='-')
	{
		if(function_exists('iconv')) {
			$string = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
		}

		$string = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $string);
		$string = trim($string, '-');
		$string = self::lowercase($string);
		$string = preg_replace("/[\/_|+ -]+/", $separator, $string);

		return $string;
	}
User avatar
voron
Jr. Bludit
Posts: 4
Joined: Tue Jun 16, 2015 8:28 am

diego wrote:Hi voro,
it implemented, I used iconv (http://php.net/manual/en/book.iconv.php), may be you don't have installed this module.

You have your own server ?
iconv is installed, see the phpinfo http://bludit.ml/phpinfo.php
try enter title of post in cyrillic lang eg. тест
http://bludit.ml/admin
pass: 326764
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Yes I saw the problem.. I am searching a solution for it, have you some recomendation ? thanks
User avatar
voron
Jr. Bludit
Posts: 4
Joined: Tue Jun 16, 2015 8:28 am

diego wrote:Yes I saw the problem.. I am searching a solution for it, have you some recomendation ? thanks
Good works only character map

Code: Select all

array (
  'А'=>'a','Б'=>'b','В'=>'v',
    'Г'=>'g','Д'=>'d','Е'=>'e','Ё'=>'yo','Ж'=>'zh',
    'З'=>'z','И'=>'i','Й'=>'j','К'=>'k','Л'=>'l',
    'М'=>'m','Н'=>'n','О'=>'o','П'=>'p','Р'=>'r',
    'С'=>'s','Т'=>'t','У'=>'u','Ф'=>'f','Х'=>'h',
    'Ц'=>'c','Ч'=>'ch','Ш'=>'sh','Щ'=>'shh','Ъ'=>'',
    'Ы'=>'y','Ь'=>'','Э'=>'e','Ю'=>'yu','Я'=>'ya',
    'а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d',
    'е'=>'e','ё'=>'yo','ж'=>'zh','з'=>'z','и'=>'i',
    'й'=>'j','к'=>'k','л'=>'l','м'=>'m','н'=>'n',
    'о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t',
    'у'=>'u','ф'=>'f','х'=>'h','ц'=>'c','ч'=>'ch',
    'ш'=>'sh','щ'=>'shh','ъ'=>'','ы'=>'y','ь'=>'',
    'э'=>'e','ю'=>'yu','я'=>'ya',' '=>'-','-'=>'-','»'=>''
);
Remember as you did in nibbleblog?
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Yes I remember the array list, but I'm looking for another way.

Some CMS uses the slug directly тест instead test, I'm thinking uses characters in UTF in the URI.
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Done, after a while searching a better solution on Google, I used the array with the characters.
Please download the version from Github and let me know if there are some error.

thanks
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

I move the topic to General forum.
User avatar
voron
Jr. Bludit
Posts: 4
Joined: Tue Jun 16, 2015 8:28 am

diego wrote:Done, after a while searching a better solution on Google, I used the array with the characters.
Please download the version from Github and let me know if there are some error.

thanks
All works fine, thank!
albel
Jr. Bludit
Posts: 1
Joined: Wed Feb 14, 2024 12:29 pm

Hello! Help me!
Please tell me how to add automatic transliteration for slug (friendly URL) in Bludit v3.15.0? Unfortunately, I didn't understand how the issue was resolved in this topic. I'm not very familiar with PHP and English language.
Post Reply