describo / crate-builder-component

A VueJS UI component to build an RO-Crate
MIT License
6 stars 3 forks source link

Add 'label' and 'help' to profile classes #53

Closed beepsoft closed 8 months ago

beepsoft commented 1 year ago

Currently classes are defined with these 3 properties in a Describo Profile:

"classes": {
    "Dataset": {
        "definition": "override",
        "subClassOf": [],
        "inputs": [
            ... the properties a user can associate to this class
        ]
    }
}

The crate builder component then uses the class's name as found as the key in classes. For example, this raw class name is displayed in the context entity browser.

image

It would be great if we were able to specify a - translatable - label and help text for classes the same way we can for fields (inputs).

For example:

"classes": {
    ...
    "geographicCoverage": {
        "label": "Geographic coverage",
        "help": "Geographic details of the dataset",
        "definition": "override",
        "subClassOf": [],
        "inputs": [
            ... the properties a user can associate to this class
        ]
    }
}

Whenever the class's name is to be displayed to the user, the component would use the label if available, and falls back to the class's name if it is not. The help text could be shown, for example, whenever hovering the name of the class or some other places in the future.

marcolarosa commented 1 year ago

I've been meaning to document our email chat here:

Yes - that's all find and sounds good. Those properties are not currently used and describo does not validate the profile so having them there is ok. It's a good idea - something to come back to in time.

marcolarosa commented 1 year ago

@beepsoft

Please take a look at https://github.com/describo/crate-builder-component/tree/implementing-profile-translations

This branch is a proof of concept for supporting localisation in the profiles. In the screenshot the second type for Author is 'Hombre' and the type for date is "When it happened". This is defined in a translations property in the profile. This example uses the blank crate and "Profile with all primitive and no groups".

Screenshot 2023-09-26 at 8 48 05 am

We could just have a label on each class in the profile but then we would also need to define translations for the primitives like Text and Date somewhere which is why I've added this translations property.

What do you think?

If you don't want to translate the primitives then having a label on the class definition is a nicer solution I think.

beepsoft commented 1 year ago

Yes, I agree, this is a better approach. With the "translations" we can translate class names that are defined outside of the profile (practically in schema.org). The only thing that maybe confusing is that "translations" is just too broad, maybe use "classTranslations" to make it more specific?

marcolarosa commented 1 year ago

I agree that translations is too broad but I'm not sold on classTranslations because it can be used to translate anything (classes and type primitives for now but who maybe other things). How about "localisation"?

beepsoft commented 1 year ago

Or maybe a structured thing?

{
  "localization": {
     "classes": {
       "Text": "Szöveg"
    }
  }
}
marcolarosa commented 1 year ago

That will make the code a little more complex:

https://github.com/describo/crate-builder-component/blob/implementing-profile-translations/src/crate-builder/profile-manager.js#L224-L226

At the moment it's very simple. Any type or class or whatever, if found as a key in the localisation property will return the value otherwise the lookup key.

beepsoft commented 1 year ago

I see. Ok, this is fine for me for now and it will work until there's no name clash between class names and other localizable items later.

marcolarosa commented 1 year ago

ok. I'll create a release with this tomorrow.

marcolarosa commented 8 months ago

Done!