Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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") {
}
Comment | File | Size | Author |
---|---|---|---|
#4 | OmegaT-po.patch | 762 bytes | raelianer |
#2 | locale.patch | 263 bytes | raelianer |
transdrupal.zip | 1.1 MB | raelianer |
Comments
Comment #0.0
raelianer CreditAttribution: raelianer commentedMore detailed description of the problem.
Comment #1
raelianer CreditAttribution: raelianer commentedOk, 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
Comment #2
raelianer CreditAttribution: raelianer commentedComment #4
raelianer CreditAttribution: raelianer commentedComment #5
raelianer CreditAttribution: raelianer commentedComment #6
chx CreditAttribution: chx commentedLooking at line 150 of gettext.inc this still seems to be a problem.
Comment #6.0
chx CreditAttribution: chx commentedmore details
Comment #18
quietone CreditAttribution: quietone at PreviousNext commentedTriaged 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!
Comment #19
quietone CreditAttribution: quietone at PreviousNext commentedFour months have passed with no reply confirming this is an issue. I also asked in #multilingual and there was not response.
Time to close.