diff --git a/.gitignore b/.gitignore index 3c4a742..8e43d8d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .project target .idea -*.zip \ No newline at end of file +*.zip +.slcache \ No newline at end of file diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy index 2d22b15..6f4093b 100644 --- a/grails-app/conf/BuildConfig.groovy +++ b/grails-app/conf/BuildConfig.groovy @@ -16,6 +16,8 @@ grails.project.fork = [ console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] ] +grails.server.port.http = 8082 + grails.project.dependency.resolver = "maven" // or ivy grails.project.dependency.resolution = { // inherit Grails' default dependencies @@ -40,9 +42,11 @@ grails.project.dependency.resolution = { } plugins { - build(":release:3.0.1", - ":rest-client-builder:1.0.3") { + build(':release:3.0.1', + ':rest-client-builder:1.0.3') { export = false } + + build(':tomcat:7.0.55') } } diff --git a/grails-app/conf/Config.groovy b/grails-app/conf/Config.groovy index c33bd8d..61daa15 100644 --- a/grails-app/conf/Config.groovy +++ b/grails-app/conf/Config.groovy @@ -20,3 +20,6 @@ log4j = { 'org.hibernate', 'net.sf.ehcache.hibernate' } + +grails.views.gsp.encoding = "UTF-8" +grails.converters.encoding = "UTF-8" \ No newline at end of file diff --git a/grails-app/controllers/by/prominence/translations/TranslationsOverviewController.groovy b/grails-app/controllers/by/prominence/translations/TranslationsOverviewController.groovy new file mode 100644 index 0000000..1efae4b --- /dev/null +++ b/grails-app/controllers/by/prominence/translations/TranslationsOverviewController.groovy @@ -0,0 +1,13 @@ +package by.prominence.translations + +class TranslationsOverviewController { + + def bundleService + + def index() { } + + def showBundles() { + + render view: 'showBundles', model: [bundles: bundleService.getBundles()] + } +} diff --git a/grails-app/domain/by/prominence/translations/Bundle.groovy b/grails-app/domain/by/prominence/translations/Bundle.groovy new file mode 100644 index 0000000..dd07da3 --- /dev/null +++ b/grails-app/domain/by/prominence/translations/Bundle.groovy @@ -0,0 +1,11 @@ +package by.prominence.translations + +class Bundle { + + String name + List propertiesList = new ArrayList<>() + + public void addPropertyFile(File file) { + propertiesList.add(file) + } +} diff --git a/grails-app/domain/by/prominence/translations/BundleProperties.groovy b/grails-app/domain/by/prominence/translations/BundleProperties.groovy new file mode 100644 index 0000000..a1a3500 --- /dev/null +++ b/grails-app/domain/by/prominence/translations/BundleProperties.groovy @@ -0,0 +1,8 @@ +package by.prominence.translations + +class BundleProperties { + + Bundle bundle + Properties properties + +} diff --git a/grails-app/i18n/anotherBundle.properties b/grails-app/i18n/anotherBundle.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/anotherBundle_af.properties b/grails-app/i18n/anotherBundle_af.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/anotherBundle_as.properties b/grails-app/i18n/anotherBundle_as.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/anotherBundle_br.properties b/grails-app/i18n/anotherBundle_br.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/anotherBundle_de.properties b/grails-app/i18n/anotherBundle_de.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/anotherBundle_en.properties b/grails-app/i18n/anotherBundle_en.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/anotherBundle_ru.properties b/grails-app/i18n/anotherBundle_ru.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/anotherBundle_uk.properties b/grails-app/i18n/anotherBundle_uk.properties new file mode 100644 index 0000000..e69de29 diff --git a/grails-app/i18n/messages.properties b/grails-app/i18n/messages.properties new file mode 100644 index 0000000..d04db22 --- /dev/null +++ b/grails-app/i18n/messages.properties @@ -0,0 +1 @@ +test.message = Test message here \ No newline at end of file diff --git a/grails-app/i18n/messages_de.properties b/grails-app/i18n/messages_de.properties new file mode 100644 index 0000000..d04db22 --- /dev/null +++ b/grails-app/i18n/messages_de.properties @@ -0,0 +1 @@ +test.message = Test message here \ No newline at end of file diff --git a/grails-app/i18n/messages_en.properties b/grails-app/i18n/messages_en.properties new file mode 100644 index 0000000..d04db22 --- /dev/null +++ b/grails-app/i18n/messages_en.properties @@ -0,0 +1 @@ +test.message = Test message here \ No newline at end of file diff --git a/grails-app/i18n/messages_ru.properties b/grails-app/i18n/messages_ru.properties new file mode 100644 index 0000000..451bea2 --- /dev/null +++ b/grails-app/i18n/messages_ru.properties @@ -0,0 +1 @@ +test.message = Тестовое сообщение \ No newline at end of file diff --git a/grails-app/services/by/prominence/translations/BundleService.groovy b/grails-app/services/by/prominence/translations/BundleService.groovy new file mode 100644 index 0000000..0ea1795 --- /dev/null +++ b/grails-app/services/by/prominence/translations/BundleService.groovy @@ -0,0 +1,49 @@ +package by.prominence.translations + +class BundleService { + + private HashSet cachedBundles + + private static final defaultFolder = "i18n" + + HashSet getBundles(boolean noCache = false) { + if (!cachedBundles || noCache) { + cachedBundles = searchForBundles().values() + } + return cachedBundles + } + + private Map searchForBundles() { + Map result = new HashMap<>() + + new File('.').eachFileRecurse() { File file -> + if(file.name.endsWith('.properties')) { + if (isTranslationProperty(file)) { + + String bundleName = getBundleName(file.name) + if (!result.get(bundleName)) { + Bundle bundle = new Bundle(name: bundleName) + result.put(bundleName, bundle) + } + result.get(bundleName).addPropertyFile(file) + } + } + } + + return result + } + + private boolean isTranslationProperty(File file) { + return file.parent.contains(defaultFolder) + } + + private String getFileNameWithoutExtension(String filename) { + return filename.substring(0, filename.lastIndexOf('.')) + } + + private String getBundleName(String filename) { + return filename.indexOf('_') < 0 ? + getFileNameWithoutExtension(filename) : + filename.substring(0, filename.indexOf('_')) + } +} diff --git a/grails-app/views/translationsOverview/index.gsp b/grails-app/views/translationsOverview/index.gsp new file mode 100644 index 0000000..5a69b9b --- /dev/null +++ b/grails-app/views/translationsOverview/index.gsp @@ -0,0 +1,11 @@ +<%@ page contentType="text/html;charset=UTF-8" %> + + + + Test + + + + + + \ No newline at end of file diff --git a/grails-app/views/translationsOverview/showBundles.gsp b/grails-app/views/translationsOverview/showBundles.gsp new file mode 100644 index 0000000..6ee53f2 --- /dev/null +++ b/grails-app/views/translationsOverview/showBundles.gsp @@ -0,0 +1,24 @@ +<%@ page contentType="text/html;charset=UTF-8" %> + + + + bundles + + + + + + ${bundle.name}
+ + -> ${properties.name}
+ ${properties.text.eachLine { line -> + print('----------> ' + line + '
') + }} +
+
+
+ + There is no bundles! + + + \ No newline at end of file