Skip to content

localizesh/schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Localize.sh Schema

This repository contains the JSON Schema definition for the Localize.sh toolchain. This schema defines the data structures for parsing, processing, and stringifying localization resources.

Schema File

schema.json contains all schema definitions:

  • Document: Represents a parsed resource file (AST + segments)
  • Segment: A single translatable text unit with support for inline tags and attributes
  • Tag: Attributes for tag markers within segments
  • ParseRequest / ParseResponse: Contracts for the Parse operation
  • StringifyRequest / StringifyResponse: Contracts for the Stringify operation

Usage

These definitions are intended to be used with a CLI-based toolchain where processors read JSON messages from stdin and write to stdout.

Data Flow

  1. Parse: ParseRequest (stdin) -> Processor -> ParseResponse (stdout)
  2. Stringify: StringifyRequest (stdin) -> Processor -> StringifyResponse (stdout)

Definitions

Segment

A single unit of text for translation.

Properties:

  • id (string, required): Unique identifier for the segment
  • text (string, required): The content string, which may contain placeholder tags (e.g., Hello {a1}World{/a1})
  • tags (object, optional): A map of tag definitions corresponding to markers in the text

Example:

{
  "id": "a3f8d9c2e1b7456789abcdef01234567",
  "text": "Welcome to {a1}Localize.sh{/a1}!",
  "tags": {
    "a1": {
      "href": "https://localize.sh"
    }
  }
}

Tag

A tag is a simple object containing key-value pairs of attributes.

Example:

{
  "href": "https://example.com"
}

Document

A generic representation of a resource file.

Properties:

  • segments (array, required): A list of translatable units found in the file
  • layout (object, required): The Abstract Syntax Tree (AST) or structural representation of the original file
  • metadata (object, optional): Optional file-level metadata

Example:

{
  "segments": [
    {
      "id": "5d41402abc4b2a76b9719d911017c592",
      "text": "Hello World"
    }
  ],
  "layout": {
    "type": "root",
    "children": [
      { "type": "segment", "id": "5d41402abc4b2a76b9719d911017c592" },
      { "type": "text", "value": "!" }
    ]
  },
  "metadata": {
    "version": "1.0",
    "locale": "en-US"
  }
}

License

Apache 2.0

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published