zanata / tennera

Various Java i18n tools, including tools for processing the Gettext and Properties formats
https://fedorahosted.org/tennera/
15 stars 6 forks source link

Does not treat tabs as white space #2

Closed bmTas closed 12 years ago

bmTas commented 12 years ago

When a tab is entered on a blank line between messages, jgettext generates this message:

Exception in thread "main" org.fedorahosted.tennera.jgettext.catalog.parse.UnexpectedTokenException: unrecognized entry directive [ ] [line=28]
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogLexer$Tokenizer.processEntry(CatalogLexer.java:352)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogLexer$Tokenizer.processLine(CatalogLexer.java:234)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogLexer$Tokenizer.readToken(CatalogLexer.java:156)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogLexer$Tokenizer.hasNext(CatalogLexer.java:140)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogLexer.nextToken(CatalogLexer.java:73)
    at antlr.TokenBuffer.fill(TokenBuffer.java:69)
    at antlr.TokenBuffer.LA(TokenBuffer.java:80)
    at antlr.LLkParser.LA(LLkParser.java:52)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogParser.entries(CatalogParser.java:609)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogParser.messageBlock(CatalogParser.java:442)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogParser.messageBlocks(CatalogParser.java:220)
    at org.fedorahosted.tennera.jgettext.catalog.parse.CatalogParser.catalog(CatalogParser.java:157)

The parse will accept spaces but not tabs. Most po file utilities accept both i.e. the Tab (\t in the following) generates the error:

msgstr ""
\t
#

Sample File:

msgid ""
msgstr ""
"Project-Id-Version: RecordEditor 0.90\n"
"Last-Translator: bm\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Content-Transfer-Encoding: 8bit\n"

# Use: Message
#  id: SqlError   Panel:
#
# English:
#     SQL: {0}
# Message: {1}
#
msgid "SqlError"
msgstr ""

# Use: Message
#  id:    Panel:
#
msgid " --> Adding Record Layout: {0}"
msgstr "  - >添加记录布局:{0}"

# Use: Message
#  id:    Panel:
#
msgid " --> Deleting Record Layout: {0}"
msgstr "  - >删除记录的布局:{0}"

# Use: Column_Heading
#  id:    Panel:
# Tbl- PropsEd_JDBC 4
msgid " User"
msgstr " 用户"

# Use: Message
#  id: CopybookLoaded   Panel:
#
# English: -->> {0} processed
#
#       Copybook: {1}
msgid "CopybookLoaded"
msgstr ""
seanf commented 12 years ago

Fixed in commit 85db249bd0.