diff --git a/src/main/java/ru/ulstu/extractor/mvc/TemplateConfiguration.java b/src/main/java/ru/ulstu/extractor/mvc/TemplateConfiguration.java index 4a0ad46..7798224 100644 --- a/src/main/java/ru/ulstu/extractor/mvc/TemplateConfiguration.java +++ b/src/main/java/ru/ulstu/extractor/mvc/TemplateConfiguration.java @@ -1,8 +1,11 @@ package ru.ulstu.extractor.mvc; import nz.net.ultraq.thymeleaf.LayoutDialect; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.thymeleaf.spring5.SpringTemplateEngine; import org.thymeleaf.templateresolver.ITemplateResolver; @@ -14,6 +17,17 @@ public class TemplateConfiguration { final SpringTemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.addTemplateResolver(templateResolver); templateEngine.addDialect(new LayoutDialect()); + templateEngine.setMessageSource(messageSource()); return templateEngine; } + + @Value("${messages.basename.path}") + private String messagesBasename; + + public MessageSource messageSource() { + ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); + messageSource.setFallbackToSystemLocale(false); + messageSource.setBasenames("file:" + messagesBasename); + return messageSource; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c616bb3..ee52065 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,3 +5,4 @@ logging.level.ru.ulstu=DEBUG extractor.custom-projects-dir= # Thymeleaf Settings spring.thymeleaf.cache=false +messages.basename.path=messages_en.properties \ No newline at end of file diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties new file mode 100644 index 0000000..34bbcb8 --- /dev/null +++ b/src/main/resources/messages.properties @@ -0,0 +1,4 @@ +messages.app-name=GitExtractor v0.1.0 +messages.menu.home=Main +messages.menu.indexed-repos=List of indexed repos +messages.menu.new-repo=Analyse new repo \ No newline at end of file diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties new file mode 100644 index 0000000..34bbcb8 --- /dev/null +++ b/src/main/resources/messages_en.properties @@ -0,0 +1,4 @@ +messages.app-name=GitExtractor v0.1.0 +messages.menu.home=Main +messages.menu.indexed-repos=List of indexed repos +messages.menu.new-repo=Analyse new repo \ No newline at end of file diff --git a/src/main/resources/messages_ru.properties b/src/main/resources/messages_ru.properties new file mode 100644 index 0000000..dfda9c7 --- /dev/null +++ b/src/main/resources/messages_ru.properties @@ -0,0 +1,4 @@ +messages.app-name=GitЁxtractor v0.1.0 +messages.menu.home=На главную +messages.menu.indexed-repos=Список проиндексированных репозиториев +messages.menu.new-repo=Анализ нового репозитория \ No newline at end of file diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html index 86a443c..0d64bba 100644 --- a/src/main/resources/templates/default.html +++ b/src/main/resources/templates/default.html @@ -1,9 +1,9 @@ + xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml">
-