As mention in documentation, i have followed below steps -
In my settings.py
LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), ) LANGUAGE_CODE = 'en-us' USE_I18N = True USE_L10N = True ugettext = lambda s: s LANGUAGES = ( ('en', ugettext('English')), ('mar', ugettext('Marathi')), )
My locale directory is in my Django project's root folder
In urls.py
from django.views.i18n import javascript_catalog js_info_dict = { 'packages': ('phone',), } urlpatterns = [ url(r'^phone/', include('phone.urls')), url(r'^jsi18n/$', javascript_catalog, js_info_dict), ]
In base.html
<script type="text/javascript" src="/jsi18n/"></script>
I am able to see translation done by trans tag, but when m trying to translate variables in javascript using gettext method m getting this particular error
ReferenceError: gettext is not defined
FYI - djangojs.po and djangojs.mo files are there in my locale directory and i have compiled the file after putting translations on.
I tried hard on google but still same error.