Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
660 views
in Q2A Core by

There is a setting in Admin->Viewing->Remove Accents from Question URL's which works to have foreign accents removed from question pages.

however, if you have someone use accents in a tag for a question, the tag page shows up with foreign accents in the URL. So for example, I have a tag called: recuperação - which has 'c' with an accent and 'a' with an accent. These show up in the URL for this word. This is not the way it should be.

How can this be fixed? I presume the questions are sent into some function to clean up the accents, but how do you send the tags thru the same function to clean them up?

On the page itself the tags should have the accents, but not in the URL. Just like it is for questions

Q2A version: 1.5

2 Answers

0 votes
by

You could have a plugin which overrides qa_tag_html() in qa-app-format.php, and calls the qa_string_remove_accents(...) function from qa-util-string.php on the $tag parameter, before calling through to the base function with the result.

However this also means that the tag will show up without accents on the tag page itself. To fix that latter problem, you can add the following in qa-page-tag.php, before the section entitled 'Prepare content for theme':

$tag=@$tagword['word'];

This might cause other glitches on the page, so let us know how it works for you.

by
Hi Gidgreen! Please tell me more? I need your help! Thanks!
0 votes
by

The similar question to yours is solved for URL here - quoted as below


You can add new function to replace your language charater with latin character, after that, you modify function qa_string_remove_accents on qa-util-string.php that return from your new function.

Below is a example that replace Vietnammese characters to latin: 

Step 1: Add new function to qa-util-string.php:

function convert_vi_to_en($str) {
$str = preg_replace('/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/', 'a', $str);
$str = preg_replace('/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/', 'e', $str);
$str = preg_replace('/(ì|í|ị|ỉ|ĩ)/', 'i', $str);
$str = preg_replace('/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/', 'o', $str);
$str = preg_replace('/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/', 'u', $str);
$str = preg_replace('/(ỳ|ý|ỵ|ỷ|ỹ)/', 'y', $str);
$str = preg_replace('/(đ)/', 'd', $str);
$str = preg_replace('/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/', 'A', $str);
$str = preg_replace('/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/', 'E', $str);
$str = preg_replace('/(Ì|Í|Ị|Ỉ|Ĩ)/', 'I', $str);
$str = preg_replace('/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/', 'O', $str);
$str = preg_replace('/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/', 'U', $str);
$str = preg_replace('/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/', 'Y', $str);
$str = preg_replace('/(Đ)/', 'D', $str);
return $str;

 

}
Step 2: change statement: return strtr($string, $qa_utf8removeaccents) on function qa_string_remove_accents($string) to return convert_vi_to_en($string);
 
PS: you must check to Remove accents from question URLs on viewing option in admin panel.
 

 

...