Would there be an easy way to sort a drop list of WPML translated countries?
I'm using string translations for the country list.
Thanks
Would there be an easy way to sort a drop list of WPML translated countries?
I'm using string translations for the country list.
Thanks
I did see this topic at the WPML forums:
http://wpml.org/forums/topic/sorting-of-dropdown-menus/
The only chance Gravity Forms would have at sorting the drop down would be after it's translated, with the gform_pre_render filter. I'm not sure how you could go about working with the sorted list of countries.
Would there be a way to use a different country drop down, already pre-sorted, based on the country selection?
I'm using the bulk-add feature to add the country list, then adding an additional "Select a country" item to the top of the drop list.
So i suppose this adds an extra level of complexity to the situation as well.
How many languages are you using? Would it be possible to create a list of countries for each language and display the proper one based on the language selection? This only works without too much trouble if you have just a couple languages. I suppose that does not allow WPMU to do its translation though: you're just providing translated lists of countries for each language. That sort of defeats the purpose of the WPML plugin. But, I can't see another way of doing it without digging in to how WPML translates the drop down and when that actually happens.
I just ran across this filter, not sure if it could be used somehow:
http://www.gravityhelp.com/documentation/page/Gform_countries
Hi Chris,
I think the filter you linked will only work on a list in the custom address form.
Please add a country droplist as a custom field! it would make thing so much easier.
I have 10 languages.
Chris,
I'm going to try a gform_pre_render filter.
Would you have an example function of how i'd sort the drop down choices alphabetically?
Thanks
You can sort the array using the PHP sort function. In the function you use with gform_pre_render, you will read the array of translated countries, which should be out of order (if they were sorted based on US English before WPML did its magic) sort them, then repopulate the drop down with the newly sorted countries. The issue will be with when WPML does its translation. Hopefully it is done before gform_pre_render is called so you can actually see the out of order values and sort them, then use them in the form.
Thanks Chris,
Could you point me to an example of how I'd sort a list alphabetically using form_pre_render?
thanks
bump