"""
Smart slugify
"""
import django.template.defaultfilters

use_unidecode = True
try:
    from unidecode import unidecode
except ImportError:
    use_unidecode = False
    
def slugify(string):
    if use_unidecode:
        string = unidecode(string)
    return django.template.defaultfilters.slugify(string)


"""
Lazy translate that allows us to access original message
"""
from django.utils import translation

def ugettext_lazy(str):
    t = translation.ugettext_lazy(str)
    t.message = str
    return t
def get_msgid(gettext):
    try:
        return gettext.message
    except AttributeError:
        return None


"""
Date formats
"""               
from django.utils.formats import get_format

formats = {
    'DATE_FORMAT': '',
    'DATETIME_FORMAT': '',
    'TIME_FORMAT': '',
    'YEAR_MONTH_FORMAT': '',
    'MONTH_DAY_FORMAT': '',
    'SHORT_DATE_FORMAT': '',
    'SHORT_DATETIME_FORMAT': '',
}

for key in formats:
    formats[key] = get_format(key).replace('P', 'g:i a')