Benedictus Benedictus - 1 year ago 112
Java Question

Thmeleaf 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>

Tom Tom
Answer Source

Use the #locale expression:

<div th:text="${#locale}"></div>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download