[wp-trac] [WordPress Trac] #7897: Commas should be internationalized
WordPress Trac
wp-trac at lists.automattic.com
Tue Feb 7 18:03:31 UTC 2012
#7897: Commas should be internationalized
-------------------------+-------------------------
Reporter: huji | Owner: nbachiyski
Type: enhancement | Status: assigned
Priority: normal | Milestone: 3.4
Component: I18N | Version: 2.9
Severity: normal | Resolution:
Keywords: needs-patch |
-------------------------+-------------------------
Comment (by nacin):
[attachment:7897.diff] approaches this holistically. It works for bulk
edit, quick edit, and the tags meta box (including without JS). It also
works for both an internationalized comma and the existing standard comma,
intermingled, in case they are different, or if force of habit causes
someone to continue to use the standard comma.
Standardization occurs in very specific places.
Rendering tag strings (PHP displays):
* get_terms_to_edit(), which joins tags with a comma and escapes the
result, is not modified. This is for compatibility reasons with plugins,
who may expect to do a PHP explode or JS split on this data.
* get_inline_data(), which uses get_terms_to_edit(), is not modified. It
currently does a replacement on the result from get_terms_to_edit(),
adding a space after each comma. Again, this is not modified for
compatibility reasons.
* What ''is'' modified is the tags meta box code. In this case, the terms
string is going directly into a textarea. So, we find all commas and
replace it with the internationalized comma, along with a trailing space.
(This did not occur in 3.3, resulting in "apple,pear,orange" with no JS.)
Saving tag strings (PHP saves):
* wp_set_post_terms() is where the explode-by-commas may take place. It
will now first find all L10n commas and replace them with standard commas
before continuing with the explode. This is done in part to allow both
commas to work, and in part because we can't reliably trim() an html
entity as well as we can trim a leading or trailing comma.
* bulk_edit_posts() is where the other explode-by-commas takes place on
save. It will now do the same thing as wp_set_post_terms(), improving its
cleaning regex in the process.
Working with tag strings (in JS):
* In post.dev.js, care is taken to properly clean/sanitize the new
string. Since the comma is sometimes used in a character class
(tagBox.clean), and an html entity could cause problems here, the L10n
comma is first replaced with a standard comma, and then switched back when
done.
* In inline-edit-post.dev.js, there is a find-replace for converting the
standard comma to the L10n comma. This is because it is relying on a
standard comma-separated term string from get_inline_data() (see above for
more).
* In post.dev.js and inline-edit-post.dev.js, the only other changes are
to specify the localized separator for tag suggestions, and properly split
or join on the new localized comma.
Tag suggestions:
* In ajax-tag-search, L10n commas are first replaced with standard commas
before exploding.
This was the code I was using to test:
{{{
add_filter( 'gettext_with_context', 'nacin_test_l10n_comma', 10, 3 );
function nacin_test_l10n_comma( $translated, $text, $context ) {
if ( $text == ',' && $context == 'tag delimiter' )
return '`';
return $translated;
}
}}}
Let's soak this in trunk.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/7897#comment:18>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list