Initial i18n commit for endpoints. All endpoints must install

gettext, which injects the _ function into the builtins.
This commit is contained in:
jaypipes@gmail.com 2010-12-11 15:10:24 -05:00
parent 1a759c3722
commit a6645d8a43
5 changed files with 17 additions and 0 deletions

View File

@ -21,6 +21,7 @@
Nova API daemon. Nova API daemon.
""" """
import gettext
import os import os
import sys import sys
@ -32,6 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir) sys.path.insert(0, possible_topdir)
gettext.install('nova', unicode=1)
from nova import flags from nova import flags
from nova import utils from nova import utils
from nova import server from nova import server

View File

@ -21,6 +21,7 @@
Twistd daemon for the nova compute nodes. Twistd daemon for the nova compute nodes.
""" """
import gettext
import os import os
import sys import sys
@ -32,6 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir) sys.path.insert(0, possible_topdir)
gettext.install('nova', unicode=1)
from nova import service from nova import service
from nova import twistd from nova import twistd
from nova import utils from nova import utils

View File

@ -21,6 +21,7 @@
Handle lease database updates from DHCP servers. Handle lease database updates from DHCP servers.
""" """
import gettext
import logging import logging
import os import os
import sys import sys
@ -33,6 +34,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir) sys.path.insert(0, possible_topdir)
gettext.install('nova', unicode=1)
from nova import context from nova import context
from nova import db from nova import db
from nova import flags from nova import flags

View File

@ -29,3 +29,8 @@
.. moduleauthor:: Manish Singh <yosh@gimp.org> .. moduleauthor:: Manish Singh <yosh@gimp.org>
.. moduleauthor:: Andy Smith <andy@anarkystic.com> .. moduleauthor:: Andy Smith <andy@anarkystic.com>
""" """
# See http://code.google.com/p/python-nose/issues/detail?id=373
# The code below enables nosetests to work with i18n _() blocks
import __builtin__
setattr(__builtin__, '_', lambda x: x)

View File

@ -40,9 +40,12 @@ Due to our use of multiprocessing it we frequently get some ignorable
""" """
import __main__ import __main__
import gettext
import os import os
import sys import sys
gettext.install('nova', unicode=1)
from twisted.scripts import trial as trial_script from twisted.scripts import trial as trial_script
from nova import flags from nova import flags