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

Hi everyone,

I am working with Q2A in french and others language. I deactivate accents in URL, but they are stil accents in TAGS url.

I have this => mywebsite/tag/écrire-une-mémoire

Could you tell me where I can fixe this? Thanks in advance!

 

I am not the only one with that problem, there is no valid answer:

http://question2answer.org/qa/13187/bug-foreign-accents-not-removed-from-url-with-tags

http://question2answer.org/qa/19496/remove-accents-from-question-urls-work-tags-user-categories

http://question2answer.org/qa/25850/remove-accents-from-tag-url

Q2A version: Last one
by
Does the answer in #13187 work for you?
by
no a bit hard for me, and it's not a 100 reliable code like Gidgreen said. Well something more simple pereaps in qa.base.php a code, it's link to my question, have a look here => http://question2answer.org/qa/31878/url-rewriting-how-to-fully-capitalize-tags-urls
by
up, need answer...

1 Answer

+1 vote
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.
 

 

by
Hi!
This not work the new version for me.

no qa-util-string.php
I have qa-include/util/string.php

When I Put function convert_vi_to_en

and replace return....,

    function qa_string_remove_accents($string)
/*
    Return UTF-8 input $string with all accents (on Roman characters) removed
*/
    {
        if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

        global $qa_utf8removeaccents;

        return convert_vi_to_en($string);
    }


noting happend, my url:

http://www.gyorskerdes.hu/tag/Let%C3%B6lt%C3%A9s
http://www.gyorskerdes.hu/internet/link%C3%A9p%C3%ADt%C3%A9s

Remove accents (chechked)

Thx.
...