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

Dear friends, 

I have realized that "Remove Accents in URL" only works for question titles. And for category slug you can edit it manually. So the URL for these two are not problem who ones who use q2a in different language than English.

However, the accents are still existing in TAGS and USERNAME. I searched through this site but I have not found any solutions, even though this topic was asked many times, check out following links.

@namgivu posted a solution like creating a new function convert_vi_to_en($str)  and follow some steps, however, this is nothing to do with tags and usernames. This solution is for question URL, which is already fine.

Q2A version: 1.7.4 fairly modified and customized

1 Answer

+2 votes
by
edited by

Dear friends,

I managed to remove accents from TAGS and USERNAME by myself. if you want to do this as well, follow this.

1) for TAGS -> open util/string.php
- Find  function qa_tags_to_tagstring($tags)
- Replace these function with below.

    function qa_tags_to_tagstring($tags)
/*
    Convert an array of tags into a string for storage in the database
*/
    {
        if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
        
         $tag = implode(',', $tags);
        return qa_string_remove_accents($tag);
    }

2) for USERNAMES -> open app/users.php

-Find function qa_get_one_user_html($handle, $microformats=false, $favorited=false)

-Replace this function with below code

function qa_get_one_user_html($handle, $microformats=false, $favorited=false)

/*

Return HTML to display for user with username $handle, with microformats if $microformats is true. Set $favorited to true to show the user as favorited.

*/

{

if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

require_once QA_INCLUDE_DIR.'util/string.php';

if (!strlen($handle))

return '';

$url = qa_path_html('user/'.qa_string_remove_accents($handle));

$favclass = $favorited ? ' qa-user-favorited' : '';

$mfclass = $microformats ? ' url fn entry-title nickname' : '';

return '<a href="'.$url.'" class="qa-user-link'.$favclass.$mfclass.'">'.qa_html($handle).'</a>';

}

- Find  function qa_get_user_avatar_html($flags, $email, $handle, $blobid, $width, $height, $size, $padding=false)

-Replace this function with below

function qa_get_user_avatar_html($flags, $email, $handle, $blobid, $width, $height, $size, $padding=false)

/*

Return HTML to display for the user's avatar, constrained to $size pixels, with optional $padding to that size

Pass the user's fields $flags, $email, $handle, and avatar $blobid, $width and $height

*/

{

if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

require_once QA_INCLUDE_DIR.'app/format.php';

require_once QA_INCLUDE_DIR.'util/string.php';

if (qa_opt('avatar_allow_gravatar') && ($flags & QA_USER_FLAGS_SHOW_GRAVATAR))

$html=qa_get_gravatar_html($email, $size);

elseif (qa_opt('avatar_allow_upload') && (($flags & QA_USER_FLAGS_SHOW_AVATAR)) && isset($blobid))

$html=qa_get_avatar_blob_html($blobid, $width, $height, $size, $padding);

elseif ( (qa_opt('avatar_allow_gravatar')||qa_opt('avatar_allow_upload')) && qa_opt('avatar_default_show') && strlen(qa_opt('avatar_default_blobid')) )

$html=qa_get_avatar_blob_html(qa_opt('avatar_default_blobid'), qa_opt('avatar_default_width'), qa_opt('avatar_default_height'), $size, $padding);

else

$html=null;

return (isset($html) && strlen($handle)) ? ('<a href="'.qa_path_html('user/'.qa_string_remove_accents($handle)).'" class="qa-avatar-link">'.$html.'</a>') : $html;

}

This worked for me. 

...