Open klonos opened 2 years ago
Noting that there is this follow-up issue in d.o: https://www.drupal.org/project/drupal/issues/3069844. It is to add other useful functionality to select FAPI elements, such as '#sort_direction'
, '#sort_natural'
, '#sort_end'
, and '#sort_unique'
. I believe that the direction one at the very least should be implemented, as it seems like a no-brainer.
This is effectively to implement the same feature that went into Drupal core v8.8.x with https://www.drupal.org/project/drupal/issues/3065903 (change record: Options sorting ability has been added to Select form element)
Consider this code:
This would result in a select element in the form, with its options listed alphabetically, but with the "nothing" option being first (intentionally not included in the sorting):
Now consider the translations of the options in Greek: "Nothing" → "Τίποτα" "Another thing" → "Κάτι άλλο" "One thing" → "Κάτι" "Yet another thing" → "Κάτι ακόμη"
Actual order (not alphabetical, because the sorting has happened in
asort()
for the English strings 👎🏼 ):Expected order (properly alphabetical, in the translated language - not according to the source language):
How things should work ideally: