Skip to content

Instantly share code, notes, and snippets.

@brettz9
Created March 19, 2016 09:34
Show Gist options
  • Save brettz9/181b8a5d5657d444ba74 to your computer and use it in GitHub Desktop.
Save brettz9/181b8a5d5657d444ba74 to your computer and use it in GitHub Desktop.
Sample JSON Schema segment for i18n proposal
{
"localePaths": [
{"#/locales": {
"allowedKeywords": ["title", "enum-titles", "default"]
}},
{"#/localePatterns": {
"order": "l-p-k",
"allowedKeywords": ["pattern"]
}}
],
"locales": {
"en": {
"myContentLanguage": {
"title": "My content language",
"enum-titles": ["German", "Italian", "Spanish"]
},
"myContentLanguageDirection": {
"title": "My content language direction",
"enum-titles": ["Right to left", "Left to right"]
},
"myContentLanguages": {
"title": "My content languages",
"default": ["de", "es"]
}
},
"fr": {
"myContentLanguage": {
"title": "Ma langue de contenu",
"enum-titles": ["allemande", "italienne", "espagnol"]
},
"myContentLanguageDirection": {
"title": "Mon sens de la langue du contenu",
"enum-titles": ["De droite à gauche", "De gauche à droite"]
},
"myContentLanguages": {
"title": "Mes langues de contenu",
"default": ["it", "es"]
}
}
},
"localePatterns": {
"en": {
"pattern": {
"aStoryInMyLanguage": "[\\w ]+"
}
},
"fr": {
"pattern": {
"aStoryInMyLanguage": "[\\w àâäèéêëîïôœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ]*"
}
}
},
"type": "object",
"properties": {
"my-books": {
"type": "object",
"properties": {
"content": {
"type": "string",
"languages": {
"property": "#/properties/my-books/properties/my-content-language"
},
"direction": {
"property": "#/properties/my-books/properties/my-content-language-direction"
}
},
"other-content": {
"type": "string",
"languages": ["en", "fr"]
},
"my-content-language": {
"type": "string",
"format": "language-tag",
"enum": ["de", "it", "es"],
"localeKey": "myContentLanguage"
},
"my-content-language-direction": {
"type": "string",
"format": "language-direction",
"enum": ["R", "L"],
"localeKey": "myContentLanguageDirection"
},
"my-content-languages" : {
"type": "array",
"items": { "$ref": "#/properties/my-content-language" },
"localeKey": "myContentLanguages"
},
}
},
"a-story-in-my-language": {
"title": "A story in my language",
"type": "string",
"localeKey": "aStoryInMyLanguage"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment