I am working on a Project where I am using React js for Front-End and Django for backend. I need to implement i18n Internationalization and Localization I saw Django documentation and came across django I18n javascript_catalog. How to use the same using getText() in React JS?. Is there any other way to implement?.
Thanks in Advance
Update for: django > 2.0:
from django.views.i18n import JavaScriptCatalog
urlpatterns = [
path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
]
Reference
Old:
Use below code in urls.py
of project
from django.views.i18n import javascript_catalog
js_info_dict = {
'domain': 'djangojs',
'packages': ('name',)
}
urlpatterns += i18n_patterns(
url(r'^jsi18n/$', javascript_catalog, js_info_dict),
Add below line to your base html file
<script type="text/javascript" src="/jsi18n/"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With