|
@@ -46,21 +46,29 @@ def iter_format_modules(lang, format_module_path=None):
|
|
|
"""
|
|
|
Does the heavy lifting of finding format modules.
|
|
|
"""
|
|
|
- if check_for_language(lang):
|
|
|
- format_locations = ['django.conf.locale.%s']
|
|
|
- if format_module_path:
|
|
|
- format_locations.append(format_module_path + '.%s')
|
|
|
- format_locations.reverse()
|
|
|
- locale = to_locale(lang)
|
|
|
- locales = [locale]
|
|
|
- if '_' in locale:
|
|
|
- locales.append(locale.split('_')[0])
|
|
|
- for location in format_locations:
|
|
|
- for loc in locales:
|
|
|
- try:
|
|
|
- yield import_module('%s.formats' % (location % loc))
|
|
|
- except ImportError:
|
|
|
- pass
|
|
|
+ if not check_for_language(lang):
|
|
|
+ return
|
|
|
+
|
|
|
+ if format_module_path is None:
|
|
|
+ format_module_path = settings.FORMAT_MODULE_PATH
|
|
|
+
|
|
|
+ format_locations = []
|
|
|
+ if format_module_path:
|
|
|
+ if isinstance(format_module_path, six.string_types):
|
|
|
+ format_module_path = [format_module_path]
|
|
|
+ for path in format_module_path:
|
|
|
+ format_locations.append(path + '.%s')
|
|
|
+ format_locations.append('django.conf.locale.%s')
|
|
|
+ locale = to_locale(lang)
|
|
|
+ locales = [locale]
|
|
|
+ if '_' in locale:
|
|
|
+ locales.append(locale.split('_')[0])
|
|
|
+ for location in format_locations:
|
|
|
+ for loc in locales:
|
|
|
+ try:
|
|
|
+ yield import_module('%s.formats' % (location % loc))
|
|
|
+ except ImportError:
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
def get_format_modules(lang=None, reverse=False):
|