To help read and write fluent fragments in the IDE, it would be helpful to have syntax highlighting. I was able to get partial support via this approach:
Add this JSON schema file to the repo:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "i18n-a11y.schema.json",
"title": "i18n a11y Fluent injections",
"allOf": [ { "$ref": "#/$defs/node" } ],
"$defs": {
"injectString": {
"type": "string",
"x-intellij-language-injection": {
"language": "Fluent",
"prefix": "tmp = "
}
},
"a11yNode": {
"anyOf": [
{ "$ref": "#/$defs/injectString" },
{
"type": "object",
"additionalProperties": { "$ref": "#/$defs/a11yNode" }
},
{
"type": "array",
"items": { "$ref": "#/$defs/a11yNode" }
}
]
},
"node": {
"anyOf": [
{
"type": "object",
"properties": {
"a11y": { "$ref": "#/$defs/a11yNode" }
},
"additionalProperties": { "$ref": "#/$defs/node" }
},
{
"type": "array",
"items": { "$ref": "#/$defs/node" }
},
{ "type": ["string","number","boolean","null"] }
]
}
}
}
Use the JSON schema associator to associate the yaml with this json schema. Enable language injection plugin (IntelliLang, I think), Enable Fluent plugin.
Then it looks like this:
It correctly matches braces and uses fluent syntax on those fragments.
See how it matches braces:
However, it lists our custom syntax { a11y.gameScreen.myText } as a parse error since that is not part of fluent, and it does not handle multilines (a string constant that spans 2 lines with yaml |- syntax), and it reformats oddly. So I don't know how to move forward with it at this time, just wanted to leave a note in case we can overcome these flaws in the future.
To help read and write fluent fragments in the IDE, it would be helpful to have syntax highlighting. I was able to get partial support via this approach:
Add this JSON schema file to the repo:
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "i18n-a11y.schema.json", "title": "i18n a11y Fluent injections", "allOf": [ { "$ref": "#/$defs/node" } ], "$defs": { "injectString": { "type": "string", "x-intellij-language-injection": { "language": "Fluent", "prefix": "tmp = " } }, "a11yNode": { "anyOf": [ { "$ref": "#/$defs/injectString" }, { "type": "object", "additionalProperties": { "$ref": "#/$defs/a11yNode" } }, { "type": "array", "items": { "$ref": "#/$defs/a11yNode" } } ] }, "node": { "anyOf": [ { "type": "object", "properties": { "a11y": { "$ref": "#/$defs/a11yNode" } }, "additionalProperties": { "$ref": "#/$defs/node" } }, { "type": "array", "items": { "$ref": "#/$defs/node" } }, { "type": ["string","number","boolean","null"] } ] } } }Use the JSON schema associator to associate the yaml with this json schema. Enable language injection plugin (IntelliLang, I think), Enable Fluent plugin.
Then it looks like this:
It correctly matches braces and uses fluent syntax on those fragments.
See how it matches braces:
However, it lists our custom syntax
{ a11y.gameScreen.myText }as a parse error since that is not part of fluent, and it does not handle multilines (a string constant that spans 2 lines with yaml|-syntax), and it reformats oddly. So I don't know how to move forward with it at this time, just wanted to leave a note in case we can overcome these flaws in the future.