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
Post a Comment