wcm_lang_switch icon indicating copy to clipboard operation
wcm_lang_switch copied to clipboard

Sort languages according to user preferences

Open thefuxia opened this issue 12 years ago • 10 comments

When there are many languages installed, the menu should be sorted like this:

  1. Last used before current selection
  2. Second last used
  3. And so on.
  4. Parse the Accept-Language header and order all matching available languages according to the preference expressed by its numerical value. q=1 should be first, q=0.9 the next and so on. q=0 should be the last in the complete list.
  5. Sort everything else alphabetically.

thefuxia avatar Feb 23 '13 07:02 thefuxia

I'm not at home currently, and my laptop sucks for developing. I have a nice class for Accept-Header parsing at home that you could use for 4. Will send a pull request when I'm back.

thefuxia avatar Feb 23 '13 07:02 thefuxia

Nice idea. Will try to get over some of the issues this weekend. Thanks :)

franz-josef-kaiser avatar Feb 23 '13 16:02 franz-josef-kaiser

Just wanted to ask about the status of this enhancement.

franz-josef-kaiser avatar Jun 12 '13 14:06 franz-josef-kaiser

status: forgotten :)

thefuxia avatar Jun 12 '13 14:06 thefuxia

Where the hell is the +1 button when you need it ;)

franz-josef-kaiser avatar Jun 12 '13 14:06 franz-josef-kaiser

What, you mean this? :+1:

stephenharris avatar Jun 12 '13 14:06 stephenharris

Anyway, I think only remember 1-2 previous choices. If you're flicking between languages (in no particular order) its not helpful to have them all listed by 'last used'. So current at the top - then last used (1-2 languages)- then the rest sorted alphabetically.

Each section should be separated by a line to make the sorting more apparent. Perhaps even label the second section 'last used'?

stephenharris avatar Jun 12 '13 14:06 stephenharris

We could build upon this idea: Maybe add a check and only move this in if someone got 5+ or 10+ language files installed? Or maybe we could add a capability check, so it only behaves like this for the admin/super-admin user as those will likely be the developer?

franz-josef-kaiser avatar Jun 12 '13 14:06 franz-josef-kaiser

@toscho Status: Forgotten again :)

Anyway, do you still have the class laying around somewhere? I'd already be happy about a Gist to see what we are talking about.

franz-josef-kaiser avatar Jan 27 '15 14:01 franz-josef-kaiser

See Mlp_Accept_Header_Parser and Mlp_Language_Negotiation. This could be adjusted. Maybe I should make thios more abstract in MultilingualPress too.

thefuxia avatar Mar 17 '15 07:03 thefuxia