WordPress.org

Make WordPress Core

#20772 closed defect (bug) (fixed)

remove_accents() improvements for Chinese pinyin permalinks

Reported by: bolo1988 Owned by: 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 23 months ago.
20772.tests.patch (1.5 KB) - added by SergeyBiryukov 23 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 in reply to: ↑ description bolo198823 months 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

comment:2 bolo198823 months 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

SergeyBiryukov23 months ago

comment:3 SergeyBiryukov23 months 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]

comment:4 SergeyBiryukov22 months ago

  • Milestone changed from Future Release to 3.5

comment:5 nacin19 months 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.