I try to build some navbar in my html with my json_file like it:
exemple of my json_file:
{
"_comment":"example auto build navbar",
"TOP" :[
{
"name" : "name1",
"id" : "MLO",
"title" : "Title than i want translate"
}]
}
in my view.py:
def view(request):
'''
'''
with open('IHMWEB/json_file.json') as data_file:
data = json.load(data_file)
c = {'user_username': request.session['user_username'],
"data" : data}
context = Context(c)
template = get_template('view.html')
translation.activate(settings.LANGUAGE_CODE)
html = template.render(context)
return HttpResponse(html)
and in my template:
{% for menu in data.TOP %}
<a href="#" id={{menu.id}} title="{{menu.title}}" class="navbar-brand"> {{menu.name}}</a>
{% endfor %}
How can i translate "title" with gettext and send translation to my template.html? Is it possible?