#1 -- Add internationalization
This commit is contained in:
parent
de2125d251
commit
4c3725a38b
@ -1,8 +1,11 @@
|
|||||||
package ru.ulstu.extractor.mvc;
|
package ru.ulstu.extractor.mvc;
|
||||||
|
|
||||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
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.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||||
import org.thymeleaf.spring5.SpringTemplateEngine;
|
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||||
|
|
||||||
@ -14,6 +17,17 @@ public class TemplateConfiguration {
|
|||||||
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
||||||
templateEngine.addTemplateResolver(templateResolver);
|
templateEngine.addTemplateResolver(templateResolver);
|
||||||
templateEngine.addDialect(new LayoutDialect());
|
templateEngine.addDialect(new LayoutDialect());
|
||||||
|
templateEngine.setMessageSource(messageSource());
|
||||||
return templateEngine;
|
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=
|
extractor.custom-projects-dir=
|
||||||
# Thymeleaf Settings
|
# Thymeleaf Settings
|
||||||
spring.thymeleaf.cache=false
|
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>
|
<!DOCTYPE html>
|
||||||
<html lang="ru"
|
<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>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<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"/>
|
<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/jquery/3.6.0/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="/webjars/bootstrap/4.6.0/js/bootstrap.min.js"></script>
|
<script type="text/javascript" src="/webjars/bootstrap/4.6.0/js/bootstrap.min.js"></script>
|
||||||
@ -14,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light" layout:fragment="navbar">
|
<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"
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
|
||||||
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
@ -23,25 +23,13 @@
|
|||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav mr-auto">
|
<ul class="navbar-nav mr-auto">
|
||||||
<li class="nav-item active">
|
<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>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#">Link</a>
|
<a class="nav-link" href="#" th:text="#{messages.menu.new-repo}">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>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user