django - Empty catalog when internationalizing JavaScript code -
I'm trying to set up.
 In my Django app there is a subdirectory with a  locale  a properly generated  djangojs.po  file. The package definition is as follows: 
  # urls.py js_info_dict = {'package': ('my_project',),}     ./manage.pyMakmessus  works well because the  .po  file contains all-translated strings, but no javascript string is ever translated on the website. And the catalog is always empty. 
I had some problems with it too. How it works for me:
Add it to the URR root urls.py:
  js_info_dict = {'domain': 'djangojs', 'packages': ( 'YOUR_PROJECT_NAME',),} urlpatterns = Pattern ('', # JavaScript is enabled using the translation string in #source: https://docs.djangoproject.com/en/dev/topics/i18n/translation/#module- Django.views .i18n (r '^ jsi18n / $', 'django.views.i18n.javascriptcomatalog', js_info_dict),)   Use in JS files:
  var somevar = gettext ('text to translate');   To compile Django translation files: From a project root in a shell / terminal run (where 'app', 'settings', etc.):
  for # "General Django Files" (.p.ohtml): Digeno - AdminPop Mammays - Local = D # Source for Javascript Files: http://stackoverflow.com/a/3571954/268125 django- Admin.py makemessages -a -d djangojs --locale = de # # compile translation files into machine code django-admin.py compilemessages --locale = D   
Comments
Post a Comment