Index: turbogears/i18n/tg_gettext.py
===================================================================
--- turbogears/i18n/tg_gettext.py	(Revision 3076)
+++ turbogears/i18n/tg_gettext.py	(Arbeitskopie)
@@ -12,14 +12,17 @@
 def get_locale_dir():
     localedir = turbogears.config.get("i18n.locale_dir")
     if not localedir:
-        localedir = os.path.join(os.path.dirname(
-            sys.modules[get_package_name()].__path__[0]), "locales")
+        package = get_package_name()
+        if package:
+            localedir = os.path.join(os.path.dirname(
+                sys.modules[package].__path__[0]), "locales")
     return localedir
 
 def is_locale_supported(locale, domain=None):
     """Checks if [domain].mo file exists for this language
     """
-    if not domain: domain = turbogears.config.get("i18n.domain", "messages")
+    if not domain:
+        domain = turbogears.config.get("i18n.domain", "messages")
 
     localedir = get_locale_dir()
     return os.path.exists(os.path.join(localedir, locale, "LC_MESSAGES", "%s.mo" % domain))
@@ -27,7 +30,8 @@
 def get_catalog(locale, domain = None):
     """Return translations for given locale.
     """
-    if not domain: domain = turbogears.config.get("i18n.domain", "messages")
+    if not domain:
+        domain = turbogears.config.get("i18n.domain", "messages")
 
     catalog = _catalogs.get(domain)
 
@@ -45,7 +49,7 @@
 def plain_gettext(key, locale=None, domain=None):
     """Gets the gettext value for key.Added to builtins as '_'. Returns Unicode string.
     @param key: text to be translated
-    @param locale: locale code to be used. If locale is None, gets the value provided
+    @param locale: locale code to be used.If locale is None, gets the value provided
     by get_locale.
     """
     gettext_func = turbogears.config.get("i18n.gettext", tg_gettext)
@@ -54,7 +58,7 @@
 def tg_gettext(key, locale=None, domain=None):
     """Gets the gettext value for key.Added to builtins as '_'. Returns Unicode string.
     @param key: text to be translated
-    @param locale: locale code to be used. If locale is None, gets the value provided by
+    @param locale: locale code to be used.If locale is None, gets the value provided by
     get_locale.
     """
     if locale is None:locale = get_locale()
@@ -72,12 +76,9 @@
     """Translates two possible texts based on whether num is greater than 1
     @param key1: text if num==1
     @param key2: text if num!=1
-
     @param num: a number
     @type num: integer
-
-    @param locale: locale code to be used.If locale is None, gets the value
-    provided by get_locale.
+    @locale:locale code to be used.If locale is None, gets the value provided by get_locale.
     """
 
     if num==1:
@@ -89,8 +90,7 @@
         return plain_gettext(key2, locale)
 
 class lazystring(object):
-    """Has a number of lazily evaluated functions replicating a string.
-    Just override the eval() method to produce the actual value.
+    """Has a number of lazily evaluated functions replicating a string. Just override the eval() method to produce the actual value.
     """
 
     def __init__(self, func, *args, **kw):
@@ -138,12 +138,10 @@
 lazy_ngettext = lazify(plain_ngettext)
 
 def gettext(key, locale=None, domain=None):
-    """Gets the gettext value for key. Added to builtins as '_'.
-    Returns Unicode string.
+    """Gets the gettext value for key. Added to builtins as '_'. Returns Unicode string.
 
     @param key: text to be translated
-    @param locale: locale code to be used. If locale is None,
-    gets the value provided by get_locale.
+    @param locale: locale code to be used. If locale is None, gets the value provided by get_locale.
      """
 
     if request_available():
@@ -156,12 +154,9 @@
 
     @param key1: text if num==1
     @param key2: text if num!=1
-
     @param num: a number
     @type num: integer
-
-    @param locale: locale code to be used. If locale is None, gets the value
-    provided by get_locale.
+    @param locale: locale code to be used. If locale is None, gets the value provided by get_locale.
     """
     if request_available():
         return plain_ngettext(key1, key2, num, locale)

