*

reflexus

  • ****
  • 146 posts
Cyrillic title and url
« on: March 17, 2018, 05:23:33 PM »
Slugs do not work for Cyrillic characters, can you fix this? With Cyrillic to Latin convert
« Last Edit: March 17, 2018, 05:28:14 PM by reflexus »

*

MB Themes

Re: Cyrillic title and url
« Reply #1 on: March 17, 2018, 08:42:14 PM »
@reflexus
There is nothing to fix as osclass routes does not ask if it is cyrilic or not. Is your server properly configured?
You could place some conversion function everywhere you see osc_route_url function in code, but I do not think it's right.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

reflexus

  • ****
  • 146 posts
Re: Cyrillic title and url
« Reply #2 on: March 17, 2018, 11:36:20 PM »
@reflexus
There is nothing to fix as osclass routes does not ask if it is cyrilic or not. Is your server properly configured?
You could place some conversion function everywhere you see osc_route_url function in code, but I do not think it's right.

I have did it myself, you are not right, you need to add an additional function for this in admin.js and user.js

*

MB Themes

Re: Cyrillic title and url
« Reply #3 on: March 18, 2018, 02:54:04 PM »
What function? You mean to get slug text? What you use?
Anyway this still is not enough, for authors and categories it only slugify their names.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

MB Themes

Re: Cyrillic title and url
« Reply #4 on: March 19, 2018, 08:21:26 AM »
I've updated plugin, used osc_sanitizeString function. Anyway I've tried to use cyrilic chars on my test domain and everything worked fine.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

reflexus

  • ****
  • 146 posts
Re: Cyrillic title and url
« Reply #5 on: March 19, 2018, 03:31:03 PM »
What function? You mean to get slug text? What you use?
Anyway this still is not enough, for authors and categories it only slugify their names.

for Categories and Authors you can use this function:

Code: [Select]
function blg_slug($str, $options = array()) {
  $str = mb_convert_encoding((string)$str, 'UTF-8', mb_list_encodings());

$defaults = array(
'delimiter' => '-',
'limit' => null,
'lowercase' => true,
'replacements' => array(),
'transliterate' => true,
);

// Merge options
$options = array_merge($defaults, $options);

$char_map = array(
// Latin
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C',
'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I',
'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ő' => 'O',
'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ű' => 'U', 'Ý' => 'Y', 'Þ' => 'TH',
'ß' => 'ss',
'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c',
'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i',
'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ő' => 'o',
'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th',
'ÿ' => 'y',

// Latin symbols
'©' => '(c)',

// Greek
'Α' => 'A', 'Β' => 'B', 'Γ' => 'G', 'Δ' => 'D', 'Ε' => 'E', 'Ζ' => 'Z', 'Η' => 'H', 'Θ' => '8',
'Ι' => 'I', 'Κ' => 'K', 'Λ' => 'L', 'Μ' => 'M', 'Ν' => 'N', 'Ξ' => '3', 'Ο' => 'O', 'Π' => 'P',
'Ρ' => 'R', 'Σ' => 'S', 'Τ' => 'T', 'Υ' => 'Y', 'Φ' => 'F', 'Χ' => 'X', 'Ψ' => 'PS', 'Ω' => 'W',
'Ά' => 'A', 'Έ' => 'E', 'Ί' => 'I', 'Ό' => 'O', 'Ύ' => 'Y', 'Ή' => 'H', 'Ώ' => 'W', 'Ϊ' => 'I',
'Ϋ' => 'Y',
'α' => 'a', 'β' => 'b', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'ζ' => 'z', 'η' => 'h', 'θ' => '8',
'ι' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => '3', 'ο' => 'o', 'π' => 'p',
'ρ' => 'r', 'σ' => 's', 'τ' => 't', 'υ' => 'y', 'φ' => 'f', 'χ' => 'x', 'ψ' => 'ps', 'ω' => 'w',
'ά' => 'a', 'έ' => 'e', 'ί' => 'i', 'ό' => 'o', 'ύ' => 'y', 'ή' => 'h', 'ώ' => 'w', 'ς' => 's',
'ϊ' => 'i', 'ΰ' => 'y', 'ϋ' => 'y', 'ΐ' => 'i',

// Turkish
'Ş' => 'S', 'İ' => 'I', 'Ç' => 'C', 'Ü' => 'U', 'Ö' => 'O', 'Ğ' => 'G',
'ş' => 's', 'ı' => 'i', 'ç' => 'c', 'ü' => 'u', 'ö' => 'o', 'ğ' => 'g',

// Russian
'А' => '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', 'Щ' => 'Sh', 'Ъ' => '', 'Ы' => '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', 'щ' => 'sh', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu',
'я' => 'ya',

// Ukrainian
'Є' => 'Ye', 'І' => 'I', 'Ї' => 'Yi', 'Ґ' => 'G',
'є' => 'ye', 'і' => 'i', 'ї' => 'yi', 'ґ' => 'g',

// Czech
'Č' => 'C', 'Ď' => 'D', 'Ě' => 'E', 'Ň' => 'N', 'Ř' => 'R', 'Š' => 'S', 'Ť' => 'T', 'Ů' => 'U',
'Ž' => 'Z',
'č' => 'c', 'ď' => 'd', 'ě' => 'e', 'ň' => 'n', 'ř' => 'r', 'š' => 's', 'ť' => 't', 'ů' => 'u',
'ž' => 'z',

// Polish
'Ą' => 'A', 'Ć' => 'C', 'Ę' => 'e', 'Ł' => 'L', 'Ń' => 'N', 'Ó' => 'o', 'Ś' => 'S', 'Ź' => 'Z',
'Ż' => 'Z',
'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z',
'ż' => 'z',

// Latvian
'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'i', 'Ķ' => 'k', 'Ļ' => 'L', 'Ņ' => 'N',
'Š' => 'S', 'Ū' => 'u', 'Ž' => 'Z',
'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n',
'š' => 's', 'ū' => 'u', 'ž' => 'z'
);

// Make custom replacements
$str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str);

// Transliterate characters to ASCII
if ($options['transliterate']) {
$str = str_replace(array_keys($char_map), $char_map, $str);
}

// Replace non-alphanumeric characters with our delimiter
$str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str);

// Remove duplicate delimiters
$str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str);

// Truncate slug to max. characters
$str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8');

// Remove delimiter from ends
$str = trim($str, $options['delimiter']);

return $options['lowercase'] ? mb_strtolower($str, 'UTF-8') : $str;
}

and for admin.js and user.js you need add additional javascript function to convert cyrilic or any others language strings to latin strings
« Last Edit: March 19, 2018, 03:36:34 PM by reflexus »

*

reflexus

  • ****
  • 146 posts
Re: Cyrillic title and url
« Reply #6 on: March 19, 2018, 03:37:21 PM »
I've updated plugin, used osc_sanitizeString function. Anyway I've tried to use cyrilic chars on my test domain and everything worked fine.

not work

*

MB Themes

Re: Cyrillic title and url
« Reply #7 on: March 19, 2018, 03:48:28 PM »
@reflexus
I still think it's your hosting issue, look there:
https://plugins2.abprofitrade.eu/blog/low-cost-energy-now-affordable-%D0%91%D0%B1%D0%93%D0%B3%D0%99%D0%B9%D0%A8%D1%88%D0%AE%D1%8E%D0%AF%D1%8F-b4

Cyrilic characters in URL, no issues.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

reflexus

  • ****
  • 146 posts
Re: Cyrillic title and url
« Reply #8 on: March 19, 2018, 05:10:43 PM »
@reflexus
I still think it's your hosting issue, look there:
https://plugins2.abprofitrade.eu/blog/low-cost-energy-now-affordable-%D0%91%D0%B1%D0%93%D0%B3%D0%99%D0%B9%D0%A8%D1%88%D0%AE%D1%8E%D0%AF%D1%8F-b4

Cyrilic characters in URL, no issues.

I did not mean Russian letters in the URL address bar, i mean converting russian or any non latin letters to latin, i make video and show what was meant, difficult to explain.

Why Cyrillic characters are bad for links, you can see your link:
https://plugins2.abprofitrade.eu/blog/low-cost-energy-now-affordable-%D0%91%D0%B1%D0%93%D0%B3%D0%99%D0%B9%D0%A8%D1%88%D0%AE%D1%8E%D0%AF%D1%8F-b4
« Last Edit: March 19, 2018, 05:13:44 PM by reflexus »

*

MB Themes

Re: Cyrillic title and url
« Reply #9 on: March 19, 2018, 08:40:47 PM »
@reflexus
It is not bad, it is url encoded and for browser or search engine it is same.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pipetko

  • ****
  • 123 posts
Re: Cyrillic title and url
« Reply #10 on: August 03, 2020, 04:58:50 PM »
I am also searching for solution cyrilic to latin transliteration of urls.. PS. I dont know if its the same for search engines, but I can see OLX and other ad giants in my country ARE using latin transliteration in all of their urls... Which should mean something.
« Last Edit: August 03, 2020, 05:00:48 PM by pipetko »

*

pipetko

  • ****
  • 123 posts
Re: Cyrillic title and url
« Reply #11 on: August 03, 2020, 07:32:55 PM »
Solution:

In /oc-includes/osclass/formating.php

After:
Code: [Select]
// Euro Sign
chr(226).chr(130).chr(172) => 'E',

Add:
Code: [Select]
//Transliteration for Cyrillic
chr(192),chr(208).chr(144) => 'a', // А
chr(224),chr(208).chr(176) => 'a', // а
chr(193),chr(208).chr(145) => 'b', // Б
chr(225),chr(208).chr(177) => 'b', // б
chr(194),chr(208).chr(146) => 'v', // В
chr(226),chr(208).chr(178) => 'v', // в
chr(195),chr(208).chr(147) => 'g', // Г
chr(227),chr(208).chr(179) => 'g', // г
chr(196),chr(208).chr(148) => 'd', // Д
chr(228),chr(208).chr(180) => 'd', // д
chr(197),chr(208).chr(149) => 'e', // Е
chr(229),chr(208).chr(181) => 'e', // е
chr(168),chr(208).chr(129) => 'yo', // Ё
chr(184),chr(209).chr(145) => 'yo', // ё
chr(198),chr(208).chr(150) => 'zh', // Ж
chr(230),chr(208).chr(182) => 'zh', // ж
chr(199),chr(208).chr(151) => 'z', // З
chr(231),chr(208).chr(183) => 'z', // з
chr(200),chr(208).chr(152) => 'i', // И
chr(232),chr(208).chr(184) => 'i', // и
chr(201),chr(208).chr(153) => 'j', // Й
chr(233),chr(208).chr(185) => 'j', // й
chr(202),chr(208).chr(154) => 'k', // К
chr(234),chr(208).chr(186) => 'k', // к
chr(203),chr(208).chr(155) => 'l', // Л
chr(235),chr(208).chr(187) => 'l', // л
chr(204),chr(208).chr(156) => 'm', // М
chr(236),chr(208).chr(188) => 'm', // м
chr(205),chr(208).chr(157) => 'n', // Н
chr(237),chr(208).chr(189) => 'n', // н
chr(206),chr(208).chr(158) => 'o', // О
chr(238),chr(208).chr(190) => 'o', // о
chr(207),chr(208).chr(159) => 'p', // П
chr(239),chr(208).chr(191) => 'p', //п
chr(208),chr(208).chr(160) => 'r', // Р
chr(240),chr(209).chr(128) => 'r', // р
chr(209),chr(208).chr(161) => 's', // С
chr(241),chr(209).chr(129) => 's', // с
chr(210),chr(208).chr(162) => 't', // Т
chr(242),chr(209).chr(130) => 't', // т
chr(211),chr(208).chr(163) => 'y', // У
chr(243),chr(209).chr(131) => 'y', // у
chr(212),chr(208).chr(164) => 'f', // Ф
chr(244),chr(209).chr(132) => 'f', // ф
chr(213),chr(208).chr(165) => 'x', // Х
chr(245),chr(209).chr(133) => 'x', // х
chr(214),chr(208).chr(166) => 'c', // Ц
chr(246),chr(209).chr(134) => 'c', //ц
chr(215),chr(208).chr(167) => 'ch', // Ч
chr(247),chr(209).chr(135) => 'ch', // ч
chr(216),chr(208).chr(168) => 'sh', // Ш
chr(248),chr(209).chr(136) => 'sh', // ш
chr(217),chr(208).chr(169) => 'sch', // Щ
chr(249),chr(209).chr(137) => 'sch', // щ
chr(218),chr(208).chr(170) => '', // Ъ
chr(250),chr(209).chr(138) => '', // ъ
chr(219),chr(208).chr(171) => 'y', // Ы
chr(251),chr(209).chr(139) => 'y', // ы
chr(220),chr(208).chr(172) => '', // Ь
chr(252),chr(209).chr(140) => '', // ь
chr(221),chr(208).chr(173) => 'e', // Э
chr(253),chr(209).chr(141) => 'e', // э
chr(222),chr(208).chr(174) => 'yu', // Ю
chr(254),chr(209).chr(142) => 'yu', // ю
chr(223),chr(208).chr(175) => 'ya', // Я
chr(255),chr(209).chr(143) => 'ya', // я
/* Цифры */
chr(48) => '0', // 0
chr(48).chr(48) => '00', // 00
chr(48).chr(49) => '01', // 01
chr(48).chr(50) => '02', // 02
chr(48).chr(51) => '03', // 03
chr(48).chr(52) => '04', // 04
chr(48).chr(53) => '05', // 05
chr(48).chr(54) => '06', // 06
chr(48).chr(55) => '07', // 07
chr(48).chr(56) => '08', // 08
chr(48).chr(57) => '09', // 09
chr(49) => '1', // 1
chr(49).chr(48) => '10', // 10
chr(49).chr(49) => '11', // 11
chr(49).chr(50) => '12', // 12
chr(49).chr(51) => '13', // 13
chr(49).chr(52) => '14', // 14
chr(49).chr(53) => '15', // 15
chr(49).chr(54) => '16', // 16
chr(49).chr(55) => '17', // 17
chr(49).chr(56) => '18', // 18
chr(49).chr(57) => '19', // 19
chr(50) => '2', // 2
chr(50).chr(48) => '20', // 20
chr(50).chr(49) => '21', // 21
chr(50).chr(50) => '22', // 22
chr(50).chr(51) => '23', // 23
chr(50).chr(52) => '24', // 24
chr(50).chr(53) => '25', // 25
chr(50).chr(54) => '26', // 26
chr(50).chr(55) => '27', // 27
chr(50).chr(56) => '28', // 28
chr(50).chr(57) => '29', // 29
chr(51) => '3', // 3
chr(51).chr(48) => '30', // 30
chr(51).chr(49) => '31', // 31
chr(51).chr(50) => '32', // 32
chr(51).chr(51) => '33', // 33
chr(51).chr(52) => '34', // 34
chr(51).chr(53) => '35', // 35
chr(51).chr(54) => '36', // 36
chr(51).chr(55) => '37', // 37
chr(51).chr(56) => '38', // 38
chr(51).chr(57) => '39', // 39
chr(52) => '4', // 4
chr(52).chr(48) => '40', // 40
chr(52).chr(49) => '41', // 41
chr(52).chr(50) => '42', // 42
chr(52).chr(51) => '43', // 43
chr(52).chr(52) => '44', // 44
chr(52).chr(53) => '45', // 45
chr(52).chr(54) => '46', // 46
chr(52).chr(55) => '47', // 47
chr(52).chr(56) => '48', // 48
chr(52).chr(57) => '49', // 49
chr(53) => '5', // 5
chr(53).chr(48) => '50', // 50
chr(53).chr(49) => '51', // 51
chr(53).chr(50) => '52', // 52
chr(53).chr(51) => '53', // 53
chr(53).chr(52) => '54', // 54
chr(53).chr(53) => '55', // 55
chr(53).chr(54) => '56', // 56
chr(53).chr(55) => '57', // 57
chr(53).chr(56) => '58', // 58
chr(53).chr(57) => '59', // 59
chr(54) => '6', // 6
chr(54).chr(48) => '60', // 60
chr(54).chr(49) => '61', // 61
chr(54).chr(50) => '62', // 62
chr(54).chr(51) => '63', // 63
chr(54).chr(52) => '64', // 64
chr(54).chr(53) => '65', // 65
chr(54).chr(54) => '66', // 66
chr(54).chr(55) => '67', // 67
chr(54).chr(56) => '68', // 68
chr(54).chr(57) => '69', // 69
chr(55) => '7', // 7
chr(55).chr(48) => '70', // 70
chr(55).chr(49) => '71', // 71
chr(55).chr(50) => '72', // 72
chr(55).chr(51) => '73', // 73
chr(55).chr(52) => '74', // 74
chr(55).chr(53) => '75', // 75
chr(55).chr(54) => '76', // 76
chr(55).chr(55) => '77', // 77
chr(55).chr(56) => '78', // 78
chr(55).chr(57) => '79', // 79
chr(56) => '8', // 8
chr(56).chr(48) => '80', // 80
chr(56).chr(49) => '81', // 81
chr(56).chr(50) => '82', // 82
chr(56).chr(51) => '83', // 83
chr(56).chr(52) => '84', // 84
chr(56).chr(53) => '85', // 85
chr(56).chr(54) => '86', // 86
chr(56).chr(55) => '87', // 87
chr(56).chr(56) => '88', // 88
chr(56).chr(57) => '89', // 89
chr(57) => '9', // 9
chr(57).chr(48) => '90', // 90
chr(57).chr(49) => '91', // 91
chr(57).chr(50) => '92', // 92
chr(57).chr(51) => '93', // 93
chr(57).chr(52) => '94', // 94
chr(57).chr(53) => '95', // 95
chr(57).chr(54) => '96', // 96
chr(57).chr(55) => '97', // 97
chr(57).chr(56) => '98', // 98
chr(57).chr(57) => '99', // 99

turn on Enable friendly urls and thats it

*

MB Themes

Re: Cyrillic title and url
« Reply #12 on: August 03, 2020, 09:01:51 PM »
Thanks for tip ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

MB Themes

Re: Cyrillic title and url
« Reply #13 on: February 24, 2021, 09:17:54 AM »
Moved to osclass 4.4
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pipetko

  • ****
  • 123 posts
Re: Cyrillic title and url
« Reply #14 on: March 29, 2021, 11:54:37 PM »
Moved to osclass 4.4
U mean it is build in there now ?! :)