mirror of
https://github.com/Prominence/grails-translations-plugin.git
synced 2026-01-09 19:06:41 +03:00
Created page for bundle translations.
Minor changes.
This commit is contained in:
parent
e36e2bdff5
commit
675eb1d055
@ -9,8 +9,19 @@ class TranslationsOverviewController {
|
||||
render view: 'index', model: [bundles: bundleService.getBundles()]
|
||||
}
|
||||
|
||||
def showBundles() {
|
||||
def show() {
|
||||
|
||||
render view: 'showBundles', model: [bundles: bundleService.getBundles()]
|
||||
if (!params.bundleName) {
|
||||
// render error
|
||||
}
|
||||
|
||||
Bundle bundle = bundleService.findBundleByName(params.bundleName as String)
|
||||
|
||||
if (!bundle) {
|
||||
// render error
|
||||
}
|
||||
|
||||
render view: 'show', model: [bundle: bundle]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1 +1,5 @@
|
||||
plugin.translations.overview.page.title = Translations overview
|
||||
plugin.translations.overview.index.page.title = Translations overview
|
||||
plugin.translations.overview.show.page.title = Bundle {0}
|
||||
|
||||
plugin.translations.totalRecords = Total: {0} records
|
||||
plugin.translations.totalBundles = Total: {0} bundles
|
||||
@ -1 +1,5 @@
|
||||
plugin.translations.overview.page.title = Translations overview
|
||||
plugin.translations.overview.index.page.title = Translations overview
|
||||
plugin.translations.overview.show.page.title = Bundle {0}
|
||||
|
||||
plugin.translations.totalRecords = Total: {0} records
|
||||
plugin.translations.totalBundles = Total: {0} bundles
|
||||
@ -1 +1,5 @@
|
||||
plugin.translations.overview.page.title = Translations overview
|
||||
plugin.translations.overview.index.page.title = Translations overview
|
||||
plugin.translations.overview.show.page.title = Bundle {0}
|
||||
|
||||
plugin.translations.totalRecords = Total: {0} records
|
||||
plugin.translations.totalBundles = Total: {0} bundles
|
||||
@ -1 +1,5 @@
|
||||
plugin.translations.overview.page.title = Обзор переводов
|
||||
plugin.translations.overview.index.page.title = Обзор переводов
|
||||
plugin.translations.overview.show.page.title = Бандл {0}
|
||||
|
||||
plugin.translations.totalRecords = Всего: {0} записей
|
||||
plugin.translations.totalBundles = Всего: {0} бандлов
|
||||
@ -4,7 +4,8 @@ class BundleService {
|
||||
|
||||
private HashSet<Bundle> cachedBundles
|
||||
|
||||
private static final defaultFolder = "i18n"
|
||||
private static final String DEFAULT_FOLDER = "i18n"
|
||||
private static final String DEFAULT_EXTENSION = '.properties'
|
||||
|
||||
HashSet<Bundle> getBundles(boolean noCache = false) {
|
||||
if (!cachedBundles || noCache) {
|
||||
@ -13,11 +14,18 @@ class BundleService {
|
||||
return cachedBundles
|
||||
}
|
||||
|
||||
Bundle findBundleByName(String name) {
|
||||
|
||||
getBundles().find { Bundle bundle ->
|
||||
bundle.name == name
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Bundle> searchForBundles() {
|
||||
Map<String, Bundle> result = new HashMap<>()
|
||||
|
||||
new File('.').eachFileRecurse() { File file ->
|
||||
if(file.name.endsWith('.properties')) {
|
||||
if(file.name.endsWith(DEFAULT_EXTENSION)) {
|
||||
if (isTranslationProperty(file)) {
|
||||
|
||||
String bundleName = getBundleName(file.name)
|
||||
@ -34,7 +42,7 @@ class BundleService {
|
||||
}
|
||||
|
||||
private boolean isTranslationProperty(File file) {
|
||||
return file.parent.contains(defaultFolder)
|
||||
return file.parent.contains(DEFAULT_FOLDER)
|
||||
}
|
||||
|
||||
private String getFileNameWithoutExtension(String filename) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta name="layout" content="main"/>
|
||||
<title><g:message code="plugin.translations.overview.page.title" /></title>
|
||||
<title><g:message code="plugin.translations.overview.index.page.title" /></title>
|
||||
<r:require modules="bootstrap"/>
|
||||
</head>
|
||||
|
||||
@ -10,23 +10,13 @@
|
||||
<g:if test="${bundles}">
|
||||
<ol>
|
||||
<g:each in="${bundles}" var="bundle">
|
||||
<li>${bundle.name}<li>
|
||||
<ul>
|
||||
<g:each in="${bundle.propertiesList}" var="properties">
|
||||
<li>${properties.name}</li>
|
||||
${properties.text.eachLine { line ->
|
||||
print('----------> ' + line + '<br/>')
|
||||
}}
|
||||
</g:each>
|
||||
</ul>
|
||||
<li><g:link action="show" params="${[bundleName: bundle.name]}" >${bundle.name}</g:link></li>
|
||||
</g:each>
|
||||
</ol>
|
||||
</g:if>
|
||||
<g:else>
|
||||
There is no bundles!
|
||||
</g:else>
|
||||
<button class="btn btn-default" type="button">
|
||||
Test bootstrap button
|
||||
</button>
|
||||
<g:message code="plugin.translations.totalBundles" args="${[bundles.size()]}"/>
|
||||
</body>
|
||||
</html>
|
||||
34
grails-app/views/translationsOverview/show.gsp
Normal file
34
grails-app/views/translationsOverview/show.gsp
Normal file
@ -0,0 +1,34 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="layout" content="main"/>
|
||||
<title><g:message code="plugin.translations.overview.show.page.title" args="${[bundle.name]}" /></title>
|
||||
<r:require modules="bootstrap"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><g:message code="plugin.translations.overview.show.page.title" args="${[bundle.name]}" /></h1>
|
||||
<br/>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<g:each in="${bundle.propertiesList}" var="propertyFile">
|
||||
<th>${propertyFile.name}</th>
|
||||
</g:each>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<g:each in="${bundle.propertiesList}" var="propertyFile">
|
||||
<td>${propertyFile.text}</td>
|
||||
</g:each>
|
||||
</tr>
|
||||
<tr>
|
||||
<g:each in="${bundle.propertiesList}" var="propertyFile">
|
||||
<td><g:message code="plugin.translations.totalRecords" args="${propertyFile.readLines().size()}"/></td>
|
||||
</g:each>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,11 +0,0 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="layout" content="main"/>
|
||||
<title>bundles</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user