stuttter / wp-user-groups

Group users together with taxonomies & terms
https://wordpress.org/plugins/wp-user-groups/
GNU General Public License v2.0
48 stars 22 forks source link

i18n issue for some languages #7

Closed ms-studio closed 7 years ago

ms-studio commented 8 years ago

I submitted a pull request some time ago to make the labels on Group edit pages translatable. In the meantime, I noticed that this solution isn't perfect and causes issues for some languages.

Currently, the labels for Group edit pages are defined in class-user-taxonomy:

'search_items'               => sprintf( __( 'Search %s', 'wp-user-groups' ),                $this->tax_plural ),
'popular_items'              => sprintf( __( 'Popular %s', 'wp-user-groups' ),               $this->tax_plural ),
'all_items'                  => sprintf( __( 'All %s', 'wp-user-groups' ),                   $this->tax_plural ),
'parent_item'                => sprintf( __( 'Parent %s', 'wp-user-groups' ),                $this->tax_singular ),
'parent_item_colon'          => sprintf( __( 'Parent %s:', 'wp-user-groups' ),               $this->tax_singular ),
'edit_item'                  => sprintf( __( 'Edit %s', 'wp-user-groups' ),                  $this->tax_singular ),
'view_item'                  => sprintf( __( 'View %s', 'wp-user-groups' ),                  $this->tax_singular ),
'update_item'                => sprintf( __( 'Update %s', 'wp-user-groups' ),                $this->tax_singular ),
'add_new_item'               => sprintf( __( 'Add New %s', 'wp-user-groups' ),               $this->tax_singular ),     

This is problematic for languages with more intricate grammar, because the adjectives (Popular, All, Parent) may need to differ according to the gender of the taxonomy (in languages that support male/female nouns).

For example in French, if one group is "Groupes" (male), and the other "Classes" (female), the 'All %s' label must translate as:

When registering a WordPress taxonomy with register_taxonomy(), those labels are defined for each taxonomy, which allows them to be gender-specific.

In this plugin, WP_User_Taxonomy simplifies the process by only specifying 'singular' and 'plural', which seems to make things easier... but the side-effect is that we get the grammar wrong for some languages :-/

How to fix it?

It should be possible to define the labels explicitly for each WP_User_Taxonomy object, the same way as with register_taxonomy().

Possibly, the current situation could work as a fallback, so there's less tedious repetition for gender-neutral languages.

JJJ commented 7 years ago

The WP_User_Taxonomy class accepts a 4th parameter for $labels which is used to override the singular/plural setup. This doesn't help the 2 core group-type's labels, but does mean anyone who currently needs this to work more accurately has a work-around until I can look at this more.

JJJ commented 7 years ago

Sorry for the delay on this. I've looked at it again, and based on my current understanding of the GetText API, I believe my comment above is probably still the best approach.

Also, new in WordPress 4.4 is a register_taxonomy_args filter, that will allow just-in-time filtering of the labels, as well as all of the other attributes.

Thanks for opening this issue. If I've misunderstood or if there's a better approach, please reopen as needed.