Support (input of) translations #359

Open
opened 2025-09-11 07:37:38 +00:00 by mih · 3 comments
mih commented 2025-09-11 07:37:38 +00:00 (Migrated from github.com)

ATM this is not easily doable. This could be framed as being able to provide "contextual overrides" of attribute values. For a translation, the context would be a language. But a non-language-translation use case would be a tuning values for a different target audience, maybe in terms of tagging some information as being "classified".

I see two general approaches:

  1. a generic override or extension mechanism -- for each attribute it is possible to define additional "layers" of values that are qualified with a context identifier (e.g. language:de)
  2. dedicated support for individual attributes (think having description and alt_description that differ in the range. One is a string the other a class (maybe I18NString) that bind that context identifier to the string value.

For (1) a YAML example might look like this

attribute_alternatives:
  language:de:
    dlcommonmx:title:
      Aufwandsentschädigung

but individual properties may be multivalued, and that is complicated to declare for the purpose of validation.

An example for (2) might be

display_label: "Köln"
alt_display_label:
  language:en:
    Cologne

But it is not immediately intuitive to me how multiple translation for multiple values in a multivalued slot would need to be declared in terms of a range specification (use case: translated keywords)

ATM this is not easily doable. This could be framed as being able to provide "contextual overrides" of attribute values. For a translation, the context would be a language. But a non-language-translation use case would be a tuning values for a different target audience, maybe in terms of tagging some information as being "classified". I see two general approaches: 1. a generic override or extension mechanism -- for each attribute it is possible to define additional "layers" of values that are qualified with a context identifier (e.g. `language:de`) 2. dedicated support for individual attributes (think having `description` and `alt_description` that differ in the `range`. One is a `string` the other a class (maybe `I18NString`) that bind that context identifier to the `string` value. For (1) a YAML example might look like this ```yaml attribute_alternatives: language:de: dlcommonmx:title: Aufwandsentschädigung ``` but individual properties may be multivalued, and that is complicated to declare for the purpose of validation. An example for (2) might be ```yaml display_label: "Köln" alt_display_label: language:en: Cologne ``` But it is not immediately intuitive to me how multiple translation for multiple values in a multivalued slot would need to be declared in terms of a `range` specification (use case: translated keywords)
mih commented 2025-11-26 07:17:08 +00:00 (Migrated from github.com)

Second round of thinking about this: I believe the approach with I18NString might be one that works....

We only need I18N for string values. So whenever range is string, it could be changed to I18NString. This would be a class that maps a language identifier (via language:... defined as in github.com/linkml/prefixmaps@ae04eb1b95/src/prefixmaps/data/prefixcc.csv (L1411)) to the internationalized variant of the string.

However, this would complicate the UX in shacl-vue quite a bit, because it forced I18N upon everyone for everything.

However, it is the "same" issue as with intermediate association classes (see https://github.com/psychoinformatics-de/shacl-vue/issues/256). So if we could have the editor "jump" over the I18NString in terms of UX and immediately create it, populated with a default language string, it might just work out good-enough.

So in terms of a data model, a record could look like this:

display_label:
  language:en: Head honcho
  language:de: Obermacker
Second round of thinking about this: I believe the approach with `I18NString` might be one that works.... We only need I18N for `string` values. So whenever `range` is `string`, it could be changed to `I18NString`. This would be a class that maps a language identifier (via `language:...` defined as in https://github.com/linkml/prefixmaps/blob/ae04eb1b95bfacd9e2aa80f761fe7f53ac8cc843/src/prefixmaps/data/prefixcc.csv#L1411) to the internationalized variant of the `string`. However, this would complicate the UX in shacl-vue quite a bit, because it forced I18N upon everyone for everything. However, it is the "same" issue as with intermediate association classes (see https://github.com/psychoinformatics-de/shacl-vue/issues/256). So if we could have the editor "jump" over the `I18NString` in terms of UX and immediately create it, populated with a default language `string`, it might just work out good-enough. So in terms of a data model, a record could look like this: ```yaml display_label: language:en: Head honcho language:de: Obermacker ```
mih commented 2025-11-26 07:40:17 +00:00 (Migrated from github.com)

I think it would make sense to introduce a I18NString to the types schema component.

I think it would make sense to introduce a `I18NString` to the `types` schema component.
jsheunis commented 2025-12-02 13:52:40 +00:00 (Migrated from github.com)

I used the TRR379-ra schema and created a local test case for the work on the AssociationClassEditor in shacl-vue:

index 868ffb0..53c2ede 100644
--- a/src/research-assets/unreleased.yaml
+++ b/src/research-assets/unreleased.yaml
@@ -203,6 +203,9 @@ slots:
     range: uri
     exact_mappings:
       - dcat:landingPage
+
+  language:
+    range: string

   target:
     title: Target
@@ -217,6 +220,18 @@ slots:
     #  - sct:363702006

 classes:
+
+  I18NString:
+    slots:
+      - language
+      - value
+    slot_usage:
+      language:
+        key: true
+      value:
+        annotations:
+          dash:propertyRole: dash:KeyInfoRole
+
   TRR379Accolade:
     is_a: FlatThing
     title: Accolade
@@ -544,6 +559,8 @@ classes:
       - title
     slot_usage:
       title:
+        range: I18NString
+        inlined: true
         annotations:
           sh:order: 1.0
       description:

This generates SHACL:


trr379ra:I18NString a sh:NodeShape ;
    sh:closed true ;
    sh:ignoredProperties ( rdf:type ) ;
    sh:property [ dash:propertyRole dash:KeyInfoRole ;
            sh:datatype xsd:string ;
            sh:description "Value that is a direct representation of a thing." ;
            sh:maxCount 1 ;
            sh:nodeKind sh:Literal ;
            sh:path rdfs:value ],
        [ sh:datatype xsd:string ;
            sh:maxCount 1 ;
            sh:nodeKind sh:Literal ;
            sh:path trr379ra:language ] ;
    sh:targetClass trr379ra:I18NString .

...

trr379ra:TRR379Concept a sh:NodeShape ;
    sh:closed true ;
    sh:ignoredProperties ( rdf:type ) ;
    sh:name "Concept" ;
    sh:property ...
        ...
        [ sh:class trr379ra:I18NString ;
            sh:description "A summarily description of the subject. It is closely related to a `name`, but often less compact and more descriptive. Typically used for documents." ;
            sh:maxCount 1 ;
            sh:nodeKind sh:BlankNodeOrIRI ;
            sh:order 1.0 ;
            sh:path dlcommonmx:title ],

It also produces OWL, but with the following warning:

WARNING:linkml.generators.owlgen:Ambiguous type for: title

Running the owl export command with the verbose flag doesn't expand on this.

When using the updated shacl to drive a local shacl-vue instance (updated to the state described here: https://github.com/psychoinformatics-de/shacl-vue/issues/256#issuecomment-3601772381), this all worked nicely:

https://github.com/user-attachments/assets/6dced5a6-255c-4345-8c8f-a64fd5c3011a

Some configuration functionality will come next, to allow a default language to be set for a deployment.

I used the [TRR379-ra schema](https://hub.trr379.de/q02/concepts.trr379.de/src/branch/main/src/research-assets/unreleased.yaml) and created a local test case for the work on the `AssociationClassEditor` in `shacl-vue`: ```diff index 868ffb0..53c2ede 100644 --- a/src/research-assets/unreleased.yaml +++ b/src/research-assets/unreleased.yaml @@ -203,6 +203,9 @@ slots: range: uri exact_mappings: - dcat:landingPage + + language: + range: string target: title: Target @@ -217,6 +220,18 @@ slots: # - sct:363702006 classes: + + I18NString: + slots: + - language + - value + slot_usage: + language: + key: true + value: + annotations: + dash:propertyRole: dash:KeyInfoRole + TRR379Accolade: is_a: FlatThing title: Accolade @@ -544,6 +559,8 @@ classes: - title slot_usage: title: + range: I18NString + inlined: true annotations: sh:order: 1.0 description: ``` This generates SHACL: ```ttl trr379ra:I18NString a sh:NodeShape ; sh:closed true ; sh:ignoredProperties ( rdf:type ) ; sh:property [ dash:propertyRole dash:KeyInfoRole ; sh:datatype xsd:string ; sh:description "Value that is a direct representation of a thing." ; sh:maxCount 1 ; sh:nodeKind sh:Literal ; sh:path rdfs:value ], [ sh:datatype xsd:string ; sh:maxCount 1 ; sh:nodeKind sh:Literal ; sh:path trr379ra:language ] ; sh:targetClass trr379ra:I18NString . ... trr379ra:TRR379Concept a sh:NodeShape ; sh:closed true ; sh:ignoredProperties ( rdf:type ) ; sh:name "Concept" ; sh:property ... ... [ sh:class trr379ra:I18NString ; sh:description "A summarily description of the subject. It is closely related to a `name`, but often less compact and more descriptive. Typically used for documents." ; sh:maxCount 1 ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order 1.0 ; sh:path dlcommonmx:title ], ``` It also produces OWL, but with the following warning: ``` WARNING:linkml.generators.owlgen:Ambiguous type for: title ``` Running the owl export command with the verbose flag doesn't expand on this. When using the updated shacl to drive a local `shacl-vue` instance (updated to the state described here: https://github.com/psychoinformatics-de/shacl-vue/issues/256#issuecomment-3601772381), this all worked nicely: https://github.com/user-attachments/assets/6dced5a6-255c-4345-8c8f-a64fd5c3011a Some configuration functionality will come next, to allow a default language to be set for a deployment.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
orinoco/concepts#359
No description provided.