Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#20772 closed defect (bug) (fixed)

remove_accents() improvements for Chinese pinyin permalinks

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

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 14 years ago.
20772.tests.patch​ (1.5 KB ) - added by SergeyBiryukov 14 years ago.

Download all attachments as: .zip

Change History (7)

#1 in reply to: ↑ description @bolo1988
14 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
14 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
14 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review → Future Release

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

Unit tests: ​[UT724]

#4 @SergeyBiryukov
14 years ago

  • Milestone Future Release → 3.5

#5 @nacin
14 years ago

  • Owner set to nacin
  • Resolution → fixed
  • Status new → 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.