Prevent broken translations in some locales for the edit post link #1066

Open
wants to merge 3 commits into
from

Projects

None yet

3 participants

@yoavf
Member
yoavf commented Jan 3, 2017

Since #775, the translation of the edit post link in some languages can end up forming a partial sentence.

By default, in English, the visual output is the word "Edit".
In Hebrew for example, the translation would be a single word:

לערוך

With the addition of the post title, the translator is instructed to translate Edit %s with %s being the post name. In Hebrew, the translation will be

לערוך את %s

Note the added word את

To quote from this post:

The word את comes before a definite object. It has no equivalent in the English language.

The end visual result in Hebrew would be:

לערוך את

Which is weird. Think of it as "Edit The" (without the actual object).

This PR fixes that by expanding the comment to note that the post name only visible to screen readers, and puts the screen reader span html inside the translated string.
The translator for Hebrew can now do something like
לערוך <span class="screen-reader-text">את %s</span>, putting the את word inside the invisible span.

@yoavf yoavf added the Has Patch label Jan 3, 2017
@grappler

Otherwise 👍

inc/template-tags.php
- esc_html__( 'Edit %s', '_s' ),
- the_title( '<span class="screen-reader-text">"', '"</span>', false )
+ /* translators: %s: Name of current post. Only visible to screen readers */
+ __( 'Edit <span class="screen-reader-text">%s</span>', '_s' ),
@grappler
grappler Jan 3, 2017 Contributor

Previously the function was esc_html__(). It is best not to change that.

@yoavf
yoavf Jan 3, 2017 Member

That's won't work now that we have the html back in the string.

@grappler
grappler Jan 3, 2017 Contributor

Oh, then we will need to use wp_kses() like done here: https://github.com/Automattic/_s/blob/master/inc/template-tags.php#L65

@yoavf yoavf changed the title from Fix issue to Prevent broken translations in some locales for the edit post link Jan 3, 2017
@jrfnl

I believe this could have been fixed by just adjusting the translators comment to be more clear, rather than changing the actual code.

@yoavf
Member
yoavf commented Jan 3, 2017

believe this could have been fixed by just adjusting the translators comment to be more clear, rather than changing the actual code.

My first instinct was to do just that - but that means (for Hebrew) choosing to omit a word from the screen reader version. It is not a better outcome.

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