diff --git a/README.md b/README.md index 791fa49..00cfa3f 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ data-values | RDF triples (e.g. a turtle string) to use as existing data graph t data-values-url | When `data-values` is not set, the data graph triples are loaded from this URL data-values-subject | The subject (id) of the generated data. If this is not set, a blank node with a new UUID is created. If `data-values` or `data-values-url` is set, this id is also used to find the root node in the data graph to fill the form data-values-namespace | RDF namespace to use when generating new RDF subjects. Default is empty, so that subjects will be blank nodes. -data-language | Language to use if shapes contain langStrings, e.g. in `sh:name` or `rdfs:label`. Default is [`navigator.language`](https://www.w3schools.com/jsref/prop_nav_language.asp) +data-language | Language to use if shapes contain langStrings, e.g. in `sh:name` or `rdfs:label`. Default is [`navigator.language`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language) with fallback to [`navigator.languages`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages) data-loading | Text to display while the web component is initializing. Default: `"Loading..."` data‑ignore‑owl‑imports | By default, `owl:imports` URLs are fetched and the resulting RDF triples are added to the shapes graph. Setting this attribute to any value disables this feature data-view | When set, turns the web component into a viewer that displays the given data graph without editing functionality @@ -111,7 +111,7 @@ Class hierarchies can be built using `rdfs:subClassOf` or `skos:broader`. ### Validation -In edit mode, `` validates the constructed data graph using the library [rdf-validate-shacl](https://github.com/zazuko/rdf-validate-shacl) and displays validation results as icons next to the respective form fields. +In edit mode, `` validates the constructed data graph using the library [shacl-engine](https://github.com/rdf-ext/shacl-engine) and displays validation results as icons next to the respective form fields. ### Data graph binding @@ -182,7 +182,7 @@ When adding a new attribution, `` renders a dropdown to let the user When binding an existing data graph to the form, the `sh:or` constraint is tried to be resolved depending on the respective data value: - For RDF literals, an `sh:or` option with a matching `sh:datatype` is chosen -- For blank nodes or named nodes, the `rdf:type` of the value is tried to be matched with a node shape having a corresponding `sh:targetClass` or with a property shape having a corresponding `sh:class` +- For blank nodes or named nodes, the `rdf:type` of the value is tried to be matched with a node shape having a corresponding `sh:targetClass` or with a property shape having a corresponding `sh:class`. If there is no `rdf:type` but a `sh:nodeKind` of `sh:IRI`, the id of the the node is used as the value. ### SHACL shape inheritance diff --git a/demo/index.html b/demo/index.html index 45e736a..f1f3cd6 100644 --- a/demo/index.html +++ b/demo/index.html @@ -11,7 +11,7 @@ diff --git a/package.json b/package.json index ad72c1a..7e7485c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ulb-darmstadt/shacl-form", - "version": "1.4.7", + "version": "1.4.8", "description": "SHACL form generator", "main": "dist/form-default.js", "module": "dist/form-default.js", diff --git a/src/config.ts b/src/config.ts index 6d5ef5e..01fcf83 100644 --- a/src/config.ts +++ b/src/config.ts @@ -31,7 +31,7 @@ export class Config { classInstanceProvider: ClassInstanceProvider | undefined prefixes: Prefixes = {} editMode = true - languages: string[] = Array.from(navigator.languages) + languages: string[] dataGraph = new Store() lists: Record = {} @@ -44,6 +44,12 @@ export class Config { constructor(theme: Theme, form: HTMLElement) { this.theme = theme this.form = form + this.languages = [... new Set(navigator.languages.flatMap(lang => { + if (lang.length > 2) { + return [lang, lang.substring(0, 2)] + } + return lang + }))] } updateAttributes(elem: HTMLElement) { @@ -61,12 +67,12 @@ export class Config { this.attributes.valuesSubject = this.attributes.valueSubject } if (atts.language) { - // remove preferred language from list of navigator languages const index = this.languages.indexOf(atts.language) if (index > -1) { + // remove preferred language from the list of languages this.languages.splice(index, 1) } - // now prepend preferred language at start of list of navigator languages + // now prepend preferred language at start of the list of languages this.languages.unshift(atts.language) } }