diff --git a/CHANGELOG.md b/CHANGELOG.md index 29140544b..866705648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ You can also check the [release page](https://github.com/visualize-admin/visuali ## Unreleased -Nothing yet. +- Features + - Localized cube landing pages are now supported (dcat:landingPage) 🌎 # [3.24.2] - 2023-11-28 diff --git a/app/rdf/query-cube-metadata.ts b/app/rdf/query-cube-metadata.ts index e275cabdc..6be465414 100644 --- a/app/rdf/query-cube-metadata.ts +++ b/app/rdf/query-cube-metadata.ts @@ -140,7 +140,10 @@ export const getCubeMetadata = async ( ?contactPoint ${ns.vcard.hasEmail} ?contactPointEmail . } OPTIONAL { ?iri ${ns.dcterms.publisher} ?publisher . } - OPTIONAL { ?iri ${ns.dcat.landingPage} ?landingPage . } + ${buildLocalizedSubQuery("iri", "dcat:landingPage", "landingPage", { + locale, + fallbackToNonLocalized: true, + })} OPTIONAL { ?iri ${ns.schema.expires} ?expires . } OPTIONAL { ?iri ${ns.schema.workExample} ?workExample . } `.GROUP().BY`?iri`.THEN.BY`?identifier`.THEN.BY`?title`.THEN.BY`?description` diff --git a/app/rdf/query-utils.ts b/app/rdf/query-utils.ts index aa44a610e..635f06b12 100644 --- a/app/rdf/query-utils.ts +++ b/app/rdf/query-utils.ts @@ -10,7 +10,13 @@ export const buildLocalizedSubQuery = ( s: string, p: string, o: string, - { locale }: { locale: string } + { + locale, + fallbackToNonLocalized, + }: { + locale: string; + fallbackToNonLocalized?: boolean; + } ) => { // Include the empty locale as well. const locales = getOrderedLocales(locale).concat(""); @@ -23,9 +29,10 @@ export const buildLocalizedSubQuery = ( }` ) .join("\n")} - BIND(COALESCE(${locales - .map((locale) => `?${o}_${locale}`) - .join(", ")}) AS ?${o}) + ${fallbackToNonLocalized ? `OPTIONAL { ?${s} ${p} ?${o}_raw }` : ""} + BIND(COALESCE(${locales.map((locale) => `?${o}_${locale}`).join(", ")} ${ + fallbackToNonLocalized ? `, ?${o}_raw` : `` + }) AS ?${o}) `; };