mirror of
https://github.com/Prominence/car-repair-site.git
synced 2026-01-09 03:36:46 +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 org.springframework.context.annotation.Bean;
|
||||
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
|
||||
public class ApplicationConfiguration {
|
||||
public class ApplicationConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public LayoutDialect 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
|
||||
|
||||
home.requirements.label = Requirements
|
||||
home.title.label = Test project "Car Repair Service"
|
||||
|
||||
client.title = Clients
|
||||
mechanic.title = Mechanics
|
||||
order.title = Orders
|
||||
|
||||
lang.en = English
|
||||
lang.ru = Russian
|
||||
|
||||
firstName.label = First Name
|
||||
middleName.label = Middle Name
|
||||
lastName.label = Last Name
|
||||
|
||||
@ -5,11 +5,15 @@ badge.mechanics = Mechanics
|
||||
badge.orders = Orders
|
||||
|
||||
home.requirements.label = Requirements
|
||||
home.title.label = Test project "Car Repair Service"
|
||||
|
||||
client.title = Clients
|
||||
mechanic.title = Mechanics
|
||||
order.title = Orders
|
||||
|
||||
lang.en = English
|
||||
lang.ru = Russian
|
||||
|
||||
firstName.label = First Name
|
||||
middleName.label = Middle Name
|
||||
lastName.label = Last Name
|
||||
|
||||
@ -5,11 +5,15 @@ badge.mechanics = Механики
|
||||
badge.orders = Заказы
|
||||
|
||||
home.requirements.label = Требования
|
||||
home.title.label = Тестовый проект "Автомастерская"
|
||||
|
||||
client.title = Клиенты
|
||||
mechanic.title = Механики
|
||||
order.title = Заказы
|
||||
|
||||
lang.en = Английский
|
||||
lang.ru = Русский
|
||||
|
||||
firstName.label = Имя
|
||||
middleName.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>
|
||||
<body>
|
||||
<div layout:fragment="header">
|
||||
<h1>Car Repair test project</h1>
|
||||
<h1 th:text="#{home.title.label}"></h1>
|
||||
</div>
|
||||
<div layout:fragment="content">
|
||||
<h2>
|
||||
<span><th:block th:text="#{home.requirements.label}"/>:</span>
|
||||
</h2>
|
||||
<img src="images/task.png" alt="Requirements"/>
|
||||
<img src="/images/task.png" th:alt="#{home.requirements.label}"/>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
@ -35,6 +35,14 @@
|
||||
</li>
|
||||
</ul>
|
||||
</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>
|
||||
</nav>
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
<td th:text="${{order.finishedOnDate}}"></td>
|
||||
<td th:text="${{order.orderStatus}}"></td>
|
||||
<td th:text="${{order.totalPrice}}"></td>
|
||||
<td style="break-inside: avoid">
|
||||
<td>
|
||||
<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>
|
||||
<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