Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
How to rewrite a Vietnamese friendly url
banxuanhoa
New
Example : ê -> e, â -> a, now I have a url that : abc.com/post/những-điều-cần-biết
how can I change to abc.com/post/nhung-dieu-can-biet
I must change in which file ?
I know how to write a string replace function, but don't know edit it or put it into wich file in vanilla source code
Does everyone can tell me know about this problem ? Thanks alot !
0
Answers
How can we tell you where to change the url if we don't know where the url is located in your forum. Do you mean in a discussion?
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I think what they want is to change the vietnamese locale to english for links. If that is the case then maybe you could change the $Definition for the links in the vietnamese locale to english.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
I tend to think you and i think differently on many discussions .
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I don't think there are rules in a guessing game no? Specially when the question is open to multiple interpretations lol
Your guesses of what they want are far better for sure and the solutions always right though!!
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
You got it backwards. A Vietnamese friendly-url is
http://việt.com/tin-nhắn/những-điều-cần-biết
not one with the accent marks removed.
Note how Vanilla stops the URL at http://vi due to lack of support for internationalized domain names.
See: http://en.wikipedia.org/wiki/Internationalized_domain_name
I want to change from : http://việt.com/tin-nhắn/những-điều-cần-biết
to http://viet.com/tin-nhan/nhung-dieu-can-biet
because when people search they typing not enought Vietnamese sign , they type o for ô, e for ê.... etc
any one can help me ?
When people search, they get "fuzzy matching" by Google, which removes the problem of search-to-result matching.
@banxuanhoa So you do want the urls to be in english (latin)?
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
I'm a dress bar display Vietnamese language
http://raovatde.com/discussion/1/key-bản-quyền-windows-8-pro-phần-mềm-giá-rẻ-tlsoftwares-com#Item_1
but when I copy to another web browser, it became : http://raovatde.com/discussion/1/key-bản-quyền-windows-8-pro-phần-mềm-gia-rẻ-tlsoftwares-com#Item_1
I can't fix it anyone can help me Thanks !
I think You would need to change the title of the discussions so you get :
http://raovatde.com/discussion/1/key-ban-quyen-windows-8-pro-phan-mem-gia-re-tlsoftwares-com#Item_1
This may affect the actual title on the discussion too but for the meantime that is what you could do until I think of something else....the point is to prevent bad spelling in vietnamese so they find the page.
Notice that when you click the link above it sends you to the right place.
http://ellislab.com/codeigniter/user-guide/helpers/text_helper.html
or
tie into the convert_accented_characters function:
url_title(convert_accented_characters('ẻảếề'ắệôê));
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
@vrijvlinder : which file I must insert this function url_title(convert_accented_characters('ẻảếề'ắệôê));
I know how to replace string, but I don't know how to custom discussions URL
don't know edit wich file in source code
Well it is a php function so I would think it would need to be placed in the config.php.
Here is a javascript to achieve the same thing. This would likely go in the global.js
http://www.mindfiresolutions.com/Js-function-to-convert-accented-characters-to-corresponding-English-alphabets--349.php
Here is another version of php
http://css-tricks.com/snippets/php/convert-accented-characters/
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Edit file/Bạn sửa các ký tự cần thay thế hoặc loại bỏ ở tập tin: "library\core\class.format.php"
:
protected static $_CleanChars = array('OLDchar' => 'newCHAR',
:
OR add below: $Mixed = strtr($Mixed, self::$_CleanChars);
PHP Replace Function:
$aPattern = array (
"a" => "á|à|ạ|ả|ã|ă|ắ|ằ|ặ|ẳ|ẵ|â|ấ|ầ|ậ|ẩ|ẫ|Á|À|Ạ|Ả|Ã|Ă|Ắ|Ằ|Ặ|Ẳ|Ẵ|Â|Ấ|Ầ|Ậ|Ẩ|Ẫ",
"o" => "ó|ò|ọ|ỏ|õ|ô|ố|ồ|ộ|ổ|ỗ|ơ|ớ|ờ|ợ|ở|ỡ|Ó|Ò|Ọ|Ỏ|Õ|Ô|Ố|Ồ|Ộ|Ổ|Ỗ|Ơ|Ớ|Ờ|Ợ|Ở|Ỡ",
"e" => "é|è|ẹ|ẻ|ẽ|ê|ế|ề|ệ|ể|ễ|É|È|Ẹ|Ẻ|Ẽ|Ê|Ế|Ề|Ệ|Ể|Ễ",
"u" => "ú|ù|ụ|ủ|ũ|ư|ứ|ừ|ự|ử|ữ|Ú|Ù|Ụ|Ủ|Ũ|Ư|Ứ|Ừ|Ự|Ử|Ữ",
"i" => "í|ì|ị|ỉ|ĩ|Í|Ì|Ị|Ỉ|Ĩ",
"y" => "ý|ỳ|ỵ|ỷ|ỹ|Ý|Ỳ|Ỵ|Ỷ|Ỹ",
"d" => "đ|Đ",
);
while(list($key,$value) = each($aPattern))
{
$Mixed = @ereg_replace($value, $key, $Mixed);
}
/**
Url Translations Vietnamese
*/
protected static $_UrlTranslations = array('–' => '-', '—' => '-', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'Ae', 'Ä' => 'A', 'Å' => 'A', 'Ā' => 'A', 'Ą' => 'A', 'Ă' => 'A', 'Æ' => 'Ae', 'Ç' => 'C', 'Ć' => 'C', 'Č' => 'C', 'Ĉ' => 'C', 'Ċ' => 'C', 'Ď' => 'D', 'Đ' => 'D', 'Ð' => 'D', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ē' => 'E', 'Ě' => 'E', 'Ĕ' => 'E', 'Ė' => 'E', 'Ĝ' => 'G', 'Ğ' => 'G', 'Ġ' => 'G', 'Ģ' => 'G', 'Ĥ' => 'H', 'Ħ' => 'H', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ī' => 'I', 'Ĩ' => 'I', 'Ĭ' => 'I', 'Į' => 'I', 'İ' => 'I', 'IJ' => 'IJ', 'Ĵ' => 'J', 'Ķ' => 'K', 'Ł' => 'K', 'Ľ' => 'K', 'Ĺ' => 'K', 'Ļ' => 'K', 'Ŀ' => 'K', 'Ñ' => 'N', 'Ń' => 'N', 'Ň' => 'N', 'Ņ' => 'N', 'Ŋ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'Oe', 'Ö' => 'Oe', 'Ō' => 'O', 'Ő' => 'O', 'Ŏ' => 'O', 'Œ' => 'OE', 'Ŕ' => 'R', 'Ŗ' => 'R', 'Ś' => 'S', 'Š' => 'S', 'Ş' => 'S', 'Ŝ' => 'S', 'Ť' => 'T', 'Ţ' => 'T', 'Ŧ' => 'T', 'Ț' => 'T', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'Ue', 'Ū' => 'U', 'Ü' => 'Ue', 'Ů' => 'U', 'Ű' => 'U', 'Ŭ' => 'U', 'Ũ' => 'U', 'Ų' => 'U', 'Ŵ' => 'W', 'Ý' => 'Y', 'Ŷ' => 'Y', 'Ÿ' => 'Y', 'Ź' => 'Z', 'Ž' => 'Z', 'Ż' => 'Z', 'Þ' => 'T', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'ae', 'ä' => 'ae', 'å' => 'a', 'ā' => 'a', 'ą' => 'a', 'ă' => 'a', 'æ' => 'ae', 'ç' => 'c', 'ć' => 'c', 'č' => 'c', 'ĉ' => 'c', 'ċ' => 'c', 'ď' => 'd', 'đ' => 'd', 'ð' => 'd', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ē' => 'e', 'ę' => 'e', 'ě' => 'e', 'ĕ' => 'e', 'ė' => 'e', 'ƒ' => 'f', 'ĝ' => 'g', 'ğ' => 'g', 'ġ' => 'g', 'ģ' => 'g', 'ĥ' => 'h', 'ħ' => 'h', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ī' => 'i', 'ĩ' => 'i', 'ĭ' => 'i', 'į' => 'i', 'ı' => 'i', 'ij' => 'ij', 'ĵ' => 'j', 'ķ' => 'k', 'ĸ' => 'k', 'ł' => 'l', 'ľ' => 'l', 'ĺ' => 'l', 'ļ' => 'l', 'ŀ' => 'l', 'ñ' => 'n', 'ń' => 'n', 'ň' => 'n', 'ņ' => 'n', 'ʼn' => 'n', 'ŋ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'oe', 'ö' => 'oe', 'ø' => 'o', 'ō' => 'o', 'ő' => 'o', 'ŏ' => 'o', 'œ' => 'oe', 'ŕ' => 'r', 'ř' => 'r', 'ŗ' => 'r', 'š' => 's', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'ue', 'ū' => 'u', 'ü' => 'ue', 'ů' => 'u', 'ű' => 'u', 'ŭ' => 'u', 'ũ' => 'u', 'ų' => 'u', 'ŵ' => 'w', 'ý' => 'y', 'ÿ' => 'y', 'ŷ' => 'y', 'ž' => 'z', 'ż' => 'z', 'ź' => 'z', 'þ' => 't', 'ß' => 'ss', 'ſ' => 'ss', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Ж' => 'ZH', 'З' => 'Z', 'Й' => 'Y', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'ș' => 's', 'ț' => 't', 'Ț' => 'T', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'YU', 'Я' => 'YA', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh',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|è|ẹ|ẻ|ẽ|ê|ế|ề|ệ|ể|ễ|É|È|Ẹ|Ẻ|Ẽ|Ê|Ế|Ề|Ệ|Ể|Ễ",
"u" => "ú|ù|ụ|ủ|ũ|ư|ứ|ừ|ự|ử|ữ|Ú|Ù|Ụ|Ủ|Ũ|Ư|Ứ|Ừ|Ự|Ử|Ữ",
"i" => "í|ì|ị|ỉ|ĩ|Í|Ì|Ị|Ỉ|Ĩ",
"y" => "ý|ỳ|ỵ|ỷ|ỹ|Ý|Ỳ|Ỵ|Ỷ|Ỹ",
"d" => "đ|Đ",
);
while(list($key,$value) = each($aPattern)){
$Mixed = @ereg_replace($value, $key, $Mixed);
}
$Mixed = preg_replace('
[\']
', '', $Mixed);// Convert punctuation, symbols, and spaces to hyphens
if (unicodeRegexSupport()) {
$Mixed = preg_replace('
[\pP\pS\s]
u', '-', $Mixed);} else {
$Mixed = preg_replace('
[\W_]
', '-', $Mixed);}
// Lowercase, no trailing or repeat hyphens
$Mixed = preg_replace('
-+
', '-', strtolower($Mixed));$Mixed = trim($Mixed, '-');
return rawurlencode($Mixed);
}