diff --git a/src/client/epics/index.js b/src/client/epics/index.js index 81a435c796123934a87224a9ced41ac25fd8be5c..8a860197b58b5af825af9d7e2abaa0fd5d8a90b3 100644 --- a/src/client/epics/index.js +++ b/src/client/epics/index.js @@ -12,8 +12,7 @@ import { import { combineEpics, ofType } from 'redux-observable' import intl from 'react-intl-universal' import localeEN from '../translations/sampo/localeEN.json' -import localeFI from '../translations/sampo/localeFI' -import localeSV from '../translations/sampo/localeSV' +import localeFI from '../translations/sampo/localeFI.json' import { stateToUrl, pickSelectedDatasets } from '../helpers/helpers' import querystring from 'querystring' import { @@ -64,8 +63,7 @@ const apiUrl = process.env.API_URL export const availableLocales = { en: localeEN, - fi: localeFI, - sv: localeSV + fi: localeFI } let backendErrorText = null diff --git a/src/client/translations/sampo/localeFI.js b/src/client/translations/sampo/localeFI.js deleted file mode 100644 index 24146e3bac367b274083dca133488dde12dc56b0..0000000000000000000000000000000000000000 --- a/src/client/translations/sampo/localeFI.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - languageLabel: 'Suomi' -} diff --git a/src/client/translations/sampo/localeFI.json b/src/client/translations/sampo/localeFI.json new file mode 100644 index 0000000000000000000000000000000000000000..deeaf136384da57425c397e78564f647b2ac9b96 --- /dev/null +++ b/src/client/translations/sampo/localeFI.json @@ -0,0 +1,1188 @@ +{ + "languageLabel": "Suomi", + "html": { + "title": "Sampo-UI – A framework for building user interfaces for semantic portals", + "description": "" + }, + "appTitle": { + "short": "", + "long": "", + "subheading": "" + }, + "appDescription": "", + "appDescription1": "", + "appDescription2": "", + "appDescription3": "", + "appDescription4": "", + "selectPerspective": "", + "mainPageImageLicence": "", + "backendErrorText": "", + "topBar": { + "feedback": "", + "info": { + "info": "", + "blog": "", + "blogUrl": "", + "aboutThePortal": "" + }, + "searchBarPlaceHolder": "", + "searchBarPlaceHolderShort": "", + "instructions": "" + }, + "facetBar": { + "results": "", + "activeFilters": "", + "removeAllFilters": "", + "narrowDownBy": "", + "filterOptions": "", + "filterByName": "", + "filterByBoundingBox": "", + "selectionOptions": "", + "selectAlsoSubconcepts": "", + "doNotSelectSubconcepts": "", + "sortingOptions": "", + "sortAlphabetically": "", + "sortByNumberOfSearchResults": "", + "useDisjunction": "", + "useConjuction": "", + "minYear": "", + "maxYear": "", + "min": "", + "max": "", + "facetSearchFieldPlaceholder": "", + "applyFacetSelection": "", + "pieChart": { + "tooltip": "" + }, + "barChart": { + "tooltip": "", + "language": { + "title": "", + "xaxisTitle": "", + "yaxisTitle": "", + "seriesTitle": "" + } + }, + "lineChart": { + "tooltip": "", + "productionTimespan": { + "title": "", + "xaxisTitle": "", + "yaxisTitle": "", + "seriesTitle": "" + } + } + }, + "tabs": { + "table": "", + "map": "", + "production_places": "", + "production_places_heatmap": "", + "last_known_locations": "", + "migrations": "", + "network": "", + "export": "", + "production_dates": "", + "event_dates": "", + "map_clusters": "", + "map_markers": "", + "heatmap": "", + "statistics": "", + "emloLetterNetwork": "", + "emloSentReceived": "", + "download": "", + "recommendations": "" + }, + "table": { + "rowsPerPage": "", + "of": "" + }, + "lineChart": { + "productionCount": "", + "transferCount": "", + "observationCount": "", + "sentCount": "", + "receivedCount": "", + "allCount": "" + }, + "exportToYasgui": "", + "openInLinkedDataBrowser": "", + "resultsAsCSV": "", + "facets": { + "dateFacet": { + "invalidDate": "", + "toBeforeFrom": "", + "minDate": "", + "maxDate": "", + "cancel": "", + "fromLabel": "", + "toLabel": "" + }, + "textFacet": { + "inputLabel": "" + }, + "sliderFacet": { + "invalidStartOrEnd": "" + } + }, + "leafletMap": { + "basemaps": { + "mapbox": { + "light-v10": "" + }, + "googleRoadmap": "", + "topographicalMapNLS": "", + "backgroundMapNLS": "" + }, + "externalLayers": { + "arkeologiset_kohteet_alue": "", + "arkeologiset_kohteet_piste": "", + "fhaLidar": "", + "karelianMaps": "", + "senateAtlas": "", + "kotus:pitajat": "", + "kotus:rajat-sms-alueet": "", + "kotus:rajat-sms-alueosat": "", + "kotus:rajat-lansi-ita": "" + }, + "mapModeButtons": { + "markers": "", + "heatmap": "" + }, + "wrongZoomLevel": "", + "wrongZoomLevelFHA": "", + "tooManyResults": "" + }, + "instancePageGeneral": { + "introduction": "", + "repetition": "" + }, + "deckGlMap": { + "arcColouring": "", + "showMoreInformation": "", + "manuscriptMigrations": { + "legendTitle": "", + "legendFrom": "", + "legendTo": "", + "from": "", + "to": "", + "count": "", + "listHeadingSingleInstance": "", + "listHeadingMultipleInstances": "" + } + }, + "perspectives": { + "perspective1": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "", + "textFacetInputPlaceholder": "" + }, + "author": { + "label": "", + "description": "" + }, + "work": { + "label": "", + "description": "" + }, + "expression": { + "label": "", + "description": "" + }, + "productionPlace": { + "label": "", + "description": "" + }, + "productionTimespan": { + "label": "", + "description": "" + }, + "note": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "event": { + "label": "", + "description": "" + }, + "owner": { + "label": "", + "description": "" + }, + "collection": { + "label": "", + "description": "" + }, + "transferOfCustodyPlace": { + "label": "", + "description": "" + }, + "transferOfCustodyTimespan": { + "label": "", + "description": "" + }, + "lastKnownLocation": { + "label": "", + "description": "" + }, + "material": { + "label": "", + "description": "" + }, + "height": { + "label": "", + "description": "" + }, + "width": { + "label": "", + "description": "" + }, + "folios": { + "label": "", + "description": "" + }, + "lines": { + "label": "", + "description": "" + }, + "columns": { + "label": "", + "description": "" + }, + "miniatures": { + "label": "", + "description": "" + }, + "decoratedInitials": { + "label": "", + "description": "" + }, + "historiatedInitials": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "perspective2": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "", + "textFacetInputPlaceholder": "" + }, + "author": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "expression": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "productionTimespan": { + "label": "", + "description": "" + }, + "collection": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "perspective3": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "type": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "eventTimespan": { + "label": "", + "description": "" + }, + "place": { + "label": "", + "description": "" + }, + "placeType": { + "label": "", + "description": "" + }, + "note": { + "label": "", + "description": "" + }, + "surrender": { + "label": "", + "description": "" + }, + "receiver": { + "label": "", + "description": "" + }, + "observedOwner": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "manuscripts": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "author": { + "label": "", + "description": "" + }, + "work": { + "label": "", + "description": "" + }, + "expression": { + "label": "", + "description": "" + }, + "productionPlace": { + "label": "", + "description": "" + }, + "productionTimespan": { + "label": "", + "description": "" + }, + "note": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "event": { + "label": "", + "description": "" + }, + "owner": { + "label": "", + "description": "" + }, + "collection": { + "label": "", + "description": "" + }, + "transferOfCustodyPlace": { + "label": "", + "description": "" + }, + "transferOfCustodyTimespan": { + "label": "", + "description": "" + }, + "lastKnownLocation": { + "label": "", + "description": "" + }, + "material": { + "label": "", + "description": "" + }, + "height": { + "label": "", + "description": "" + }, + "width": { + "label": "", + "description": "" + }, + "folios": { + "label": "", + "description": "" + }, + "lines": { + "label": "", + "description": "" + }, + "columns": { + "label": "", + "description": "" + }, + "miniatures": { + "label": "", + "description": "" + }, + "decoratedInitials": { + "label": "", + "description": "" + }, + "historiatedInitials": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "works": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "author": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "expression": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "productionTimespan": { + "label": "", + "description": "" + }, + "collection": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "events": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "type": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "eventTimespan": { + "label": "", + "description": "" + }, + "place": { + "label": "", + "description": "" + }, + "note": { + "label": "", + "description": "" + }, + "surrender": { + "label": "", + "description": "" + }, + "receiver": { + "label": "", + "description": "" + }, + "observedOwner": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "actors": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "type": { + "label": "", + "description": "" + }, + "birthDateTimespan": { + "label": "", + "description": "" + }, + "deathDateTimespan": { + "label": "", + "description": "" + }, + "place": { + "label": "", + "description": "" + }, + "work": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "role": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "places": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "placeType": { + "label": "", + "description": "" + }, + "area": { + "label": "", + "description": "" + }, + "manuscriptProduced": { + "label": "", + "description": "" + }, + "manuscriptTransferred": { + "label": "", + "description": "" + }, + "manuscriptObserved": { + "label": "", + "description": "" + }, + "actor": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "collections": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "owner": { + "label": "", + "description": "" + }, + "place": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "expressions": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "finds": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "findName": { + "label": "", + "description": "" + }, + "specification": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "type": { + "label": "", + "description": "" + }, + "subCategory": { + "label": "", + "description": "" + }, + "objectSubCategory": { + "label": "", + "description": "" + }, + "material": { + "label": "", + "description": "" + }, + "materialLiteral": { + "label": "", + "description": "" + }, + "period": { + "label": "", + "description": "" + }, + "periodObject": { + "label": "", + "description": "" + }, + "startYear": { + "label": "", + "description": "" + }, + "endYear": { + "label": "", + "description": "" + }, + "municipality": { + "label": "", + "description": "" + }, + "image": { + "label": "", + "description": "" + } + } + }, + "emloActors": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "author": { + "label": "", + "description": "" + }, + "gender": { + "label": "", + "description": "" + }, + "type": { + "label": "", + "description": "" + }, + "birthDateTimespan": { + "label": "", + "description": "" + }, + "deathDateTimespan": { + "label": "", + "description": "" + }, + "altLabel": { + "label": "", + "description": "" + }, + "related": { + "label": "", + "description": "" + }, + "event": { + "label": "", + "description": "" + }, + "owner": { + "label": "", + "description": "" + }, + "rel": { + "label": "", + "description": "" + }, + "cor": { + "label": "", + "description": "" + }, + "transferOfCustodyTimespan": { + "label": "", + "description": "" + }, + "knownLocation": { + "label": "", + "description": "" + }, + "material": { + "label": "", + "description": "" + }, + "height": { + "label": "", + "description": "" + }, + "width": { + "label": "", + "description": "" + }, + "folios": { + "label": "", + "description": "" + }, + "lines": { + "label": "", + "description": "" + }, + "columns": { + "label": "", + "description": "" + }, + "miniatures": { + "label": "", + "description": "" + }, + "decoratedInitials": { + "label": "", + "description": "" + }, + "historiatedInitials": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "emloLetters": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "language": { + "label": "", + "description": "" + }, + "subject": { + "label": "", + "description": "" + }, + "datasource": { + "label": "", + "description": "" + }, + "excipit": { + "label": "", + "description": "" + }, + "description": { + "label": "", + "description": "" + }, + "manuscript": { + "label": "", + "description": "" + }, + "productionTimespan": { + "label": "", + "description": "" + }, + "collection": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + }, + "target": { + "label": "", + "description": "" + }, + "from": { + "label": "", + "description": "" + }, + "to": { + "label": "", + "description": "" + } + } + }, + "emloPlaces": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "instancePage": { + "label": "", + "description": "" + }, + "properties": { + "uri": { + "label": "", + "description": "" + }, + "type": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "country": { + "label": "", + "description": "" + }, + "broader": { + "label": "", + "description": "" + }, + "narrower": { + "label": "", + "description": "" + }, + "place": { + "label": "", + "description": "" + }, + "placeType": { + "label": "", + "description": "" + }, + "note": { + "label": "", + "description": "" + }, + "surrender": { + "label": "", + "description": "" + }, + "receiver": { + "label": "", + "description": "" + }, + "observedOwner": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + }, + "hellerau": { + "label": "", + "facetResultsType": "", + "shortDescription": "", + "longDescription": "", + "properties": { + "uri": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "home1930": { + "label": "", + "description": "" + }, + "home1937": { + "label": "", + "description": "" + } + } + }, + "clientFSPlaces": { + "label": "", + "shortDescription": "", + "datasets": { + "kotus": { + "label": "", + "aboutLink": "" + }, + "pnr": { + "label": "", + "aboutLink": "" + }, + "warsa_karelian_places": { + "label": "", + "aboutLink": "" + }, + "tgn": { + "label": "", + "aboutLink": "" + } + }, + "facetResultsType": "", + "inputPlaceHolder": "", + "searchByArea": "", + "searchByAreaTitle": "", + "searchByAreaCancel": "", + "searchByAreaSearch": "", + "properties": { + "datasetSelector": { + "label": "", + "description": "" + }, + "prefLabel": { + "label": "", + "description": "" + }, + "broaderTypeLabel": { + "label": "", + "description": "" + }, + "broaderAreaLabel": { + "label": "", + "description": "" + }, + "modifier": { + "label": "", + "description": "" + }, + "basicElement": { + "label": "", + "description": "" + }, + "collectionYear": { + "label": "", + "description": "" + }, + "source": { + "label": "", + "description": "" + } + } + } + }, + "aboutThePortalPartOne": "", + "aboutThePortalPartTwo": "", + "instructions": "", + "feedback": "" +} \ No newline at end of file diff --git a/src/client/translations/sampo/localeSV.js b/src/client/translations/sampo/localeSV.js deleted file mode 100644 index e37e1cdabe498cc8f9890e68aef9b96bd415e580..0000000000000000000000000000000000000000 --- a/src/client/translations/sampo/localeSV.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - languageLabel: 'Svenska' -} diff --git a/src/server/translations_generator/index.js b/src/server/translations_generator/index.js index d50713947cd5c75533f242c8f4ef4168f662cd9a..31bb75318e6db378a2e23693aba2336dde938f7f 100644 --- a/src/server/translations_generator/index.js +++ b/src/server/translations_generator/index.js @@ -19,8 +19,6 @@ const auth = new google.auth.GoogleAuth({ const sheets = google.sheets({ version: 'v4', auth }) -const spreadsheetId = process.env.SHEETS_API_SHEET_ID - // const writeToGoogleSheet = async values => { // try { // const result = await sheets.spreadsheets.values.update({ @@ -37,13 +35,13 @@ const spreadsheetId = process.env.SHEETS_API_SHEET_ID // } // } -const readFromGoogleSheet = async () => { +const readFromGoogleSheet = async ({ spreadsheetId, ranges }) => { try { - const result = await sheets.spreadsheets.values.get({ + const result = await sheets.spreadsheets.values.batchGet({ spreadsheetId, - range: 'A:B' + ranges }) - return result.data.values + return result.data.valueRanges } catch (error) { console.log(error) } @@ -54,15 +52,17 @@ const writeToFile = async (path, data) => { try { await fs.writeFile(path, json) - console.log('Saved data to file.') + console.log(`Saved translations from Google Sheets into '${path}'`) } catch (error) { console.error(error) } } -const sheetValuesToFlatObject = values => { - return values.reduce((result, item, index) => { - result[item[0]] = item[1] +const sheetValueRangesToFlatObject = valueRanges => { + const keyArray = valueRanges[0].values + const valueArray = valueRanges[1].values + return keyArray.reduce((result, item, index) => { + result[item[0]] = valueArray[index] ? valueArray[index][0] : '' return result }, {}) } @@ -85,8 +85,14 @@ const sheetValuesToFlatObject = values => { // writeToGoogleSheet(values) if (readTranslationsFromGoogleSheets) { - readFromGoogleSheet().then(data => { - const flatObject = sheetValuesToFlatObject(data) + const spreadsheetId = process.env.SHEETS_API_SHEET_ID + + readFromGoogleSheet({ spreadsheetId, ranges: ['Taulukko1!A:A', 'Taulukko1!B:B'] }).then(data => { + const flatObject = sheetValueRangesToFlatObject(data) writeToFile('src/client/translations/sampo/localeEN.json', unflatten(flatObject)) }) + readFromGoogleSheet({ spreadsheetId, ranges: ['Taulukko1!A:A', 'Taulukko1!C:C'] }).then(data => { + const flatObject = sheetValueRangesToFlatObject(data) + writeToFile('src/client/translations/sampo/localeFI.json', unflatten(flatObject)) + }) }