Problem/Motivation

When using PoItem to export translation strings, the linebreak output differs between translated and untranslated strings.

Steps to reproduce

$untranslated = new PoItem();
$untranslated->setSource("");

// msgid ""
// msgstr ""
$untranslated->__toString():

$translated = new PoItem();
$translated->setSource("");
$translated->setTranslation("");

// msgid ""
// msgstr ""
//
$translated->__toString();

Proposed resolution

Append line break to singular untranslated string output for consistency with other cases.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#5 drupal-3278481-5-testonly.patch2.42 KBgapple

Issue fork drupal-3278481

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gapple created an issue. See original summary.

gapple’s picture

Status: Active » Needs review
andypost’s picture

Status: Needs review » Needs work

as a bug it needs fail.patch

gapple’s picture

StatusFileSize
new2.42 KB

easy 'nuff - I just edited the MR diff to only include the test in this patch file.

gapple’s picture

Status: Needs work » Needs review
andypost’s picture

Status: Needs review » Needs work

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave made their first commit to this issue’s fork.

smustgrave’s picture

having a terrible time rebasing this lol

andypost’s picture

Status: Needs work » Needs review

Used to run test for 11.x and cherry-picked commit from previous MR (thanks smustgrave for 9.5)

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Think this looks good now

alexpott’s picture

There's so much odd code in this class...

    foreach ($this->translation as $i => $trans) {
      if (isset($this->translation[$i])) {
        $output .= 'msgstr[' . $i . '] ' . $this->formatString($trans);
      }
      else {
        $output .= 'msgstr[' . $i . '] ""' . "\n";
      }
    }

Afaics if (isset($this->translation[$i])) { must be true. I'm not even sure what that code is try to do... - maybe handle the case where one of the plural forms is not translated.

Anyhow this fix is fine.

  • alexpott committed be9783de on 11.x
    Issue #3278481 by andypost, gapple, smustgrave: PoItem::formatSingular...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Going to commit to 11.x only as I don;t see why po files should change in a patch release. It's not like this is causing any real bugs.

Committed be9783d and pushed to 11.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.