Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.8k views
in Q2A Core by
Hi all,

I have a URL  looke like this : http://localhost/question2answer/6/xin-chào-mọi-người (1)

I want to change it to  http://localhost/question2answer/6/xin-chao-moi-nguoi (2)

It is  Vietnamse. I know the rule to change (1) to (2)

But , I dont know where to put the code.

3 Answers

+2 votes
by
edited by
 
Best answer

The accents are removed using the $qa_utf8removeaccents variable in qa-include/util/string.php. You'd need to add to the array lines such as

'à' => 'a',
'ọ' => 'o',

...and so on. However, the proper method to accomplish this is to make a function override plugin. Follow the instructions there, override the qa_string_initialize() function and do something like this:

function qa_string_initialize()
{
    qa_string_initialize_base();
    global $qa_utf8removeaccents;

    $qa_utf8removeaccents['à'] = 'a';
    $qa_utf8removeaccents['ọ'] = 'o';
    // etc
}

Hope that helps!

by
edited by
Thank you, Can not mark your answer is the best, I logged with FB, what's wrong ???
by
You seem to be using a different email on FB- you have to link both of your accounts I guess from your account page.
by
No , I used only one gmail account
by
When i check the question again. I saw " I wrote this question" . I remember I made this question directly on the web. not login. Now I know the reason.
+2 votes
by

Admin/Viewing

=>Remove accents from question URLs

by
Of course , I said I know how to remove the accents from URL, And I can write the code to do it. The question is "Which place to put the code?"
by
There is no code to put anywhere.
Go to http://www.example.com/question2answer/admin/viewing

Scroll to #2 option


1. Question title length in URLs:    ..............................................50 characters
2. Remove accents from question URLs:    ...............................checked
3. Count the number of question views: .................................checked
by
Thank @donshakespeare, I did what you said. But it seems the function does not work well  with Vietnamese accents. Do you know which place for the function remove the accents
0 votes
by
Hello again,

I put new post here because I think I may help others:

First I don't know the correct way to make a plugins like @Scott said,

Here is something I already tried:

normalize-url-vietnamese.php

class normalize_url_vietnamese{
    public function qa_string_initialize()
    {
        // qa_string_initialize_base();
        global $qa_utf8removeaccents;

        $qa_utf8removeaccents['á']='a';
        $qa_utf8removeaccents['à']='a';
        $qa_utf8removeaccents['ả']='a';
        $qa_utf8removeaccents['ã']='a';
        $qa_utf8removeaccents['ạ']='a';

        // blalalalalalala

        }

}

qa-plugin.php

<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
    header('Location: ../../');
    exit;
}

qa_register_plugin_module('filter', 'normalize-url-vietnamese.php', 'normalize_url_vietnamese', 'Normalize URL Vietnamese');

-------------------------------------------------------------------------------------------------

When I added

        $qa_utf8removeaccents['á']='a';
        $qa_utf8removeaccents['à']='a';
        $qa_utf8removeaccents['ả']='a';
        $qa_utf8removeaccents['ã']='a';
        $qa_utf8removeaccents['ạ']='a';

to util/string.php page, it just work for "question" only, "tags" and "category" not working, still keep wrong accents

Thank,
...