WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.46k stars 4.18k forks source link

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

Open afercia opened 10 months ago

afercia commented 10 months ago

Description

Splitting this out from https://github.com/WordPress/gutenberg/issues/56381#issuecomment-1845056167

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':

https://github.com/WordPress/gutenberg/blob/40c233f929dc1668541a2fbd9eadd40d2b790bd0/packages/editor/src/components/post-publish-panel/postpublish.js#L128-L132

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:

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

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

SergeyBiryukov commented 10 months ago

Related: #28990

afercia commented 10 months ago

Thinking at this a little more in depth, I think including the linked post title in the 'published' or 'scheduled' string does or harms than good.

When publishing or scheduling a post, the most important information I'd like to have as a used is some feedback that confirms the post has been publishedor scheduled successfully. As a used, I would benefit from that information to be prominent in the post-publish panel. Instead, what I get is the linked post title in great prominence. The 'is now live' and 'is now scheduled' parts of the string are visually less prominent and not that readable. This i smore evident when the post title is long and goes in two lines. Screenshot to illustrate:

Screenshot 2023-12-12 at 09 23 15

I'd argue this isn't idea. While I understand some of the reasoning behind thie implementation, I think a clear, short, message that just informs me the publishing / scheduling was successful would be better. Im not sure the post title should be there in the first place. Also, making the post title a link seems redundant and just clutter the UI as there's a well visible 'View Post' button in the panel.

afercia commented 10 months ago

One more case: concatenating a string with a variable (in this case a component that renders different date and time in different format) is not translatable correctly:

https://github.com/WordPress/gutenberg/blob/16ec554a2605d45414ee121e2f36c1d7177974ad/packages/editor/src/components/post-publish-panel/postpublish.js#L104-L105

For example, when scheduling a post to be published today at a later time, PostScheduleLabel renders the word Today. I'm not sure on Today is correct English:

Screenshot 2023-12-12 at 14 37 27

More importantly, in other languages, on would need to be changed to something else or entirely omitted depending whether PostScheduleLabel renders a date or a word like Today. In Italian, for example, il 7 settembre is correct but il Oggi is totally wrong:

Screenshot 2023-12-12 at 14 36 15

Also, in languages other than English on may need to be changed to something else depending on the day number. for example, in Italian:

afercia commented 8 months ago

After various attempts, I realized that it's not possible to fix the translatable strings without introducing design changes. As such, I'd like to broaden the scope of this issue to propose a new, simpler, clearer, design of the publish panel. I'll update this issue title accordingly.