/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/__init__.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Thuban/UI/__init__.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1871 - (hide annotations)
Mon Oct 27 17:11:06 2003 UTC (21 years, 4 months ago) by bh
Original Path: trunk/thuban/Thuban/UI/__init__.py
File MIME type: text/x-python
File size: 1281 byte(s)
Rework how localization works so that we use wx's translation
functions when running Thuban as a normal application but not when
we don't need any UI, such as in the test suite. See the comment
in Thuban/__init__.py for details

* Thuban/__init__.py (_): Add one level of indirection to make the
translation handling more flexible and to make it possible to use
either wx's translation services or not.
(gettext_identity, translation_function_installed)
(install_translation_function): New function to help with this

* Thuban/UI/__init__.py: Install the wx specific translation
function if it's OK to do that

1 bh 918 # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2 bh 6 # Authors:
3     # Bernhard Herzog <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with Thuban for details.
7 bh 230
8 bh 1871
9     _locale = None
10     def install_wx_translation():
11     """Install the wx translation function in Thuban.
12    
13     For more information about translations in Thuban see the comment in
14     Thuban/__init__.py
15     """
16     global _locale
17     import Thuban
18     if not Thuban.translation_function_installed():
19     # Only import wx modules when we actually can install the
20     # function so that the test suite can inhibit this
21     import wxPython.wx as wx
22     wx.wxLocale_AddCatalogLookupPathPrefix(Thuban._message_dir)
23     _locale = wx.wxLocale()
24     _locale.AddCatalog("thuban")
25     Thuban.install_translation_function(wx.wxGetTranslation)
26    
27     # Reset the python locale. This makes sure that the LC_NUMERIC
28     # seen by the python interpreter and by C modules is "C" instead
29     # of the user's locale. Python code will still see the user's
30     # locale where it matters. Without this, drawing the map doesn't
31     # work for some reason
32     import locale
33     locale.setlocale(locale.LC_NUMERIC, "")
34    
35     install_wx_translation()

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26