Skip to content

Commit 59a1e63

Browse files
committed
#433 fix(missing lang properties)
1 parent 7c82196 commit 59a1e63

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

grails-app/conf/application.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ grails:
2222
upload:
2323
maxFileSize: 10000000
2424
maxRequestSize: 10000000
25+
i18n:
26+
region: 'default'
2527

2628
layersService:
2729
url: 'https://spatial.ala.org.au/ws'

grails-app/controllers/au/org/ala/spatial/portal/PortalController.groovy

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ class PortalController {
151151
config.spApp.each { k, v ->
152152
spApp.put(k, v.class.newInstance(params.get(k, v)))
153153
}
154-
config.spApp = spApp
154+
if (params.get("lang")) {
155+
config.i18n?.currentRegion = params.get("lang")
156+
} else {
157+
config.i18n?.currentRegion = config.i18n?.region
158+
}
155159

156160
render(view: 'index',
157161
model: [config : config,

grails-app/services/au/org/ala/spatial/portal/PropertiesService.groovy

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package au.org.ala.spatial.portal
1717

1818
import org.apache.commons.io.FileUtils
19+
import org.apache.logging.log4j.util.Strings
1920

2021
/**
2122
* Helper class for invoking other ALA web services.
@@ -29,6 +30,10 @@ class PropertiesService {
2930
def defaultFile = "${name}.properties";
3031
def properties = new Properties()
3132

33+
//Load default English properties
34+
def defaultProperties = new Properties()
35+
defaultProperties.load(new StringReader(PortalController.classLoader.getResourceAsStream("messages.properties")?.text))
36+
3237
def text = PortalController.classLoader.getResourceAsStream("$defaultFile")?.text
3338
if (text) {
3439
properties.load(new StringReader(text))
@@ -54,6 +59,12 @@ class PropertiesService {
5459
if (file.exists()) {
5560
properties.load(new FileReader(file))
5661
}
62+
//Use default English properties if the required lang is not available
63+
defaultProperties.each{
64+
if (!properties.getProperty(it.key)){
65+
properties.setProperty(it.key, it.value)
66+
}
67+
}
5768

5869
if (properties.size() == 0 && type != 'messages') {
5970
get('messages')

grails-app/views/portal/index.gsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
, '${config.doiService.url}/**'
145145
</g:if>
146146
],
147-
i18n: '${config.i18n?.region?:"default"}',
147+
i18n: '${config.i18n?.currentRegion?:"default"}',
148148
editable: ${params.edit?:'false'},
149149
wmsIntersect: ${config.wms.intersect},
150150
projections: ${(config.projections as grails.converters.JSON).toString().encodeAsRaw()},

0 commit comments

Comments
 (0)