getting locale working correctly: best practices?

9 views
Skip to first unread message

sandro dentella

unread,
Jun 20, 2009, 5:27:01 AM6/20/09
to PyInstaller
Hi,

using the --onedir option I managed to get to the point that the
application starts, recognizes the locale setting of the os it is
running
on, uses locale .po of my application to translate messages, but
when I
use babel to format numbers, it complains that it does not know the
locale
it_IT.

My understanding is that that locale *is* installed on the machine,
but is
not visible to the application.

Of course I don't mean to add locale for any possible language in my
application, I'd rather use the locale already installed on the os
but
that -in a way- is the opposite of the logic of pyinstaller that
should
provide a complete environ...

How should I do?

Which are the best practices for localization?

thanks again
sandro

Giovanni Bajo

unread,
Jun 20, 2009, 12:34:10 PM6/20/09
to PyIns...@googlegroups.com
On sab, 2009-06-20 at 02:27 -0700, sandro dentella wrote:
> Hi,
>
> using the --onedir option I managed to get to the point that the
> application starts, recognizes the locale setting of the os it is
> running
> on, uses locale .po of my application to translate messages, but
> when I
> use babel to format numbers, it complains that it does not know the
> locale
> it_IT.

I'm not sure I understand the problem. Can you provide me with a
reproduction recipe?
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


Alessandro Dentella

unread,
Jun 20, 2009, 1:48:44 PM6/20/09
to PyIns...@googlegroups.com
On Sat, Jun 20, 2009 at 06:34:10PM +0200, Giovanni Bajo wrote:
>
> On sab, 2009-06-20 at 02:27 -0700, sandro dentella wrote:
> > Hi,
> >
> > using the --onedir option I managed to get to the point that the
> > application starts, recognizes the locale setting of the os it is
> > running
> > on, uses locale .po of my application to translate messages, but
> > when I
> > use babel to format numbers, it complains that it does not know the
> > locale
> > it_IT.
>
> I'm not sure I understand the problem. Can you provide me with a
> reproduction recipe?

Here a 2 line example:

sandro@bluff:/misc/src/svn/pyinstaller-hg$ cat babex/ex1.py

from babel import numbers
print numbers.format_decimal(123.4)

babel needs to access the locale system to know how to format numbers
It finds it on my machine:

sandro@bluff:/misc/src/svn/pyinstaller-hg$ python babex/ex1.py
123,4

But not on the generated one:

sandro@bluff:/misc/src/svn/pyinstaller-hg$ Makespec.py -o babex babex/ex1.py
wrote babex/ex1.spec
now run Build.py to build the executable
sandro@bluff:/misc/src/svn/pyinstaller-hg$ Build.py babex/ex1.spec
checking Analysis
building Analysis because outAnalysis0.toc non existent
running Analysis outAnalysis0.toc
Analyzing: ./support/_mountzlib.py
Analyzing: ./support/useUnicode.py
Analyzing: babex/ex1.py
Warnings written to babex/warnex1.txt
checking PYZ
rebuilding outPYZ1.toc because outPYZ1.pyz is missing
building PYZ outPYZ1.toc
checking PKG
rebuilding outPKG3.toc because outPKG3.pkg is missing
building PKG outPKG3.pkg
checking EXE
rebuilding outEXE2.toc because ex1 missing
building EXE from outEXE2.toc
Appending archive to EXE babex/build/pyi.linux2/ex1/ex1
checking COLLECT
building because outCOLLECT4.toc missing or bad
building COLLECT outCOLLECT4.toc
sandro@bluff:/misc/src/svn/pyinstaller-hg$ babex/dist/ex1/ex1
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "babex/build/pyi.linux2/ex1/outPYZ1.pyz/babel.numbers", line 156, in format_decimal
File "babex/build/pyi.linux2/ex1/outPYZ1.pyz/babel.core", line 210, in parse
File "babex/build/pyi.linux2/ex1/outPYZ1.pyz/babel.core", line 136, in __init__
babel.core.UnknownLocaleError: unknown locale 'it_IT'


sandro
*:-)


--
Sandro Dentella *:-)
http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy

Reply all
Reply to author
Forward
0 new messages