#6149 closed defect (bug) (fixed)
i18n strings logical issues
Reported by: | slaFFik | Owned by: | |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | major | Version: | |
Component: | I18N | Keywords: | needs-patch |
Cc: |
Description
Such things are very bad for i18n - generating translatable strings on a fly.
if ( 'delete-group' == $menu['slug'] ) { $title = sprintf( _x( '%s Group', 'Group WP Admin Bar delete link', 'buddypress' ), $menu['name'] ); }
I'm not only talking about this particular example, but the whole attitude.
In German that can be a one word, in Russian - we have tons of forms of words ("удалить группу", "удаление группы" etc - which mean the same but have different suffixes and endings depending on the context), other languages can have the word "Delete" split into several parts, where one should be before "Group", another - after it.
Change History (11)
#1
@
10 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
#2
@
10 years ago
bp-core-component.php
<label class="screen-reader-text" for="bp_components[<?php echo esc_attr( $name ); ?>]"><?php sprintf( __( 'Select %s', 'buddypress' ), esc_html( $labels['title'] ) ); ?></label>
#3
@
10 years ago
bp-groups-adminbar.php
:
$title = sprintf( _x( 'Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress' ), $menu['name'] );
#4
@
10 years ago
That's what I've found. But I may miss some strings, as there are hundreds (literally, like ~400) of such places (translatable strings with variables injections via sprintf()
or printf()
).
#5
@
10 years ago
- Milestone changed from Future Release to 2.3
Thanks very much for the specific examples, @slaFFik.
For the screen-reader-text, we can probably safely remove the translatable string altogether, and replace it with the component name. If someone thinks it's extremely important to have a verb in here, let's use the format 'Select component: %s', which is not terribly elegant, but should decline OK in most languages.
The 'Edit Group' link should either be changed to a string literal 'Edit Group' (with no group name), or a colon should be added 'Edit Group: %s'.
A general rule here is that we should never sprintf part of an English sentence. Nouns decline differently in different languages, verbs conjugate in ways we can't predict, etc. We should only sprintf stuff like URLs, CSS classes, etc. I'm guessing that most of the cases of sprintf()
or printf()
follow this rule, but there are probably many places where we can improve.
I'm going to move this ticket to 2.3 so that we can handle the specific strings listed here. As you continue to find more, please post them on this ticket.
With directory titles, we solved this in [8090]. See #4631.
In the particular case of 'delete-group', it looks like we should just be able to use a literal string 'Delete Group'.
slaFFik, if you know of other specific cases like this, please do list them here.