In article <[EMAIL PROTECTED]>, "Thomas W" <[EMAIL PROTECTED]> wrote:
> I'm trying to wrap my head around the docs at python.org related to the > gettext-module, but I'm having some problem getting it to work. Is > there any really simple, step-by-step on how to use this module > available? > > This is my script so far : > > import gettext > gettext.install('test2', '.', unicode=1) > lang1 = gettext.translation('test2', languages=['no']) > print _('writing a log to file') I do: # assume the script is named "myscript.py": us = os.path.splitext(os.path.basename(sys.argv[0]))[0] usdir = os.path.dirname(sys.argv[0]) import gettext gettext.install(us, usdir) > in the folder where the test2.py-script lives I've created a > folder-structure like > > ./locales/NO/LC_MESSAGES/messages.mo Mine looks like: ./en_PL/LC_MESSAGES/myscript.mo > the messages.mo-file I've created using the scripts in the > \Tools\i18l\-folder by running : > > python pygettext.py test2.py > > and renaming the generated messages.pot-file to messages.po, and > editing it to look like : > > # SOME DESCRIPTIVE TITLE. > # Copyright (C) YEAR ORGANIZATION > # FIRST AUTHOR <[EMAIL PROTECTED]>, YEAR. > # > msgid "" > msgstr "" > "Project-Id-Version: PACKAGE VERSION\n" > "POT-Creation-Date: 2005-11-22 13:02+W. Europe Standard Time\n" > "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" > "Last-Translator: FULL NAME <[EMAIL PROTECTED]>\n" > "Language-Team: LANGUAGE <[EMAIL PROTECTED]>\n" > "MIME-Version: 1.0\n" > "Content-Type: text/plain; charset=CHARSET\n" > "Content-Transfer-Encoding: ENCODING\n" > "Generated-By: pygettext.py 1.5\n" ... You need to set the "Content-Type: charset" and "Content-Transfer-Encoding:". I use: "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" ________________________________________________________________________ TonyN.:' [EMAIL PROTECTED] ' <http://www.georgeanelson.com/> -- http://mail.python.org/mailman/listinfo/python-list