Add langstring support to the metamodel - #276
Open
niegrzybkowski wants to merge 1 commit into
Open
niegrzybkowski wants to merge 1 commit into
niegrzybkowski wants to merge 1 commit into
Conversation
niegrzybkowski
force-pushed
the
LNK-96/multilingual-text
branch
from
September 10, 2026 07:30
dc2ce6c to
0c01159
Compare
|
ping @djarecka @puja-trivedi (also see the linkml playground) |
|
I see how this kind of option could be useful in data holdings. I'll just note that for the schema itself we used the LinkML schema.extensions structure to enable an overlay of all textual content of a schema, such that after loading a schema into an application, a given language overlay can be placed right on top of it to facilitate locale-friendly applications. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue linkml/linkml#3548 and a dozen others
This PR adds the definitions and the documentation of a new
langstringtype which will provide the necessary infrastructure for implementing multi-lingual support for schema metadata. This PR does not yet change the metamodel metadata slots to use the type - buttitleanddescriptionare marked as candidates.Justification
Lack of first class support for multilinguality in LinkML has been a big pain point for us. Adding external tooling would work for now, and I can see it being a useful feature on its own, but this is something that should be enabled by the metamodel, not done in spite of it. Multi-linguality is a hard requirement in the EU, often enforced by law. Web has moved on to being multi-lingual by default: multi-linguality is required by W3C in all standards. For LinkML to be useful for ontology writing, this is badly needed.
Functionality
langstringvalues are a union ofplainstrings (non-language-tagged), andmulti-languagestrings (language tagged, with at least one language).plainstrings are treated as such - they do not specify language information and are assumed to always be something that should be displayed to the user.multi-languagestrings are a mapping of a language tag to the appropriate text, localized in the specified language.Serializations
Copied from the notes:
Examples:
"some text"becomes RDF"some text"^^xsd:string{ "en": "some text", "pl": "jakiś tekst" }becomes RDF"some text"@enand"jakiś tekst"@plRuntime behavior
Copied from the notes:
plain()yields a string that is populated from: (1) the plain text if available, (2) the English text if available, or (3) the text of the alphabetically first language tag.in_language(tag)yields a string that is populated from: (1) the plain text if available, (2) the text of the specified language if available, (3) the English text if available, or (4) the text of the alphabetically first language tag.Rationale for making
langstringa magic typeWe've seen the approaches proposed by linkml-adjacent projects, but we have opted to go for the simplest option that would work for metadata. Given the constraints:
To implement something that would satisfy all of these constraints generically (while allowing it to be used in "regular" schemas as well) would require a lot more effort in the metamodel, which would probably not be useful outside of this specific application. Let's not add 5 new boolean slots for this
Additional context
We have this implemented fully in LinkML-Scala. See the demo in the playground here and the code here
I think an alternative approach would be to make langstrings a magic class like linkml:Any, as opposed to a type, which would preserve the "types are always atomic values" assumption.
Future considerations
I think in_language slot should control the language of the
plainstring, but it would require careful scoping and other considerations for this to work well. This would allow for exampleto mean
"My thing"@enin RDF