Skip to content

Hierarchical term selector: don't use variables in translatable strings #13936

@afercia

Description

@afercia

In core, it's a long established, good, practice to avoid post types, taxonomies, etc. variable names for placeholders in translatable strings. It doesn't work due to structural differences in languages: feminine, masculine, various form of plurals, etc.

const filterLabel = sprintf(
_x( 'Search %s', 'term' ),
get(
this.props.taxonomy,
[ 'name' ],
slug === 'category' ? __( 'Categories' ) : __( 'Terms' )
)
);
const groupLabel = sprintf(
_x( 'Available %s', 'term' ),
get(
this.props.taxonomy,
[ 'name' ],
slug === 'category' ? __( 'Categories' ) : __( 'Terms' )
)
);

These strings should be either simplified or use full translatable strings added in core for the taxonomies.

There are also other minor consequences. For example, in Italian (and I guess in many other languages) we don't use title casing. However, the first string placeholder is placed with the taxonomy name so the final result is a title cased string. Unpleasant to see, as all the other strings don't use title casing:

screenshot 2019-02-18 at 22 09 02

The second string is translated as:

aria-label="Disponibile Categorie"

which is wrong, but I can't blame translators as _x( 'Available %s', 'term' ) is difficult to translate and not visible in the interface.

In these cases, I'd recommend to:

  • either simplify the strings and remove placeholders
  • or introduce new taxonomie label in core and use them in the editor

Metadata

Metadata

Assignees

No one assigned

    Labels

    Internationalization (i18n)Issues or PRs related to internationalization efforts[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions