PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Gravity & WPML alphabetic sort of translated country list?

  1. 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

    Posted 12 years ago on Wednesday October 31, 2012 | Permalink
  2. 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?

    Posted 12 years ago on Wednesday October 31, 2012 | Permalink
  3. 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.

    Posted 12 years ago on Wednesday October 31, 2012 | Permalink
  4. 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.

    Posted 12 years ago on Thursday November 1, 2012 | Permalink
  5. I just ran across this filter, not sure if it could be used somehow:

    http://www.gravityhelp.com/documentation/page/Gform_countries

    Posted 12 years ago on Thursday November 1, 2012 | Permalink
  6. 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.

    Posted 12 years ago on Thursday November 1, 2012 | Permalink
  7. 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

    Posted 12 years ago on Thursday November 1, 2012 | Permalink
  8. 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.

    Posted 12 years ago on Wednesday November 7, 2012 | Permalink
  9. Thanks Chris,

    Could you point me to an example of how I'd sort a list alphabetically using form_pre_render?

    thanks

    Posted 12 years ago on Saturday November 17, 2012 | Permalink
  10. bump

    Posted 12 years ago on Thursday November 22, 2012 | Permalink