The problem is also descibed here: https://sourceforge.net/tracker/?func=detail&atid=520347&aid=3418750&gro...

OmegaT produces files including entries without msgstr, this seems to be a problem for the import function in drupal.

Problematic part of the original .po-file exported by drupal:

#: /drupal-6.22/admin/settings/language
msgid ""
msgstr ""

#: /drupal-6.22/admin/settings/language
msgid "ICanLocalize"
msgstr ""

OmegaT export looks like this:

#: /drupal-6.22/admin/settings/language
msgid ""

#: /drupal-6.22/admin/settings/language     <== LINE 535
msgid "ICanLocalize"
msgstr ""

Error message: The translation file de.po contains an error: "msgstr" was expected but not found on line 535.

It seems the problem can be located at includes/locale.inc following line 1081:

function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = 'default') {

  while (!feof($fd)) {
    $line = fgets($fd, 10*1024); // A line should not be this long
    if ($lineno == 0) {
    $lineno++;
    $line = trim(strtr($line, array("\\\n" => "")));

    if (!strncmp("#", $line, 1)) { // A comment              <== line 535 contains a comment and $context has been set to "MSGID"
      if ($context == "COMMENT") { // Already in comment context: add
      elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one
      else { // Parse error
        _locale_import_message('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', $file, $lineno); // <== ERROR MESSAGE COMES FROM HERE
        return FALSE;
      }
    }
    elseif (!strncmp("msgid_plural", $line, 12)) {
    elseif (!strncmp("msgid", $line, 5)) {
      $line = trim(substr($line, 5));
      $quoted = _locale_import_parse_quoted($line);
      $current["msgid"] = $quoted;
      $context = "MSGID";                 // !!! $context set to "MSGID" at line 533 !!!
    }
    elseif (!strncmp("msgstr[", $line, 7)) {
    elseif (!strncmp("msgstr", $line, 6)) {
    elseif ($line != "") {
  }

  // End of PO file, flush last entry
  if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) {
  elseif ($context != "COMMENT") {
}
CommentFileSizeAuthor
#4 OmegaT-po.patch762 bytesraelianer
#2 locale.patch263 bytesraelianer
transdrupal.zip1.1 MBraelianer
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

raelianer’s picture

Issue summary: View changes

More detailed description of the problem.

raelianer’s picture

Ok, this is working for me:
Change line 1121:
elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one
to
elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR") || ($context == "MSGID")) { // End current entry, start a new one

raelianer’s picture

Status: Active » Needs review
FileSize
263 bytes

Status: Needs review » Needs work

The last submitted patch, locale.patch, failed testing.

raelianer’s picture

Status: Needs work » Needs review
FileSize
762 bytes
raelianer’s picture

Version: 6.22 » 6.x-dev
Component: translation.module » locale.module
chx’s picture

Version: 6.x-dev » 8.x-dev
Status: Needs review » Needs work

Looking at line 150 of gettext.inc this still seems to be a problem.

chx’s picture

Issue summary: View changes

more details

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: -import +Bug Smash Initiative

Triaged during a BugSmash group triage meeting.

There has been no activity here for 10 years, so maybe this has been resolved?

Is this issue still a problem?

Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Four months have passed with no reply confirming this is an issue. I also asked in #multilingual and there was not response.

Time to close.