-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added etymology field to translation schema, specified required/optio…
…nal properties for words
- Loading branch information
1 parent
4f79757
commit 7e0df00
Showing
3 changed files
with
78 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
from glob import iglob | ||
import tomllib | ||
from jsonschema import validate | ||
from jsonschema import validate, Draft7Validator, ValidationError | ||
import json | ||
import sys | ||
|
||
sys.tracebacklimit = 0 | ||
|
||
if __name__ == "__main__": | ||
for path in iglob("../../**/*.toml", recursive=True): | ||
with open(path, 'rb') as file: | ||
try: | ||
print(f"Checking {file.name}...") | ||
data = tomllib.load(file) | ||
|
||
if "translations" in path: | ||
with open("../../schemas/translation.schema.json") as schema: | ||
print(f"Checking translation schema for {file.name}...") | ||
validate(data, json.load(schema)) | ||
except tomllib.TOMLDecodeError as e: | ||
print(e) | ||
for path in iglob("../../**/*.toml", recursive=True): | ||
with open(path, "rb") as file: | ||
try: | ||
print(f"Checking {file.name}...") | ||
data = tomllib.load(file) | ||
|
||
if "translations" in path: | ||
with open("../../schemas/translation.schema.json") as schema: | ||
print(f"Checking translation schema for {file.name}...") | ||
validate( | ||
instance=data, | ||
schema=json.load(schema), | ||
format_checker=Draft7Validator.FORMAT_CHECKER, | ||
) | ||
except tomllib.TOMLDecodeError as e: | ||
print(e) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://linku.la/sona/schemas/translation.schema.json", | ||
"title": "sona Translation file", | ||
"description": "Localized metadata for a Toki Pona word", | ||
"type": "object", | ||
"properties": { | ||
"def": { | ||
"description": "The definition of the word", | ||
"type": "string" | ||
"additionalProperties": { | ||
"properties": { | ||
"commentary": { | ||
"description": "Extra information regarding the word", | ||
"type": "string" | ||
}, | ||
"def": { | ||
"description": "The definition of the word", | ||
"type": "string" | ||
}, | ||
"etymology": { | ||
"description": "Information about the word's origin through other languages", | ||
"items": { | ||
"properties": { | ||
"alt": { | ||
"description": "The \"word\" field transliterated in Latin characters", | ||
"type": "string" | ||
}, | ||
"definition": { | ||
"description": "The definition of the word in its origin language", | ||
"type": "string" | ||
}, | ||
"language": { | ||
"description": "The word's origin language", | ||
"type": "string" | ||
}, | ||
"word": { | ||
"description": "The word written out in its original script", | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object", | ||
"required": ["language"], | ||
"additionalProperties": false | ||
}, | ||
"type": "array" | ||
}, | ||
"sitelen_pona_etymology": { | ||
"description": "The etymology of the word's sitelen pona glyph", | ||
"type": "string" | ||
} | ||
}, | ||
"commentary": { | ||
"description": "Extra information regarding the word", | ||
"type": "string" | ||
}, | ||
"sitelen_pona_etymology": { | ||
"description": "The etymology of the word's sitelen pona glyph", | ||
"type": "string" | ||
} | ||
"type": "object", | ||
"required": ["def"], | ||
"additionalProperties": false | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export type Translation = { | ||
[word: string]: { | ||
def: string; | ||
commentary: string; | ||
sitelen_pona_etymology: string; | ||
etymology: Array<{ | ||
language: string; | ||
word: string; | ||
alt: string; | ||
definition: string; | ||
}>; | ||
}; | ||
}; |