#1 -- Add internationalization
This commit is contained in:
parent
de2125d251
commit
4c3725a38b
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
4
src/main/resources/messages.properties
Normal file
4
src/main/resources/messages.properties
Normal file
@ -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
|
4
src/main/resources/messages_en.properties
Normal file
4
src/main/resources/messages_en.properties
Normal file
@ -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
|
4
src/main/resources/messages_ru.properties
Normal file
4
src/main/resources/messages_ru.properties
Normal file
@ -0,0 +1,4 @@
|
||||
messages.app-name=GitЁxtractor v0.1.0
|
||||
messages.menu.home=На главную
|
||||
messages.menu.indexed-repos=Список проиндексированных репозиториев
|
||||
messages.menu.new-repo=Анализ нового репозитория
|
@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>GitExtractor</title>
|
||||
<title th:text="#{messages.app-name}">app-name</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="/webjars/bootstrap/4.6.0/js/bootstrap.min.js"></script>
|
||||
@ -14,7 +14,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light" layout:fragment="navbar">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<a class="navbar-brand" href="#" th:text="#{messages.app-name}">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -23,25 +23,13 @@
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
|
||||
<a class="nav-link" href="#" th:text="#{messages.menu.home}">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">
|
||||
Dropdown
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="#">Action</a>
|
||||
<a class="dropdown-item" href="#">Another action</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Something else here</a>
|
||||
</div>
|
||||
<a class="nav-link" href="#" th:text="#{messages.menu.new-repo}">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
|
||||
<a class="nav-link" href="#" th:text="#{messages.menu.indexed-repos}">Link</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user