mirror of
https://github.com/Prominence/car-repair-site.git
synced 2026-01-09 19:56:43 +03:00
Implemented locale changing.
This commit is contained in:
parent
19196fbe05
commit
af110658b6
@ -3,12 +3,38 @@ package com.github.prominence.carrepair.conf;
|
|||||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.LocaleResolver;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||||
|
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ApplicationConfiguration {
|
public class ApplicationConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LayoutDialect layoutDialect() {
|
public LayoutDialect layoutDialect() {
|
||||||
return new LayoutDialect();
|
return new LayoutDialect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocaleResolver localeResolver() {
|
||||||
|
SessionLocaleResolver slr = new SessionLocaleResolver();
|
||||||
|
slr.setDefaultLocale(Locale.US);
|
||||||
|
return slr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocaleChangeInterceptor localeChangeInterceptor() {
|
||||||
|
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
|
||||||
|
lci.setParamName("lang");
|
||||||
|
return lci;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(localeChangeInterceptor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,15 @@ badge.mechanics = Mechanics
|
|||||||
badge.orders = Orders
|
badge.orders = Orders
|
||||||
|
|
||||||
home.requirements.label = Requirements
|
home.requirements.label = Requirements
|
||||||
|
home.title.label = Test project "Car Repair Service"
|
||||||
|
|
||||||
client.title = Clients
|
client.title = Clients
|
||||||
mechanic.title = Mechanics
|
mechanic.title = Mechanics
|
||||||
order.title = Orders
|
order.title = Orders
|
||||||
|
|
||||||
|
lang.en = English
|
||||||
|
lang.ru = Russian
|
||||||
|
|
||||||
firstName.label = First Name
|
firstName.label = First Name
|
||||||
middleName.label = Middle Name
|
middleName.label = Middle Name
|
||||||
lastName.label = Last Name
|
lastName.label = Last Name
|
||||||
|
|||||||
@ -5,11 +5,15 @@ badge.mechanics = Mechanics
|
|||||||
badge.orders = Orders
|
badge.orders = Orders
|
||||||
|
|
||||||
home.requirements.label = Requirements
|
home.requirements.label = Requirements
|
||||||
|
home.title.label = Test project "Car Repair Service"
|
||||||
|
|
||||||
client.title = Clients
|
client.title = Clients
|
||||||
mechanic.title = Mechanics
|
mechanic.title = Mechanics
|
||||||
order.title = Orders
|
order.title = Orders
|
||||||
|
|
||||||
|
lang.en = English
|
||||||
|
lang.ru = Russian
|
||||||
|
|
||||||
firstName.label = First Name
|
firstName.label = First Name
|
||||||
middleName.label = Middle Name
|
middleName.label = Middle Name
|
||||||
lastName.label = Last Name
|
lastName.label = Last Name
|
||||||
|
|||||||
@ -5,11 +5,15 @@ badge.mechanics = Механики
|
|||||||
badge.orders = Заказы
|
badge.orders = Заказы
|
||||||
|
|
||||||
home.requirements.label = Требования
|
home.requirements.label = Требования
|
||||||
|
home.title.label = Тестовый проект "Автомастерская"
|
||||||
|
|
||||||
client.title = Клиенты
|
client.title = Клиенты
|
||||||
mechanic.title = Механики
|
mechanic.title = Механики
|
||||||
order.title = Заказы
|
order.title = Заказы
|
||||||
|
|
||||||
|
lang.en = Английский
|
||||||
|
lang.ru = Русский
|
||||||
|
|
||||||
firstName.label = Имя
|
firstName.label = Имя
|
||||||
middleName.label = Отчество
|
middleName.label = Отчество
|
||||||
lastName.label = Фамилия
|
lastName.label = Фамилия
|
||||||
|
|||||||
BIN
src/main/resources/static/images/ru.png
Executable file
BIN
src/main/resources/static/images/ru.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 420 B |
BIN
src/main/resources/static/images/us.png
Executable file
BIN
src/main/resources/static/images/us.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 609 B |
@ -6,13 +6,13 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div layout:fragment="header">
|
<div layout:fragment="header">
|
||||||
<h1>Car Repair test project</h1>
|
<h1 th:text="#{home.title.label}"></h1>
|
||||||
</div>
|
</div>
|
||||||
<div layout:fragment="content">
|
<div layout:fragment="content">
|
||||||
<h2>
|
<h2>
|
||||||
<span><th:block th:text="#{home.requirements.label}"/>:</span>
|
<span><th:block th:text="#{home.requirements.label}"/>:</span>
|
||||||
</h2>
|
</h2>
|
||||||
<img src="images/task.png" alt="Requirements"/>
|
<img src="/images/task.png" th:alt="#{home.requirements.label}"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -35,6 +35,14 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="float-right">
|
||||||
|
<a th:href="@{?lang=en}">
|
||||||
|
<img th:src="@{/images/us.png}" th:alt="#{lang.en}"/>
|
||||||
|
</a>
|
||||||
|
<a th:href="@{?lang=ru}">
|
||||||
|
<img th:src="@{/images/ru.png}" th:alt="#{lang.ru}"/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,7 @@
|
|||||||
<td th:text="${{order.finishedOnDate}}"></td>
|
<td th:text="${{order.finishedOnDate}}"></td>
|
||||||
<td th:text="${{order.orderStatus}}"></td>
|
<td th:text="${{order.orderStatus}}"></td>
|
||||||
<td th:text="${{order.totalPrice}}"></td>
|
<td th:text="${{order.totalPrice}}"></td>
|
||||||
<td style="break-inside: avoid">
|
<td>
|
||||||
<div class="btn-group float-right">
|
<div class="btn-group float-right">
|
||||||
<a th:href="@{/order/edit/{id}(id=${order.id})}" class="btn btn-secondary" th:text="#{common.edit.button}"></a>
|
<a th:href="@{/order/edit/{id}(id=${order.id})}" class="btn btn-secondary" th:text="#{common.edit.button}"></a>
|
||||||
<button type="button" class="btn btn-danger" th:onclick="'deleteOrderById(' + ${order.id} + ')'" th:text="#{common.delete.button}"></button>
|
<button type="button" class="btn btn-danger" th:onclick="'deleteOrderById(' + ${order.id} + ')'" th:text="#{common.delete.button}"></button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user