[openstreetmap/openstreetmap-website] Add yalphabetize for yaml normalisation (PR #3459)
Andy Allan
notifications at github.com
Tue Feb 15 14:59:38 UTC 2022
Thanks @samrjenkins for the PR, I like the idea of having consistency in ordering in our en.yml file. It's something that I try to do when I'm adding new keys, but without any linting it's hard to maintain (and unreasonable to ask other people to follow undocumented manual ordering). So I'm happy to add something like yalphabetize.
But I think the "consistency in ordering" is more important than "strictly alphabetical". For example, you ask:
> Do you think there is much advantage in having the rails translations at the top?
Yes, I do. There are around 5 top-level keys that are used globally and are not related to controllers. So we put them at the top of the file. I think that makes the layout more logical than having e.g. the globally-useful "helpers" translations in among the controllers.
But this principle also extends to other keys. I would prefer the controller method names (the second-level keys, for most top level keys) to follow a specific order (e.g. `index show new create edit update destroy`) so that they (hopefully) match what is found in the controller files. And I would like for the view-related keys (usually the third/final level key) that they are alphabetical, except I always like to put `title` first.
I saw in the yalphabetize documentation that we can configure the order, but only for complete sets.
> numbers_extended:
> \# The keys in this mapping do not match an allow order or a subset of an allowed order (notice the extra `zero` key which does not appear in the allowed order of numbers).
> \# They are ordered alphabetically.
> one: 1
> three: 3
> two: 2
> zero: 0
If we could have something similar but where members of a configured set come first, in that order, and then everything else comes after, in alphabetical order, I think that might be perfect, e.g.:
> ordered_first
> \- [html activerecord helpers time datetime]
> \- [index show new create edit update destroy]
> \- [title]
> users:
> index: ...
> update: ...
> anything: ...
> else: ...
> in: ...
> order: ...
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3459#issuecomment-1040373207
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/3459/c1040373207 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20220215/9201fd17/attachment.htm>
More information about the rails-dev
mailing list