[wp-trac] [WordPress Trac] #57981: Export .po files error of untranslated strings starting or ending with new lines (\n)
WordPress Trac
noreply at wordpress.org
Fri Mar 24 20:08:21 UTC 2023
#57981: Export .po files error of untranslated strings starting or ending with new
lines (\n)
---------------------------+-----------------------------
Reporter: pedromendonca | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version: trunk
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
As found while dealing with GlotPress [see GitHub
issue]https://github.com/GlotPress/GlotPress/issues/1594, there is a bug
on the method `export_entry()` of class `PO` of core.
The PO method `match_begin_and_end_newlines()` has an early check for
`$translation`, early returns the variable without changing nothing if the
variable is `''` (empty).
As `match_begin_and_end_newlines()` is only early returning for `''`
(empty) values, fails and actually adds new lines on `null` translations,
which is wrong, and produces the undesired effect as seen in the GlotPress
export error mentioned above.
The problem is that when the translation don't exist, it's set to `null`,
not `''` (empty). But `export_entry()` sends to
`match_begin_and_end_newlines()` either `''` (empty) in case
`$entry->translations` is empty, or, of the translations array do exist,
each one might have `null` values, which is the correct default behavior.
So, for consistency probably `match_begin_and_end_newlines()` should only
check for `null` values to earlier return, and the `export_entry()` should
only sends `null` or non-empty strings in case there is an actual
translation.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57981>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list