Index: turbogears/i18n/tg_gettext.py
===================================================================
--- turbogears/i18n/tg_gettext.py	(Revision 3028)
+++ turbogears/i18n/tg_gettext.py	(Arbeitskopie)
@@ -2,37 +2,42 @@
 import turbogears
 from turbogears.i18n.utils import get_locale
 from turbojson.jsonify import jsonify
-from turbogears.util import request_available
+from turbogears.util import get_package_name, request_available
 import os
+import sys
 import types
 
 _catalogs = {}
 
+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")
+    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 = turbogears.config.get("i18n.locale_dir", "locales")
+    localedir = get_locale_dir()
+    return os.path.exists(os.path.join(localedir, locale, "LC_MESSAGES", "%s.mo" % domain))
 
-    return os.path.exists(os.path.join(localedir, locale, "LC_MESSAGES", "%s.mo" %domain))
-
 def get_catalog(locale, domain = None):
-    """Return translations for given locale. 
+    """Return translations for given locale.
     """
-    if domain is None:domain = turbogears.config.get("i18n.domain", "messages")
+    if not domain: domain = turbogears.config.get("i18n.domain", "messages")
 
     catalog = _catalogs.get(domain)
 
     if not catalog:
-
         catalog = _catalogs[domain] = {}
 
     messages = catalog.get(locale)
     if not messages:
-
-        localedir = turbogears.config.get("i18n.locale_dir", "locales")
-        messages = catalog[locale] = translation(domain=domain, 
+        localedir = get_locale_dir()
+        messages = catalog[locale] = translation(domain=domain,
             localedir=localedir, languages=[locale])
 
     return messages
@@ -40,7 +45,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)
@@ -49,7 +54,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()
@@ -74,11 +79,11 @@
 
     if num==1:
 
-        return plain_gettext(key1, locale) 
+        return plain_gettext(key1, locale)
 
     else:
 
-        return plain_gettext(key2, locale) 
+        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.
Index: turbogears/qstemplates/quickstart/setup.py_tmpl
===================================================================
--- turbogears/qstemplates/quickstart/setup.py_tmpl	(Revision 3028)
+++ turbogears/qstemplates/quickstart/setup.py_tmpl	(Arbeitskopie)
@@ -4,10 +4,18 @@
 import os
 execfile(os.path.join("${package}", "release.py"))
 
+packages=find_packages()
+package_data = find_package_data(where='${package}',
+    package='${package}')
+if os.path.isdir('locales'):
+    packages.append('locales')
+    package_data.update(find_package_data(where='locales',
+        exclude=('*.po',), only_in_packages=False))
+
 setup(
     name="${project}",
     version=version,
-    
+
     # uncomment the following lines if you fill them out in release.py
     #description=description,
     #author=author,
@@ -15,38 +23,37 @@
     #url=url,
     #download_url=download_url,
     #license=license,
-    
-    install_requires = [
+
+    install_requires=[
         "TurboGears >= ${turbogearsversion}",
-#if $identity == "sqlalchemy" 
-        "SQLAlchemy", 
-#end if 
+#if $identity == "sqlalchemy"
+        "SQLAlchemy",
+#end if
     ],
-    scripts = ["start-${package}.py"],
+    scripts=["start-${package}.py"],
     zip_safe=False,
-    packages=find_packages(),
-    package_data = find_package_data(where='${package}',
-                                     package='${package}'),
-    keywords = [
+    packages=packages,
+    package_data=package_data,
+    keywords=[
         # Use keywords if you'll be adding your package to the
         # Python Cheeseshop
-        
+
         # if this has widgets, uncomment the next line
         # 'turbogears.widgets',
-        
+
         # if this has a tg-admin command, uncomment the next line
         # 'turbogears.command',
-        
+
         # if this has identity providers, uncomment the next line
         # 'turbogears.identity.provider',
-    
+
         # If this is a template plugin, uncomment the next line
         # 'python.templating.engines',
-        
+
         # If this is a full application, uncomment the next line
         # 'turbogears.app',
     ],
-    classifiers = [
+    classifiers=[
         'Development Status :: 3 - Alpha',
         'Operating System :: OS Independent',
         'Programming Language :: Python',
@@ -55,11 +62,11 @@
         # if this is an application that you'll distribute through
         # the Cheeseshop, uncomment the next line
         # 'Framework :: TurboGears :: Applications',
-        
+
         # if this is a package that includes widgets that you'll distribute
         # through the Cheeseshop, uncomment the next line
         # 'Framework :: TurboGears :: Widgets',
     ],
-    test_suite = 'nose.collector',
+    test_suite='nose.collector',
     )
-    
+
Index: turbogears/qstemplates/quickstart/start-+package+.py_tmpl
===================================================================
--- turbogears/qstemplates/quickstart/start-+package+.py_tmpl	(Revision 3028)
+++ turbogears/qstemplates/quickstart/start-+package+.py_tmpl	(Arbeitskopie)
@@ -2,7 +2,7 @@
 import pkg_resources
 pkg_resources.require("TurboGears")
 
-from turbogears import update_config, start_server
+from turbogears import config, update_config, start_server
 import cherrypy
 cherrypy.lowercase_api = True
 from os.path import *
@@ -13,12 +13,13 @@
 # look for setup.py in this directory. If it's not there, this script is
 # probably installed
 if len(sys.argv) > 1:
-    update_config(configfile=sys.argv[1], 
+    update_config(configfile=sys.argv[1],
         modulename="${package}.config")
 elif exists(join(dirname(__file__), "setup.py")):
     update_config(configfile="dev.cfg",modulename="${package}.config")
 else:
     update_config(configfile="prod.cfg",modulename="${package}.config")
+config.update(dict(package="${package}"))
 
 from ${package}.controllers import Root
 
Index: turbogears/util.py
===================================================================
--- turbogears/util.py	(Revision 3028)
+++ turbogears/util.py	(Arbeitskopie)
@@ -98,14 +98,20 @@
 
 def get_package_name():
     """Try to find out the package name of the current directory."""
+    package = config.get("package")
+    if package:
+        return package
     if "--egg" in sys.argv:
         projectname = sys.argv[sys.argv.index("--egg")+1]
         egg = pkg_resources.get_distribution(projectname)
-        package = list(egg._get_metadata("top_level.txt"))[0]
-        return package
-    fname = get_project_meta('top_level.txt')
-    if fname:
-        return open(fname).readline()[:-1]
+        top_level = egg._get_metadata("top_level.txt")
+    else:
+        fname = get_project_meta('top_level.txt')
+        top_level = fname and open(fname) or []
+    for package in top_level:
+        package = package.rstrip()
+        if package and package != 'locales':
+            return package
 
 def get_project_name():
     pkg_info = get_project_meta('PKG-INFO')
@@ -426,6 +432,6 @@
            "arg_index", "inject_arg", "inject_args", "bind_args",
            "recursive_update", "combine_contexts", "request_available",
            "flatten_sequence", "load_class", "Bunch",
-           "parse_http_accept_header", 
+           "parse_http_accept_header",
            "to_unicode", "to_utf8", "get_template_encoding_default",
            "find_precision", "copy_if_mutable"]

