Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#20772 closed defect (bug) (fixed)

remove_accents() improvements for Chinese pinyin permalinks

Reported by: bolo1988's profile bolo1988 Owned by: nacin's profile nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.3.2
Component: I18N Keywords: has-patch
Focuses: Cc:

Description

echo str_replace(' ', '-', str_replace('.', '', sanitize_file_name(remove_accents(strtolower('Lǚcì')))));

the result:

lǚcì

and i found remove_accents() can't convert the following chars:
ǎ -> a
ǒ -> o
ǚ -> v/u
ǐ -> i
ǔ -> u

Attachments (2)

20772.patch (1.4 KB) - added by SergeyBiryukov 12 years ago.
20772.tests.patch (1.5 KB) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (7)

#1 in reply to: ↑ description @bolo1988
12 years ago

Replying to bolo1988:

echo str_replace(' ', '-', str_replace('.', '', sanitize_file_name(remove_accents(strtolower('Lǚcì')))));

the result:

lǚcì

and i found remove_accents() can't convert the following chars:
ǎ -> a,
ǒ -> o,
ǚ -> v/u,
ǐ -> i,
ǔ -> u

#2 @bolo1988
12 years ago

		$pinyin_in = array(
			chr(199).chr(142) => 'a',
			chr(199).chr(144) => 'i',
			chr(199).chr(146) => 'o',
			chr(199).chr(148) => 'u',
			chr(199).chr(154) => 'u',
		);
		$output = str_replace(array_keys($pinyin_in), $pinyin_in, $string);

This code can fixed the problem

#3 @SergeyBiryukov
12 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to Future Release

20772.patch adds the missing Pinyin diacritics to the replacement list.

Unit tests: [UT724]

#4 @SergeyBiryukov
12 years ago

  • Milestone changed from Future Release to 3.5

#5 @nacin
12 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [21859]:

Add Pinyin diacritics to remove_accents(). Remove these diacritics in sanitize_title_with_dashes() on save as well. props bolo1988, SergeyBiryukov. fixes #20772.

Note: See TracTickets for help on using tickets.