-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String Audit: False-positive for different translator comments #96
Comments
Oh, so it associates the comment with the preceeding I will try to look into this soon. Sounds like something that might need to be reported upstream at https://github.com/oscarotero/Gettext though. In the meantime... can you just refactor the code? 😜 |
Simple test case: // The Months
$month['01'] = /* translators: month name */ __( 'January' );
$month['02'] = /* translators: month name */ __( 'February' );
// Abbreviations for each month.
$month_abbrev[ __( 'January' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Jan', 'January abbreviation' );
$month_abbrev[ __( 'February' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Feb', 'February abbreviation' ); No problem with the #. translators: month name
#: test.php:3
#: test.php:7
msgid "January"
msgstr ""
#. translators: month name
#. translators: three-letter abbreviation of the month
#: test.php:4
#: test.php:8
msgid "February"
msgstr ""
#. translators: three-letter abbreviation of the month
#: test.php:7
msgctxt "January abbreviation"
msgid "Jan"
msgstr ""
#. translators: three-letter abbreviation of the month
#: test.php:8
msgctxt "February abbreviation"
msgid "Feb"
msgstr "" |
Reported upstream: php-gettext/Gettext#194 It's been a while since I looked at that library, so if anyone wants to investigate |
Suggested change in https://core.trac.wordpress.org/ticket/45628: $this->month_abbrev[ /* translators: month name */ __( 'December' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Dec', 'December abbreviation' ); Haven't tested if that works. |
That will only work if the other string actually also has a translators comment. |
See #154 for more examples |
This can be revisited now with https://github.com/php-gettext/Gettext/releases/tag/v4.8.5 being released, as it's most likely fixed. |
This specific code section win Given that, plus the upstream fix in Gettext, this can be closed. |
There are these warnings:
The string "September" exists here and here. The second one is the comment for
_x( 'Sep', 'September abbreviation' )
and not__( 'September' )
.The text was updated successfully, but these errors were encountered: