Commits

Simon Meers  committed 2b26430

Changed auto-detected module name from "gettext" to "dbgettext_registration", now configurable, to avoid namespace clashes.

  • Participants
  • Parent commits f5f6185

Comments (0)

Files changed (4)

File dbgettext/__init__.py

 from django.utils.importlib import import_module
 LOADING = False
 
+from django.conf import settings
+REGISTRATION_MODULE_NAME = getattr(
+    settings, 'DBGETTEXT_REGISTRATION_MODULE_NAME', 'dbgettext_registration')
+
 def autodiscover():
     """
-    Auto-discover INSTALLED_APPS gettext.py modules and fail silently when
-    not present. This forces an import on them to register any dbggettext bits 
-    they may want.
+    Auto-discover INSTALLED_APPS dbgettext_registration.py modules and fail 
+    silently when not present. This forces an import on them to register any 
+    dbggettext bits they may want.
     """
     global LOADING
     if LOADING:
     LOADING = True
 
     import imp
-    from django.conf import settings
     for app in settings.INSTALLED_APPS:
         try:
             app_path = import_module(app).__path__
             continue
 
         try:
-            imp.find_module('gettext', app_path)
+            imp.find_module(REGISTRATION_MODULE_NAME, app_path)
         except ImportError:
             continue
 
-        import_module("%s.gettext" % app)
+        import_module("%s.%s" % (app, REGISTRATION_MODULE_NAME))
     
     # import project-level options
     if hasattr(settings, 'DBGETTEXT_PROJECT_OPTIONS'):

File docs/parsing.rst

 
     This <b>string</b> is <i>translatable</i> by <u>default</u>.
 
-The ``custom_lexicon_rules`` :ref:`option <options>` allow the HTML parsing algorithm to be customised to suit your needs. For example, the following ``gettext.py`` file allows images to appear as moveable placeholders in translatable strings::
+The ``custom_lexicon_rules`` :ref:`option <options>` allow the HTML parsing algorithm to be customised to suit your needs. For example, the following ``dbgettext_registration.py`` file allows images to appear as moveable placeholders in translatable strings::
 
     from dbgettext.registry import registry, Options
     from dbgettext.parser import Token

File docs/registration.rst

 
 Models can be registered for django-dbgettext in a similar fashion to registering `ModelAdmin classes <http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-objects>`_ for ``django.contrib.admin``
 
-Simply create a ``gettext.py`` file within your application root directory, import the dbgettext ``registry`` object, and register your Models together with their customised ``dbgettext.models.Options``. For example::
+Simply create a ``dbgettext_registration.py`` file within your application root directory, import the dbgettext ``registry`` object, and register your Models together with their customised ``dbgettext.models.Options``. For example::
 
     from dbgettext.registry import registry, Options
     from dbgettext.lexicons import html    
 	
     registry.register(MyModel, MyModelOptions)
 
-That's it. Your ``gettext.py`` files will be automatically imported by django-dbgettext, and registered models will be included when running :doc:`dbgettext_export <dbgettext_export>`.
+That's it. Your ``dbgettext_registration.py`` files will be automatically imported by django-dbgettext, and registered models will be included when running :doc:`dbgettext_export <dbgettext_export>`.
+
+You can customise the module name using the ``DBGETTEXT_REGISTRATION_MODULE_NAME`` :ref:`setting <settings>`.
 
 .. _project-level:
 

File docs/settings.rst

 
 * ``DBGETTEXT_PATH``: path (absolute or relative to project root) where :doc:`dbgettext_export <dbgettext_export>` should store its output. Defaults to ``locale``.
 * ``DBGETTEXT_ROOT``: name of directory within ``DBGETTEXT_PATH`` (redundancy to provide protection from auto-purging upon export). Defaults to ``dbgettext``.
+* ``DBGETTEXT_REGISTRATION_MODULE_NAME``: name of modules within apps for registration. Defaults to ``dbgettext_registration``
 * ``DBGETTEXT_PROJECT_OPTIONS``: dotted path to python module containing project-level registration code (e.g. ``my_project.dbgettext_options`` if you have a ``dbgettext_options.py`` file in your ``my_project`` directory).
 * ``DBGETTEXT_INLINE_HTML_TAGS``: tuple of tag names allowed to appear inline within strings parsed with ``dbgettext.lexicons.html``. Defaults to ``('b','i','u','em','strong',)``.
 * ``DBGETTEXT_SPLIT_SENTENCES``: split chunks of text into separate sentences for translation where appropriate. Defaults to ``True``.