Skip to content

Commit 4b2142e

Browse files
committed
add translate test
1 parent 65af236 commit 4b2142e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { fetchGetCapabilities, fetchDescribeRecord, fetchGetRecords } from "./cswrequests.js";
22
import { cswEndPoints } from "./endpoints.js";
3+
import { translateStrings } from "./translate.js";
34

45
let cswTestUrl = 'https://nationaalgeoregister.nl/geonetwork/srv/dut/csw-inspire';
6+
let language = 'Dutch';
57

68
// if arguments are provided, use them
79
if (process.argv.length > 2) {
810
console.log(`using endpoint ${cswEndPoints[parseInt(process.argv[2])].name}`)
911
cswTestUrl = cswEndPoints[parseInt(process.argv[2])].url;
12+
language = cswEndPoints[parseInt(process.argv[2])].language;
1013
}
1114

1215
const capabilities = await fetchGetCapabilities(cswTestUrl);
@@ -25,4 +28,11 @@ let getRecords = await fetchGetRecords(getRecordsUrl, capabilities.serviceTypeVe
2528
if (getRecords.error && getRecords.error.indexOf('status') > -1 && getRecords.error.indexOf('404') > -1) {
2629
getRecords = await fetchGetRecords(cswTestUrl, capabilities.serviceTypeVersion, elementSetName);
2730
}
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

Comments
 (0)