Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thymeleaf get current locale

How can I get current locale in thymeleaf template? Thymeleaf context is locale aware, so it would be weird to inject locale on every request, is there some variable I can request in a template?

<div th:text="${currentLocale}"></div>
like image 677
Ben Avatar asked Nov 27 '16 21:11

Ben


1 Answers

Use the #locale expression:

<div th:text="${#locale}"></div>
like image 112
Tom Avatar answered Oct 30 '22 17:10

Tom