1
1
import { fetchGetCapabilities , fetchDescribeRecord , fetchGetRecords } from "./cswrequests.js" ;
2
2
import { cswEndPoints } from "./endpoints.js" ;
3
+ import { translateStrings } from "./translate.js" ;
3
4
4
5
let cswTestUrl = 'https://nationaalgeoregister.nl/geonetwork/srv/dut/csw-inspire' ;
6
+ let language = 'Dutch' ;
5
7
6
8
// if arguments are provided, use them
7
9
if ( process . argv . length > 2 ) {
8
10
console . log ( `using endpoint ${ cswEndPoints [ parseInt ( process . argv [ 2 ] ) ] . name } ` )
9
11
cswTestUrl = cswEndPoints [ parseInt ( process . argv [ 2 ] ) ] . url ;
12
+ language = cswEndPoints [ parseInt ( process . argv [ 2 ] ) ] . language ;
10
13
}
11
14
12
15
const capabilities = await fetchGetCapabilities ( cswTestUrl ) ;
@@ -25,4 +28,11 @@ let getRecords = await fetchGetRecords(getRecordsUrl, capabilities.serviceTypeVe
25
28
if ( getRecords . error && getRecords . error . indexOf ( 'status' ) > - 1 && getRecords . error . indexOf ( '404' ) > - 1 ) {
26
29
getRecords = await fetchGetRecords ( cswTestUrl , capabilities . serviceTypeVersion , elementSetName ) ;
27
30
}
28
- console . log ( getRecords ) ;
31
+ if ( getRecords . error ) {
32
+ console . error ( `url: ${ getRecordsUrl } , error: ${ getRecords . error } ` ) ;
33
+ } else {
34
+ const titles = getRecords . records . map ( record => record . title ) ;
35
+ const types = getRecords . records . map ( record => record . type ) ;
36
+ const englishTitles = await translateStrings ( [ ...titles , ...types ] , language ) ;
37
+ console . log ( titles , englishTitles ) ;
38
+ }
0 commit comments