Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have ordered the terms of my vocabulary alphabetically.
I use localize terms for translation.
The terms are translated correctly and are in the same order as the default language.
As a result the translated terms are not listed alphabetically.
How can I fix this?
Maybe I should submit this issue at another module?
Thanks in advance!
Comments
Comment #1
alesand CreditAttribution: alesand commentedI have solved this problem in my case (6.x-1.0) by making some changes in /i18n/i18ntaxonomy/i18ntaxonomy.module:
And thanks for i18n!
Comment #2
tomsm CreditAttribution: tomsm commentedYes, that worked! Thank you very much, alesand.
After I updated the i18taxonomy module with update.php everything was alphabetical for each language.
I think that this feature should be included in the module.
Comment #3
tomsm CreditAttribution: tomsm commentedHi alesand,
My menu is alphabetical. But when I create a node that uses this vocabulary, the items are sorted alphabetically without keeping their parent-child hierarchy in the edit node screen. For example I have:
parent item 1
- child 1
- child 2
parent item 2
- child 1
- child 2
it becomes:
- child 1
- child 1
- child 2
- child 2
parent 1
parent 2
Can you fix this?
Comment #4
magoo CreditAttribution: magoo commentedhello,
There is also a jQuery solution. As the other solution, it does not support hierarchical taxonomies.
However, sorting with any of those methods is weird because it short circuits the weights an administrator could give by ordering the terms.
At least, this solution avoids hacking the modules.
This is inspired by somebody else's webpage. I'll add the ref, when I find it again.
NOTE: the
.not('#edit-taxonomy-X')
is used to avoid applying on some taxonomies.Comment #5
tomsm CreditAttribution: tomsm commentedThanks for the tip. But where do I add this code?
Comment #6
magoo CreditAttribution: magoo commentedin your theme's page.tpl.php
in a <script type="text/javascript"></script>
BR
Comment #7
Kars-T CreditAttribution: Kars-T commentedThis was inactive over a year so I am closing this.
Comment #8
HakS CreditAttribution: HakS commentedHello,
I'm trying to get this code to work on D7 version but I couldn't
This is the code:
Comment #9
Jose Reyero CreditAttribution: Jose Reyero commentedSince this may be an array of objects, maybe we need some sorting function, see http://es.php.net/manual/es/function.usort.php
And we should be sorting only when the previous array (before translating) is oredered alphabetically, so we need some extra options here.
Comment #10
Cyclodex CreditAttribution: Cyclodex commentedQuestion: I tried to discover what this code should fix, but somehow the whole function is not reflecting any changes for my site. Don't understand it exactly what's going on...
What I could fix for now is my exposed filters in views, see #1312074: Sort exposed translated filters by their value. with a hook_form_alter().
But I think this solution is not the correct one, we should try to fix this more generally when generating the term list. But somehow I do understand the things not good enough, so for now could not find a way how and especially where we should fix this.
i18n_taxonomy ?
i18n_views ?
Could it be that this code here is not working for me due I am using i18n_views ?
So then I would have to contact i18n_views team for some help...
I would like to help out whit this case, but would be nice to get some feedback to get me back on track :)
Regards Cyclodex
Comment #11
Cyclodex CreditAttribution: Cyclodex commentedDue this seems to be hard to fix I just wanted to note, that I implemented some other hook_form_alter() to order all my select and checkboxes fields, finally I got a correct ordered list in a foreign language.
So the problem is done for me with this workaround.
Comment #12
Jose Reyero CreditAttribution: Jose Reyero commentedMoving to the right component
Comment #13
A.Kotov CreditAttribution: A.Kotov commentedHi, is there any chance this happens for 7 ? ))
Comment #14
nerdcore CreditAttribution: nerdcore commentedAlthough the suggestion in #11 sounds sensible for forms, I'm having an issue where displaying a localized taxonomy in the node display shows a secondary-language list in the primary language's sort order. Also the primary language doesn't appear sorted properly itself (this is clearly not an i18n-specific issue).
This issue is nearly 5 years old. I was going to submit a patch which would address the form display suggested in #11 but I'm unsure how to affect other places where this sort is incorrect, such as node display list of terms.
Any suggestion on how to order the terms as displayed by the Views module?
I still need forms sorted alphabetically using a localized taxonomy as well.
Comment #15
nerdcore CreditAttribution: nerdcore commentedComment #16
nerdcore CreditAttribution: nerdcore commentedI've confirmed I am still experiencing primary-language sort order on secondary language lists in 7.x-1.x-dev.
Comment #17
nerdcore CreditAttribution: nerdcore commentedAdding this related issue in case someone finds it useful:
#2283537: I18n of taxonomy in exposed filter : translations and orders
Comment #18
jasom CreditAttribution: jasom commentedIs there any progress? This is similar issue from i18n_views #1645304: Sort by "Taxonomy term: Name (translated)" field
Comment #19
noah CreditAttribution: noah as a volunteer commentedHere's a quick and dirty solution to sorting based on translated term name in Views. Doesn't require i18n_views, but does use transliteration (though it could be easily modified to work without if it's not required). This is the "Style output" template: