javascript - How to pass locale using FOSJsRoutingBundle -


i installed fosjsrouting route need _locale parameter. how can in js ? there way locale in js ?

in twig, can app.request.attributes.get('_locale') in js, don't find documentation.

ajax

$.ajax({     type : 'get',     url : routing.generate('get_credits', {'_locale': app.request.attributes.get('_locale'), 'amount' : amount, 'monthnumber' : month }),     beforesend : function(){     console.log('loading');     },     success: function(data){     },     error : function(){     } }); 

what set locale html-tag attribute

<html lang="{{ app.request.locale }}">  

which results in

<html lang="en"> 

this useful seo, , can locale in js calling

$('html').attr('lang'); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -