Skip to content

Add blog post on making JSON strings work for every language#2407

Open
xfq wants to merge 5 commits into
json-schema-org:mainfrom
xfq:string-meta
Open

Add blog post on making JSON strings work for every language#2407
xfq wants to merge 5 commits into
json-schema-org:mainfrom
xfq:string-meta

Conversation

@xfq

@xfq xfq commented Jun 3, 2026

Copy link
Copy Markdown

What kind of change does this PR introduce?

A new blog post.

Issue Number:

Screenshots/videos:

If relevant, did you update the documentation?

Summary

JSON is a very successful data format, but its string type is very simple. A value such as a title and name often needs more than Unicode characters. Consumers may need to know the language of the text and its direction, e.g., when displaying right-to-left scripts such as Arabic or Hebrew. Without that metadata, applications fall back to guessing, and guessing often fails.

The W3C Internationalization Working Group has a document on this topic: Strings on the Web: Language and Direction Metadata, which is a practical guide for specifications and formats that exchange strings. This is a blog post about the best practice.

Does this PR introduce a breaking change?

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

@xfq xfq requested a review from a team as a code owner June 3, 2026 03:15
@github-project-automation github-project-automation Bot moved this to Ready to review in PR - Triage Group Jun 3, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 10615ef

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0effebe) to head (551dd74).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2407   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          672       672           
  Branches       211       211           
=========================================
  Hits           672       672           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vtushar06

Copy link
Copy Markdown
Collaborator

Hey @Utkarsh-123github, what do you think about this post?

@gregsdennis gregsdennis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any really wrong with the post or its content. Just a few minor editorial suggestions.

I do have a concern that this is only tangentially related to JSON Schema, though.

Comment thread pages/blog/posts/making-json-strings-work-for-every-language.md Outdated
}
```

The document recommends `language` for a resource-wide default language field and `direction` for a resource-wide default direction field. For localizable text objects, the examples use `lang` and `dir`, which align naturally with HTML attributes when the value is eventually displayed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON and HTML don't need to be kept in alignment. If the recommendation is for language and direction, it might be better to keep with that rather than to introduce an unnecessary association.

If the HTML/JSON alignment is warranted, an aside explaining why would be good.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread pages/blog/posts/making-json-strings-work-for-every-language.md

@jdesrosiers jdesrosiers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do have a concern that this is only tangentially related to JSON Schema, though.

I see this as promoting best practices for schema authors, which I think is a great thing to include in this blog. But, I'd like to see a little more in the post giving guidance on how to apply these concepts using JSON Schema.

There are three patterns described in this post and you've only given a schema for one of them. I'd like to see schemas for all three patterns and examples of how to use them in a data structure the schema author is designing.

For example, the localizable text schema,

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://exampe.com/localizable-text",

  "type": "object",
  "properties": {
    "value": { "type": "string" },
    "lang": { "type": "string" },
    "dir": { "enum": ["ltr", "rtl", "auto"] }
  },
  "required": ["value"]
}

And an example of using it,

{
  "type": "object",
  "properties": {
    "title": { "$ref": "https://example.com/localizable-text" }
  }
}

Then the global settings pattern,

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://exampe.com/global-localization",

  "type": "object",
  "properties": {
    "language": { "type": "string" },
    "direction": { "enum": ["ltr", "rtl", "auto"] }
  }
}

And an example of using it,

{
  "$ref": "https://example.com/global-localization",
  "properties": {
    "name": { "type": "string" },
    "description": { "type": "string" },
    "alternateTitle": { "$ref": "https://example.com/localizable-text" }
  }
}

Then the language map pattern,

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/language-map",

  "type": "object",
  "patternProperties": {
    "[a-z][a-z]": { "$ref": "https://example.com/localizable-text" }
  }
}

And an example of using it,

{
  "type": "object",
  "properties": {
    "title": { "$ref": "https://example.com/language-map" }
  }
}

I think incorporating something like that would make this a more useful resource for schema authors.

Comment thread pages/blog/posts/making-json-strings-work-for-every-language.md
@jdesrosiers

Copy link
Copy Markdown
Member

@jviotti I think there are several reusable structures here that could be a useful addition to your schema registry.

@xfq

xfq commented Jun 16, 2026

Copy link
Copy Markdown
Author

Thanks for the suggestions! I updated the blog post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready to review

Development

Successfully merging this pull request may close these issues.

New blog post, Making JSON Strings Work for Every Language

4 participants