diff --git a/src/main/java/com/github/prominence/carrepair/conf/ApplicationConfiguration.java b/src/main/java/com/github/prominence/carrepair/conf/ApplicationConfiguration.java index 8f1e90c..03c683e 100644 --- a/src/main/java/com/github/prominence/carrepair/conf/ApplicationConfiguration.java +++ b/src/main/java/com/github/prominence/carrepair/conf/ApplicationConfiguration.java @@ -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()); + } } diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 1f94d21..f17ad71 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -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 diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index 1f94d21..f17ad71 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -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 diff --git a/src/main/resources/messages_ru.properties b/src/main/resources/messages_ru.properties index 3abf531..08f0638 100644 --- a/src/main/resources/messages_ru.properties +++ b/src/main/resources/messages_ru.properties @@ -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 = Фамилия diff --git a/src/main/resources/static/images/ru.png b/src/main/resources/static/images/ru.png new file mode 100755 index 0000000..47da421 Binary files /dev/null and b/src/main/resources/static/images/ru.png differ diff --git a/src/main/resources/static/images/us.png b/src/main/resources/static/images/us.png new file mode 100755 index 0000000..10f451f Binary files /dev/null and b/src/main/resources/static/images/us.png differ diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index c9484e2..16f4b98 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -6,13 +6,13 @@
-

Car Repair test project

+

:

- Requirements +
diff --git a/src/main/resources/templates/main.html b/src/main/resources/templates/main.html index daaaad2..d35df31 100644 --- a/src/main/resources/templates/main.html +++ b/src/main/resources/templates/main.html @@ -35,6 +35,14 @@ +
+ + + + + + +
diff --git a/src/main/resources/templates/order/index.html b/src/main/resources/templates/order/index.html index 70c070b..39bd356 100644 --- a/src/main/resources/templates/order/index.html +++ b/src/main/resources/templates/order/index.html @@ -81,7 +81,7 @@ - +