admin管理员组

文章数量:1023876

I want to make a WP website in Turkish that shows the proper Turkish alphabet characters in the URL fields in the webbrowser and in WP instead of the English alphabet ones. I tried it already but I don't succeed at it. What happens is, instead of the Turkish characters like these: "Çok güzel bir saksı yapmışlar önümüzdekiler" it shows their 'closest relatives' English character ones, like this: "Cok guzel bir saksi yapmislar onumuzdekiler".

I don't know why this happens and how I can get those proper Turkish characters in the URLs in WP. Anybody have an idea?

How I did it now: I manually installed WP and edited the wp-config.php file to enter my database values and entered these values:

The database character set: I leave it at utf8, so this:

define('DB_CHARSET', 'utf8');

DB_COLLATE: I've read that the database collation should normally be left blank except for Turkish language sites which need to have: 'utf8_turkish_ci'. So this:

define('DB_COLLATE', 'utf8_turkish_ci');

So I did all this on one Turkish language site already but the URL fields still don't show the proper Turkish alphabet characters but instead their closest English alphabet characters.

So I would like to know: What determines which alphabet's characters get to be shown in the URL fields?

And what do I need to do to get this done?

I want to make a WP website in Turkish that shows the proper Turkish alphabet characters in the URL fields in the webbrowser and in WP instead of the English alphabet ones. I tried it already but I don't succeed at it. What happens is, instead of the Turkish characters like these: "Çok güzel bir saksı yapmışlar önümüzdekiler" it shows their 'closest relatives' English character ones, like this: "Cok guzel bir saksi yapmislar onumuzdekiler".

I don't know why this happens and how I can get those proper Turkish characters in the URLs in WP. Anybody have an idea?

How I did it now: I manually installed WP and edited the wp-config.php file to enter my database values and entered these values:

The database character set: I leave it at utf8, so this:

define('DB_CHARSET', 'utf8');

DB_COLLATE: I've read that the database collation should normally be left blank except for Turkish language sites which need to have: 'utf8_turkish_ci'. So this:

define('DB_COLLATE', 'utf8_turkish_ci');

So I did all this on one Turkish language site already but the URL fields still don't show the proper Turkish alphabet characters but instead their closest English alphabet characters.

So I would like to know: What determines which alphabet's characters get to be shown in the URL fields?

And what do I need to do to get this done?

Share Improve this question edited May 8, 2019 at 9:58 Pratik Patel 1,1111 gold badge11 silver badges23 bronze badges asked May 8, 2019 at 8:51 HansHans 557 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The function [sanitize_title()][1] generates slugs. This function makes a subsequent call to remove_accents(). This function is found in /wp-includes/formatting.php and includes a map of all character conversions (just FYI).

This only occurs in the "save" context of sanitize_title() which is the default.

Removing accents is not necessary, but it helps ensure the posts slug only contains certain characters. To replace this, you will have to build your own remove_accents() that includes Turkish special characters.

Assuming you've done this and called it my_remove_accents(), let's move forward.

function my_sanitize_title( $title, $raw_title ) {
    return my_remove_accents( sanitize_title_with_dashes( $raw_title ) );
}
add_filter( 'sanitize_title', 'my_sanitize_title', 99, 2 );

sanitize_title_with_dashes() is added to the sanitize_title filter rather than being called from the sanitize_title() function. Calling this function does not replace any accented characters.

I want to make a WP website in Turkish that shows the proper Turkish alphabet characters in the URL fields in the webbrowser and in WP instead of the English alphabet ones. I tried it already but I don't succeed at it. What happens is, instead of the Turkish characters like these: "Çok güzel bir saksı yapmışlar önümüzdekiler" it shows their 'closest relatives' English character ones, like this: "Cok guzel bir saksi yapmislar onumuzdekiler".

I don't know why this happens and how I can get those proper Turkish characters in the URLs in WP. Anybody have an idea?

How I did it now: I manually installed WP and edited the wp-config.php file to enter my database values and entered these values:

The database character set: I leave it at utf8, so this:

define('DB_CHARSET', 'utf8');

DB_COLLATE: I've read that the database collation should normally be left blank except for Turkish language sites which need to have: 'utf8_turkish_ci'. So this:

define('DB_COLLATE', 'utf8_turkish_ci');

So I did all this on one Turkish language site already but the URL fields still don't show the proper Turkish alphabet characters but instead their closest English alphabet characters.

So I would like to know: What determines which alphabet's characters get to be shown in the URL fields?

And what do I need to do to get this done?

I want to make a WP website in Turkish that shows the proper Turkish alphabet characters in the URL fields in the webbrowser and in WP instead of the English alphabet ones. I tried it already but I don't succeed at it. What happens is, instead of the Turkish characters like these: "Çok güzel bir saksı yapmışlar önümüzdekiler" it shows their 'closest relatives' English character ones, like this: "Cok guzel bir saksi yapmislar onumuzdekiler".

I don't know why this happens and how I can get those proper Turkish characters in the URLs in WP. Anybody have an idea?

How I did it now: I manually installed WP and edited the wp-config.php file to enter my database values and entered these values:

The database character set: I leave it at utf8, so this:

define('DB_CHARSET', 'utf8');

DB_COLLATE: I've read that the database collation should normally be left blank except for Turkish language sites which need to have: 'utf8_turkish_ci'. So this:

define('DB_COLLATE', 'utf8_turkish_ci');

So I did all this on one Turkish language site already but the URL fields still don't show the proper Turkish alphabet characters but instead their closest English alphabet characters.

So I would like to know: What determines which alphabet's characters get to be shown in the URL fields?

And what do I need to do to get this done?

Share Improve this question edited May 8, 2019 at 9:58 Pratik Patel 1,1111 gold badge11 silver badges23 bronze badges asked May 8, 2019 at 8:51 HansHans 557 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The function [sanitize_title()][1] generates slugs. This function makes a subsequent call to remove_accents(). This function is found in /wp-includes/formatting.php and includes a map of all character conversions (just FYI).

This only occurs in the "save" context of sanitize_title() which is the default.

Removing accents is not necessary, but it helps ensure the posts slug only contains certain characters. To replace this, you will have to build your own remove_accents() that includes Turkish special characters.

Assuming you've done this and called it my_remove_accents(), let's move forward.

function my_sanitize_title( $title, $raw_title ) {
    return my_remove_accents( sanitize_title_with_dashes( $raw_title ) );
}
add_filter( 'sanitize_title', 'my_sanitize_title', 99, 2 );

sanitize_title_with_dashes() is added to the sanitize_title filter rather than being called from the sanitize_title() function. Calling this function does not replace any accented characters.

本文标签: languageGetting Turkish alphabet characters in the URL field in webbrowser