w3c / w3c/json-ld-syntax

extend language maps to support base direction

Open
#489 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

substantive:class 4
Dominant language
HTML
Stars
139
Forks
23
PR merge metrics
No merged PRs in 30d

Description

currently, language maps in JSON-LD allow to create literals with a language tag, but not with a base direction, which is not good from an i18n point of view.
If you want to to express the title of a book about JSON-LD both in English and Arabic, you need the following (expanded) JSON-LD:

{
    "http://schema.org/title": [
        { "@value": "JSON-LD and Linked Data", "@language": "en", "@direction": "ltr" }
        { "@value": "JSON-LD والبيانات المرتبطة", "@language": "ar", "@direction": "rtl" }
    ]
}

but you can't get this result with a language map.

A workaround is possible by defining different properties with language maps, one for ltr titles, and one for rtl titles (see example in the playground). But that requires contexts designers to provision it.

An alternative would be to extend the expansion algorithm for language maps, to accept a special format in their keys containing both language tag and optionally a base direction. All we need is an encoding which is not ambiguous with valid language tags. A possible separator would be --, which is what Turtle uses. Another possible separator is a space, but it is less YAML-friendly (and actually looks odd, spaces in keys are not usual).

Example:

{
  "@context": {
    "titles": {
      "@id": "http://schema.org/title",
      "@container": "@language",
      "@context": {
        "@direction": "ltr"
      }
    }
  },
  "titles": {
    "en": "JSON-LD and Linked Data",
    "ar--rtl": "JSON-LD والبيانات المرتبطة"
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JSON-LD 1.1 language maps section and its expansion algorithm, then compare the current behavior with the examples in this issue. Define an unambiguous encoding for a language tag with an optional base direction, and update the specification so the example produces expanded values containing both @language and @direction while ordinary language-map keys continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.