Reputation: 281
I need current locale. I get locale code and send it to javascript. This code throw error:
<script type="text/javascript">
var loc = [[${#locale}]];
Uncaught ReferenceError: ru_RU is not defined.
What is the problem? This one not throw error:
<div th:text="${#locale}"></div>
Upvotes: 1
Views: 959
Reputation: 1351
Either add quotes so you have
var loc = "[[${#locale}]]";
or change type="text/javascript"
to th:inline="javascript"
This is because [[${#locale}]]
translated to ru_RU
without quotes is considered as variable, not string, this is why you get ReferenceError
Upvotes: 1