Skip to content

Commit

Permalink
#428 impl(i18n on dynamic menu)
Browse files Browse the repository at this point in the history
  • Loading branch information
qifeng-bai committed Nov 1, 2021
1 parent 4b64a91 commit 4963c46
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 31 deletions.
6 changes: 6 additions & 0 deletions grails-app/assets/javascripts/spApp/service/menuService.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

if ($SH.menu.indexOf('http') == 0) {
var setup = $http.get($SH.menu, _httpDescription('getMenu')).then(function (data) {
for(var i = 0; i < data.data.length; i++) {
data.data[i].name = $i18n(data.data[i].name);
for(var j = 0; j < data.data[i].items.length; j++) {
data.data[i].items[j].name = $i18n(data.data[i].items[j].name);
}
}
menuConfig = data.data;
return menuConfig;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}

return [
MapService.newArea($i18n("Current extent"),
MapService.newArea($i18n(16, "Current extent"),
["longitude:[" + extents[0] + " TO " + extents[2] + "]", "latitude:[" + extents[1] + " TO " + extents[3] + "]"],
'POLYGON((' + extents[0] + ' ' + extents[3] + ',' + extents[0] + ' ' + extents[1] + ',' +
extents[2] + ' ' + extents[1] + ',' + extents[2] + ' ' + extents[3] + ',' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
spec: {
"input": [
{
"description": "Select area",
"description": $i18n(352, "Select area."),
"type": "area",
"constraints": {
"min": 1,
Expand All @@ -25,7 +25,7 @@
}
},
{
"description": "Species options",
"description": $i18n(411,"Species options."),
"type": "speciesOptions",
"constraints": {
"min": 1,
Expand All @@ -34,7 +34,7 @@
}
},
{
"description": "Select facet",
"description": $i18n(412,"Select facet."),
"type": "facet",
"constraints": {
"min": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
spec: {
"input": [
{
"description": "Select layers.",
"description": $i18n(414,"Select layers."),
"type": "layer",
"constraints": {
"min": 1,
"optional": false
}
}],
"description": "Add environmental and contextual layers to the map."
"description": $i18n(515,"Add environmental and contextual layers to the map.")
},

execute: function (inputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"input": [
{
"name": "species",
"description": "Select species.",
"description": $i18n(416,"Select species."),
"type": "species",
"constraints": {
"min": 1,
Expand All @@ -30,7 +30,7 @@
},
{
"name": "speciesOptions",
"description": "Include related areas.",
"description": $i18n(417,"Include related areas."),
"type": "speciesOptions",
"constraints": {
"optional": true,
Expand All @@ -41,15 +41,15 @@
},
{
"name": "area",
"description": "Restrict to an area.",
"description": $i18n(418,"Restrict to an area."),
"type": "area",
"constraints": {
"min": 1,
"max": 1,
"defaultToWorld": true
}
}],
"description": "Add a species layer to the map"
"description": $i18n(419,"Add a species layer to the map")
},


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
spec: {
"input": [
{
"description": "Select areas.",
"description": $i18n(420,"Select areas."),
"type": "area",
"constraints": {
"min": 1,
Expand All @@ -25,7 +25,7 @@
}
},
{
"description": "Filetype.",
"description": $i18n(421,"Filetype."),
"type": "list",
"constraints": {
"default": "Shapefile",
Expand All @@ -41,26 +41,26 @@
}],
"view": [
{
"name": "Select areas to export.",
"name": $i18n(422,"Select areas to export."),
"inputs": [
"area"
]
},
{
"name": "Select filetype.",
"name": $i18n(423,"Select filetype."),
"inputs": [
"layer"
]
},
{
"name": "Number of groups and Shapefile generation",
"name": $i18n(424,"Number of groups and Shapefile generation"),
"inputs": [
"groups",
"shp"
]
}
],
"description": "Export areas."
"description": $i18n(425,"Export areas.")
},

execute: function (inputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
spec: {
"input": [
{
"description": "Restrict to an area.",
"description": $i18n(543, "Restrict to an area."),
"type": "area",
"constraints": {
"min": 1,
Expand All @@ -24,7 +24,7 @@
}
},
{
"description": "Species options.",
"description": $i18n(411,"Species options."),
"type": "speciesOptions",
"constraints": {
"areaIncludes": false,
Expand All @@ -33,7 +33,7 @@
"absentOption": true
}
}],
"description": "Export a species list."
"description": $i18n(426,"Export a species list.")
},

downloading: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"input": [
{
"name": "species",
"description": "Select mapped species.",
"description": $i18n(544,"Select mapped species."),
"type": "species",
"constraints": {
"min": 1,
Expand All @@ -39,14 +39,14 @@
},
{
"name":"annotateWorkflow",
"description": "Annotate your workflow",
"description": $i18n(545,"Annotate your workflow"),
"type": "annotation",
"constraints": {
"optional": false
}
}
],
"description": "Export points."
"description": $i18n(546,"Export points.")
},

refresh: function (inputs, specs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}

}],
"description": "Export areas."
"description": $i18n(425,"Export areas.")
},

execute: function (inputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"input": [
{
"name": "area",
"description": "Select area.",
"description": $i18n(382,"Select area."),
"type": "area",
"constraints": {
"min": 1,
Expand All @@ -34,7 +34,7 @@
},
{
"name": "species",
"description": "Select species.",
"description": $i18n(416,"Select species."),
"type": "species",
"constraints": {
"min": 1,
Expand All @@ -46,7 +46,7 @@
},
{
"name": "layers",
"description": "Select layers.",
"description": $i18n(414,"Select layers."),
"type": "layer",
"constraints": {
"min": 1,
Expand Down
26 changes: 23 additions & 3 deletions grails-app/assets/javascripts/spApp/spApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,32 @@ function fetchData() {
gMessages[k + ""] = result.data[k]
}
$SH.gMessages = gMessages;
$i18n = function (k) {
var key = ("" + k).replace(" ", "_");
// $i18n = function (k) {
// var key = ("" + k).replace(" ", "_");
// if ($SH.gMessages[key] !== undefined) {
// return $SH.gMessages[key]
// } else {
// return k
// }
// }
/**
* If key is not found in message.properties, use the default value
*
* If no default value is given, use key
*
* @param k key
* @param v optional default value
* @returns {*}
*/
$i18n = function (k, v) {
var key = ("" + k);
if ($SH.gMessages[key] !== undefined) {
return $SH.gMessages[key]
} else {
return k
if (v !== undefined)
return v
else
return k
}
}
}));
Expand Down
4 changes: 3 additions & 1 deletion grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ skin:
favicon: 'https://www.ala.org.au/app/uploads/2019/01/cropped-favicon-32x32.png'

layersService:
url: 'https://localhost:8085/spatial-service/'
url: 'https://spatial.ala.org.au/ws'

lists:
url: 'https://lists.ala.org.au'
Expand Down Expand Up @@ -622,6 +622,8 @@ environments:
use-forward-headers: true
grails:
serverURL: http://devt.ala.org.au:8087
layersService:
url: 'http://localhost:8080/ws/'
test:
production:
assets:
Expand Down
14 changes: 13 additions & 1 deletion grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ typeMismatch.java.lang.Long=Property {0} must be a valid number
typeMismatch.java.lang.Short=Property {0} must be a valid number
typeMismatch.java.math.BigDecimal=Property {0} must be a valid number
typeMismatch.java.math.BigInteger=Property {0} must be a valid number

#menu
#add \ before space or special chars
#Key is case-sensitive
Add\ to\ map=Add to map
Area\ Report\ -\ interactive=Area Report - interactive


# added by grailsApp/assets/javascript/spApp/templates/*
1=×
2=Add area
Expand Down Expand Up @@ -571,4 +579,8 @@ typeMismatch.java.math.BigInteger=Property {0} must be a valid number
539=Authentication failed or login session expired, Please login again!
540=An error occurred. Please try again and if the same error occurs, send an email to [email protected] and include the URL to this page, the error message and what steps you performed that triggered this error.
541=Import another species list
542=Current List:
542=Current List:
543=Restrict to an area.
544=Select mapped species.
545=Annotate your workflow
546=Export points.

0 comments on commit 4963c46

Please sign in to comment.