Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

menu-config internationalization #428

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ node_modules
grails-app/assets/compile/

grails-app/conf/application-backup.yml
/.asscache
/npm-debug.log
12 changes: 12 additions & 0 deletions .jpb/persistence-units.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PersistenceUnitSettings">
<persistence-units>
<persistence-unit name="Default">
<packages>
<package value="" />
</packages>
</persistence-unit>
</persistence-units>
</component>
</project>
39 changes: 33 additions & 6 deletions _Events.groovy
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import org.apache.commons.io.FileUtils
import org.apache.commons.lang.StringUtils
import org.gradle.internal.os.OperatingSystem

def build(String baseDir) {

println 'Starting NPM install'
final workdir = new File(baseDir, '')
final proc = new ProcessBuilder().inheritIO()
final exec = proc.command('npm', '-dd', 'install').start()
// npm for UNIX, npm.cmd for Windows
final exec = null;
if (OperatingSystem.current().isLinux()) {
exec = proc.command('npm', '-dd', 'install').start()
} else if (OperatingSystem.current().isUnix()) {
exec = proc.command('npm', '-dd', 'install').start()
} else if (OperatingSystem.current().isWindows()) {
exec = proc.command('npm.cmd', '-dd', 'install').start()
} else if (OperatingSystem.current().isMacOsX()) {
exec = proc.command('npm', '-dd', 'install').start()
} else {
exec = proc.command('npm', '-dd', 'install').start()
}
def exitValue = exec.waitFor()
if (exitValue) {
println '*****************************************************'
Expand All @@ -19,15 +31,17 @@ def build(String baseDir) {
}

println 'Copying files to grails-app/assets/node_modules'
new ProcessBuilder().inheritIO().command('rm', '-r', 'grails-app/assets/node_modules').start().waitFor()

// new ProcessBuilder().inheritIO().command('rm', '-r', 'grails-app/assets/node_modules').start().waitFor()
println '================================='
println baseDir
println '================================='
def files = ['angular/angular.min.js', 'angular-animate/angular-animate.min.js', 'angular-aria/angular-aria.min.js',
'angular-leaflet-directive/dist/angular-leaflet-directive.min.js', 'angular-route/angular-route.min.js',
'angular-touch/angular-touch.min.js', 'angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
'angular-ui-bootstrap/dist/ui-bootstrap-csp.css', 'bootbox/dist/bootbox.min.js', 'jquery/dist/jquery.min.js',
'ng-file-upload/dist/ng-file-upload.js', 'ngbootbox/dist/ngBootbox.min.js',
'bootstrap/dist/', 'leaflet/dist/', 'leaflet-draw/dist/', 'proj4/dist/proj4.js',
'proj4leaflet/src/proj4leaflet.js']
'proj4leaflet/src/proj4leaflet.js','ace-builds/src/ace.js', 'ace-builds/src/mode-json.js', 'angular/angular-csp.css']
files.each { name ->
def dst = new File(baseDir + '/grails-app/assets/node_modules/' + name)
dst.getParentFile().mkdirs()
Expand Down Expand Up @@ -62,7 +76,18 @@ def build(String baseDir) {

// jsdoc
println 'Starting JSDoc'
final exec2 = proc.command('npm', 'run', 'jsdoc').start()
final exec2 = null;
if (OperatingSystem.current().isLinux()) {
exec2 = proc.command('npm', 'run', 'jsdoc').start()
} else if (OperatingSystem.current().isUnix()) {
exec2 = proc.command('npm', 'run', 'jsdoc').start()
} else if (OperatingSystem.current().isWindows()) {
exec2 = proc.command('npm.cmd', 'run', 'jsdoc').start()
} else if (OperatingSystem.current().isMacOsX()) {
exec2 = proc.command('npm', 'run', 'jsdoc').start()
} else {
exec2 = proc.command('npm', 'run', 'jsdoc').start()
}
def exitValue2 = exec2.waitFor()
if (exitValue2) {
println '*****************************************************'
Expand All @@ -87,6 +112,8 @@ def build(String baseDir) {

// load existing defaults
def p = new File(baseDir + '/grails-app/i18n/messages.properties')
// test refere to data dir
//def p = new File('/data/spatial-hub/i18n/messages.properties')
def prop = new Properties()
prop.load(new FileReader(p))
// reverse lookup
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ task _Events {
new GroovyScriptEngine([''] as String[]).run('_Events.groovy', new Binding())
}
}

// the tasks used here for dependsOn may be incomplete/incorrect

assetCompile.dependsOn(_Events)
compileGroovy.dependsOn(_Events)
bootRun.dependsOn(_Events)

bootRun {
grails { pathingJar = true }
jvmArgs('-Dspring.output.ansi.enabled=always', '-Xmx4G')
addResources = true
}
Expand Down
2 changes: 1 addition & 1 deletion embedExample.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
'https://collections.ala.org.au/**',
'http://phylolink.ala.org.au/**'
],
i18n: 'default',
i18n: 'de',
editable: false
};
</script>
Expand Down
Binary file added gradle-base-services-1.0.jar.zip
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions grails-app/assets/javascripts/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@


//ace
//= require ace-builds-1.2.8/src/ace.js
//= require ace-builds-1.2.8/src/mode-json.js
//= require ace-builds/src/ace.js
//= require ace-builds/src/mode-json.js
2 changes: 1 addition & 1 deletion grails-app/assets/javascripts/spApp/controller/toolCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
if (value.type === 'species') {
c.splice(parseInt(k) + 1, 0, {
type: "date",
description: "Select date range",
description: $i18n(531),
name: '_date'
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}
}
list.unshift({
title: $i18n("Other"),
title: $i18n(22),
facets: dynamicList
})
}
Expand Down
2 changes: 1 addition & 1 deletion grails-app/assets/javascripts/spApp/service/mapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@
},
getAllSpeciesQuery: function (layer) {
var query = {q: [], name: '', bs: '', ws: ''};
query.name = $i18n("All species");
query.name = $i18n(244);
query.bs = $SH.biocacheServiceUrl;
query.ws = $SH.biocacheUrl;
query.q.push('*:*');
Expand Down
22 changes: 20 additions & 2 deletions grails-app/assets/javascripts/spApp/service/menuService.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@

return httpconfig;
};

//TODO: support dynamic menu update

/*
if ($SH.menu.indexOf('http') == 0) {
var setup = $http.get($SH.menu, _httpDescription('getMenu')).then(function (data) {
menuConfig = data.data;
return menuConfig;
});
} else {
menuConfig = $SH.menu;
setup = $q.when(menuConfig)
}
*/
//TODO: support dynamic menu update
if ($SH.menu.indexOf('http') == 0) {
var setup = $http.get($SH.menu, _httpDescription('getMenu')).then(function (data) {
var it_0 = 0;
var it_1 = 0;
for(it_0 = 0; it_0 < data.data.length; it_0++) {
data.data[it_0].name = $i18n(data.data[it_0].i18nNr);
for(it_1 = 0; it_1 < data.data[it_0].items.length; it_1++) {
data.data[it_0].items[it_1].name = $i18n(data.data[it_0].items[it_1].i18nNr);
}
}
menuConfig = data.data;
return menuConfig;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

return [
MapService.newArea($i18n("Current extent"),
MapService.newArea($i18n(16),
["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),
"type": "area",
"constraints": {
"min": 1,
Expand All @@ -25,22 +25,22 @@
}
},
{
"description": "Species options.",
"description": $i18n(411),
Copy link
Contributor

@qifeng-bai qifeng-bai Nov 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a default value, like: $i18n(411, "Species options."). It would give developers a direct hint : it is "Species options.".

I have added a new $i18n(k, v) method to support this functionality

"type": "speciesOptions",
"constraints": {
"optional": true
}
},
{
"description": "Select facet.",
"description": $i18n(412),
"type": "facet",
"constraints": {
"min": 1,
"max": 1,
"optional": false
}
}],
"description": "Add species using a facet."
"description": $i18n(413)
},

execute: function (inputs) {
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(298),
"type": "layer",
"constraints": {
"min": 1,
"optional": false
}
}],
"description": "Add environmental and contextual layers to the map."
"description": $i18n(415)
},

execute: function (inputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
return {

// Override text with view-config.json
// Im Moment nur deutsche Internationalisierung
spec: {
"input": [
{
"name": "species",
"description": "Select species.",
"description": $i18n(416),
"type": "species",
"constraints": {
"min": 1,
Expand All @@ -30,7 +31,7 @@
},
{
"name": "speciesOptions",
"description": "Include related areas.",
"description": $i18n(417),
"type": "speciesOptions",
"constraints": {
"optional": true,
Expand All @@ -41,15 +42,15 @@
},
{
"name": "area",
"description": "Restrict to an area.",
"description": $i18n(418),
"type": "area",
"constraints": {
"min": 1,
"max": 1,
"defaultToWorld": true
}
}],
"description": "Add a species layer to the map"
"description": $i18n(419)
},


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
spec: {
"input": [
{
"description": $i18n("Select area."),
"description": $i18n(352),
"type": "area",
"constraints": {
"min": 1,
"max": 1,
"optional": false
}
}],
"description": $i18n("Area Report")
"description": $i18n(353)
},

execute: function (inputs) {
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),
"type": "area",
"constraints": {
"min": 1,
Expand All @@ -25,7 +25,7 @@
}
},
{
"description": "Filetype.",
"description": $i18n(421),
"type": "list",
"constraints": {
"default": "Shapefile",
Expand All @@ -41,26 +41,26 @@
}],
"view": [
{
"name": "Select areas to export.",
"name": $i18n(422),
"inputs": [
"area"
]
},
{
"name": "Select filetype.",
"name": $i18n(423),
"inputs": [
"layer"
]
},
{
"name": "Number of groups and Shapefile generation",
"name": $i18n(424),
"inputs": [
"groups",
"shp"
]
}
],
"description": "Export areas."
"description": $i18n(425)
},

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(418),
"type": "area",
"constraints": {
"min": 1,
Expand All @@ -24,15 +24,15 @@
}
},
{
"description": "Species options.",
"description": $i18n(411),
"type": "speciesOptions",
"constraints": {
"areaIncludes": false,
"kosherIncudes": true,
"endemicIncludes": true
}
}],
"description": "Export a species list."
"description": $i18n(426)
},

downloading: false,
Expand Down
Loading