Skip to content

Post publish panel: Simplify design and follow best practices for localization #56854

Open
@afercia

Description

@afercia

Description

Splitting this out from #56381 (comment)

WordPress best practices for localization strongly recommend to avoid translatable strings that concatenate or contain variables, because the variable may differ in gender and number in languages other than English. In these cases it would be impossible to correctly translate the string.

There are several cases in the Gutenberg codebase where this recommendation is not followed. One of these cases is in the 'post publish pane':

label={ sprintf(
/* translators: %s: post type singular name */
__( '%s address' ),
postLabel
) }

The above string can't be translated correctly. The placeholder gets replaced with the post type, which can vary in gender.

While in English 'Post address', 'Page address' or 'Product address' etc. are perfectly okay, in ohter languages translators would need to:

  • Use an appropriate gender form, for example in Italian:
    • Indirizzo dell'articolo
    • Indirizzo della pagina
  • Change the order of the words in the string but they can't do it if they don't know what %s will be replaced with.

These string should:

Right now thie can't be translated correctly and we can't blame translators for this. Given this string:

__( '%s address' ),

translators can only translate address and hope that it will rok in all cases. Unfortunately, it doesn't worl

The same problem occurs when concatenating text. Concatenation should always be avoided. This is not translatable corrrectly:

https://github.com/WordPress/gutenberg/blob/trunk/packages/editor/src/components/post-publish-panel/postpublish.js/#L114-L117

because in many languages the adjectives published and scheduled vary in gender depending whether the post type name is male or female.

Screenshots comparing Post / Page panels in English and Italian:

Screenshot 2023-12-07 at 10 49 33

Step-by-step reproduction instructions

  • Switch the WordPress admin to a language with gender forms e.g. Italian.
  • Publish a post or page.
  • In the post-publish panel, observe the strings mentioned above in the issue description can't be translated correctly.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Needs Design FeedbackNeeds general design feedback.[Package] Editor/packages/editor[Type] BugAn existing feature does not function as intendedl10nLocalization and translations best practices

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions