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')
in the folder where the test2.py-script lives I've created a
folder-structure like
../locales/NO/LC_MESSAGES/messages.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@ADDRESS>, 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@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: test2.py:5
msgid "writing a log to file"
msgstr "skriver logg til fil"
and then run python msgfmt.py messages.po and moving it to
../locales/NO/LC_MESSAGES/messages.mo
When I run
python test2.py
it gives me this error :
Traceback (most recent call last):
File "C:\Program
Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" ,
line 307, in RunScript
debugger.run(codeObject, __main__.__dict__, start_stepping=0)
File "C:\Program
Files\Python24\Lib\site-packages\pythonwin\pywin\debugger\__init__.py",
line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
File "C:\Program
Files\Python24\Lib\site-packages\pythonwin\pywin\debugger\debugger.py",
line 631, in run
exec cmd in globals, locals
File "C:\Program Files\Python24\Tools\i18n\test2.py", line 4, in ?
lang1 = gettext.translation('test2', languages=['no'])
File "C:\Program Files\Python24\lib\gettext.py", line 456, in
translation
raise IOError(ENOENT, 'No translation file found for domain',
domain)
IOError: [Errno 2] No translation file found for domain: 'test2'
Hmmm ... any hints?
Thomas 2 3496
In article <11**********************@g14g2000cwa.googlegroups .com>,
"Thomas W" <th***********@gmail.com> 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@ADDRESS>, 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@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\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.:' *firstname*nlsnews@georgea*lastname*.com
' <http://www.georgeanelson.com/>
Thomas W wrote: Hmmm ... any hints?
I think gettext needs environment variables (e.g. LANG)
to be set.
Regards,
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: StasZ |
last post by:
Hello,
I have some programs which are developed on Linux and uses gettext for
the language support.
While they run without problem on a win32 platform i haven't a clue how
to get the gettext...
|
by: Terry Hancock |
last post by:
I'm looking at the gettext module for the first time and
learning how to write internationalized code in Python.
Naturally, I also looked at the original Gnu gettext
manual, which mentions that...
|
by: cantabile |
last post by:
Hi,
I'm failing to make it work but can't find out what's wrong. Here's what
I do :
================
test.py
import gettext
gettext.install('')
|
by: 3rdshiftcoder |
last post by:
hi-
i am having trouble using parameter values in my function and to be honest a
little trouble with
member variables. i am trying to pass in the argument 'd' representing
delete.
what the...
|
by: russ.phillips.nospam |
last post by:
Hi,
I'm trying to use gettext to internationalise my project , but I'm
getting the following error message with some translations:
"Traceback (most recent call last):
file PanicButton.py line...
|
by: desktop |
last post by:
I have read in Bjarne Stroustrup that using malloc and free should be
avoided in C++ because they deal with uninitialized memory and one
should instead use new and delete.
But why is that a...
|
by: Darko |
last post by:
Hi,
I have problems implementing i18n on my site hosted on a FreeBSD
server. While it was hosted on a Linux server, there were no problems,
but once I transferred it to FreeBSD, gettext()...
|
by: paolob |
last post by:
Hi to all,
I'm running php 5.2.5 on Debian etch, with apache 2.0.56.
I need to include, in php.ini, gettext.so library but I didn't find
anything.
I've already install:
apt-get install gettext...
|
by: Vicent Giner |
last post by:
Hello.
I am new to Python. It seems a very interesting language to me. Its
simplicity is very attractive.
However, it is usually said that Python is not a compiled but
interpreted programming...
|
by: Spaeleus |
last post by:
Hi!
I'm really new to python.
I've a question that involves the use of gettext in python for internationalization.
I'm followin the italian translation for enigma2 CVS, the distribuition for some...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |