init subcommand fails: LookupError: unknown encoding: charset

12 views
Skip to first unread message

Fabio Quintilii

unread,
Feb 19, 2017, 4:24:08 AM2/19/17
to Python Babel
Hallo,

I'm testing pybabel on Pythonanywhere and when I run the init subcommand it fails with "LookupError: unknown encoding: charset" exception.

I use python2.7 version, but pybabel runs under python3.5.

The issue was reported in the topic https://groups.google.com/forum/#!topic/python-babel/lT-005ICU1M, but It was not clear for me.

Can someone give me any suggestion?

Regards, Fabio


OUTPOT OF EXTRACT AND INIT SUBCOMMANDS
---------------------------------------------------------------------------------

pybabel extract . --charset='UTF-8'

extracting messages from __init__.py
extracting messages from app.py
extracting messages from config.py
extracting messages from models.py
extracting messages from views.py
# Translations template for PROJECT.
# Copyright (C) 2017 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2017-02-17 18:25+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <L...@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.2.0\n"
#: views.py:708
msgid "Home Page"
msgstr ""
#: views.py:709
msgid "Tables"
msgstr ""
#: views.py:710
msgid "Dashboard"
msgstr ""



--------------------------------------------------------------------------------

pybabel init -i messages.po -d translations -l it


creating catalog 'translations/it/LC_MESSAGES/messages.po' based on 'messages.po'
Traceback (most recent call last):
  File "/usr/local/bin/pybabel", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/babel/messages/frontend.py", line 1151, in main
    return CommandLineInterface().run(sys.argv)
  File "/usr/local/lib/python3.5/dist-packages/babel/messages/frontend.py", line 665, in run
    return getattr(self, cmdname)(args[1:])
  File "/usr/local/lib/python3.5/dist-packages/babel/messages/frontend.py", line 1022, in init
    write_po(outfile, catalog, width=options.width)
  File "/usr/local/lib/python3.5/dist-packages/babel/messages/pofile.py", line 447, in write_po
    _write(comment_header + u'\n')
  File "/usr/local/lib/python3.5/dist-packages/babel/messages/pofile.py", line 390, in _write
    text = text.encode(catalog.charset, 'backslashreplace')
LookupError: unknown encoding: charset

Fabio Quintilii

unread,
Feb 19, 2017, 6:54:19 AM2/19/17
to Python Babel
I'm sorry, I poster twice by mistake, is it possibile to delete this one?

Thanks, Fabio

Reply all
Reply to author
Forward
0 new messages