-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ARB comments #62
Comments
Ok so two issues here:
The ARB format already supports arbitrary keys prefixed with {
"homeScreenTitle": "",
"@homeScreenTitle": {
"comment": "Some comment"
}
} The
ARB files are just JSON files with an added schema. The autoformatter should just be the JSON formatter, and VS Code at least seems to support retaining blank lines. |
Thank you for the prompt reply! Adding comments to ARB fileIt seems that there is no documented way of adding developer-focused comments / structure to ARB files. When I Googled how to do it, I continuously got suggestions of using To avoid confusion with custom x-fields, I could use for example Whatever the syntax, it would be good it ARB-editor could highlight the comments in a different color so that they would be easier to spot. Supporting empty linesThank you for the pointer. I have Prettier extension installed, and even though it retained one empty line in *.json files, it removed all empty lines in *.arb files. Adding the following
|
Maybe all keys starting with |
Thanks for collecting those examples, which shows this is an issue which should be solved more generally. I would propose One of the examples linked is rather about using comments to separate the ARB file into sections. I can't think of a good solution for that, except splitting up the arb file into several smaller files, or using |
My original use case is actually about segmenting the file, so that it's easier for developers to see what is where. I guess |
To elaborate a bit: I think your suggested comments are a great addition. One of the things I've had pains with other localization formats is the indistinction between descriptions intended for translators and comments intended for developers. Making the file format easier to structure and edit by developers would also be great, and positioned comments / segmenting would assist in that. |
Regarding the structuring, I really think it would be best to have multiple files. The ARB file format, in its current structure, is not made to be structured internally as it consists of top-level messages only. We could discuss adding some sort of structuring as a new feature, but that would probably be a breaking change in the format, and give two different options of structuring. Both those things don't sound great. |
Yes, I agree it would be a significant change. If the structuring is semantic, it would probably mean nesting the keys, which is a big change. For larger scopes using several files is probably best. For small scopes desiring some structure, using a Do you think highlighting |
I personally think that JSON dictionaries (and ARB files as an extension) should not care about ordering, so it feels weird to use comments to format this. But then again, if it works, why not :)
I filed #64. |
Expected Behavior
Most places discussing how to organize and add comments to ARB files suggest the following format for comments:
Currently this produces the error "Metadata for an undefined key" in ARB-editor. This warning can be disabled, but that's less than ideal. I propose ARB-editor should accept this
@_xyz
comment convention and highlight the comment differently from other keys to make it more visible.Also grouping localization strings with empty lines is useful, but ARB-editor autoformat removes all empty lines. I propose it should retain one empty line (possibly with a configuration option how many to retain). (EDIT: Problem was with Prettier extension, solution below)
Specifications
The text was updated successfully, but these errors were encountered: