4

im having a problem with PoEdit I used a software called PO-Auto-Translator to translate a po file and once it was done i wanted to continue editing the file with poedit, when i try to save i get many errors...

    04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:46: missing 'msgstr' section
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:46:22: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:51: missing 'msgstr' section
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:51:22: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:52: keyword "$s" unknown
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:795: keyword "Upload" unknown
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:795:55: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:1583: missing 'msgstr' section
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:1583:27: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:1584: keyword "s" unknown
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:1597:28: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:1597: keyword "s" unknown
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4162:14: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4163: end-of-line within string
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4167:14: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4167: keyword "Admin" unknown
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4168: end-of-line within string
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4172:14: syntax error
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4173: end-of-line within string
04/21/14 22:39:12: C:\Users\home\Desktop\translation.po:4176:31: syntax error
04/21/14 22:39:12: C:\Program Files (x86)\Poedit\GettextTools\bin\msgfmt.exe: too many errors, aborting

i compared the file to other files who dont show this error and didnt find a problem with it.

here are the first 50 lines of the translation

# Translation of translation
msgid ""
msgstr ""
"Project-Id-Version: translation\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-12-05 10:43+0100\n"
"PO-Revision-Date: 2014-04-21 22:39+0200\n"
"Last-Translator: \n"
"Language-Team: AppThemes\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.6.4\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_nx:1,2;_x:1,2c;_ex:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:1,2,3c\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: .\n"

#: 404.php:22
msgid "Whoops! Page Not Found."
msgstr "אופס! דף לא נמצא."

#: 404.php:24
#: 404.php:44 search.php:77 includes/theme-actions.php:218
msgid "Sponsored Links"
msgstr "קישורים ממומנים"

#: attachment.php:19
#, php-format
msgid "Return to %s"
msgstr "חזור אל% s"

#: attachment.php:20
#, php-format
msgid "← Return to %s"
msgstr "? חזור אל% s"

#: attachment.php:31
#, php-format
msgid "<span class="%1$s">By</span> %2$s"  /line 46
msgstr "ש"

#: attachment.php:44
#, php-format
msgid "<span class="%1$s">Uploaded</span> %2$s"
msgstr "<span class="%1$s">Uploaded</span> %2$s"

#: attachment.php:55
#, php-format
msgid "Full size is %s pixels"
msgstr "גודל מלא הוא פיקסלים% s"

can anyone see whats the problem of my file?

Dani
  • 79
  • 2
  • 12

3 Answers3

6

Your PO file is invalid — it doesn't follow PO file format syntax and doesn't escape quotes within string literals. msgid "foo"bar" is invalid, unlike msgid "foo\"bar", similarly to C, PHP or many other languages.

IMNSHO, you should ditch whatever tool produced such horribly broken PO files (it definitely wasn't Poedit as the X-Generator header would imply) immediately and replace it with something that actually knows its output format. Such as xgettext, the standard tool for gettext strings extraction. It supports PHP just fine.

If the tool is something homegrown, here's a very good description of the PO format by Chusslove Illich of Pology: http://pology.nedohodnik.net/doc/user/en_US/ch-poformat.html (unofficial, but much better than GNU gettext's own manual). If you write or read PO files in any of your code, I highly recommend it.

Václav Slavík
  • 6,445
  • 2
  • 28
  • 25
3

For anyone reading this and having trouble debugging errors showing in POEdit from your po files, you can run:

msgfmt -v -c mypofile.po

It will show every error shown in your po file with the line associated to it.

Also, you can use Catalogue > Purge Deleted Translations from the POEdit menu that will save you a ton of issues and making your po file lighter.

Eric Martin
  • 2,247
  • 1
  • 16
  • 16
1

I found the problem. I need to manually add \ next to every " where poedit gave the error... Little by little I fixed it and it works :)

Greg
  • 18,111
  • 5
  • 46
  • 68
Dani
  • 79
  • 2
  • 12