Opened 10 years ago
Last modified 9 years ago
#25751 closed Cleanup/optimization
Translation of strings in a javascript file: Docs are incorrect — at Version 2
| Reported by: | George Tantiras | Owned by: | nobody | 
|---|---|---|---|
| Component: | Documentation | Version: | 1.8 | 
| Severity: | Normal | Keywords: | javascript translation | 
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | yes | 
| Easy pickings: | no | UI/UX: | no | 
Description (last modified by )
To translate a string in a javascript file, the docs propose the following setup in the urls.py:
from django.views.i18n import javascript_catalog
js_info_dict = {
    'packages': ('your.app.package',),
}
urlpatterns = [
    url(r'^jsi18n/$', javascript_catalog, js_info_dict),
]
This will not work unless the javascript url is added to urlpatterns under i18n_patterns:
from django.views.i18n import javascript_catalog
from django.conf.urls.i18n import i18n_patterns
js_info_dict = {
    'packages': ('application.name',),
}
urlpatterns = [
    ...
]
urlpatterns += i18n_patterns(
    url(r'^jsi18n/$', javascript_catalog, js_info_dict),
)
      Change History (2)
comment:1 by , 10 years ago
| Summary: | Translation of strings in a javascript file docs are incorrect → Translation of strings in a javascript file: Docs are incorrect | 
|---|
comment:2 by , 10 years ago
| Description: | modified (diff) | 
|---|
  Note:
 See   TracTickets
 for help on using tickets.