Change radios into select for more then 5 languages

hass - January 1, 2008 - 16:22
Project:Drupal
Version:6.x-dev
Component:locale.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

If there are more then 5 languages on a website the user fieldset "Language settings" in "user/x/edit" becomes a very big radio list. This patch changes the "radios" to a "select" if there are more then 5 languages defined.

This is the same way how i10_server/community works :-).

AttachmentSize
locale_select_gt_5_radios.patch679 bytes

#1

hass - January 1, 2008 - 17:07

Found one more...

AttachmentSize
locale_select_gt_5_radios.patch 1.51 KB

#2

Gábor Hojtsy - January 2, 2008 - 12:14
Status:needs review» fixed

Fixed the second case in the patch to say <= 5 (it said <= 4), and committed that, thanks.

#3

hass - January 2, 2008 - 17:09
Status:fixed» reviewed & tested by the community

No, this is wrong... in the second case the number 4 was correct. In the first - 5 is correct. With 4 - the English language is not in the language array and is added extra. Therefor your change cause now to show the select only if your site have 6 languages (including english)...

See here - this requires the number "4":
'#options' => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages),

#4

Gábor Hojtsy - January 2, 2008 - 19:17
Status:reviewed & tested by the community» needs work

Hm, actually from the looks of the code, *two* additional language options are added, not one. Right?

#5

hass - January 2, 2008 - 20:21

Yes, but $languages contains an array of languages without 'en' => t('English (provided by Drupal)')). Check it out :-). The patch switches to select box if you have 5 languages, what are 6 radios... 5 languages + 1 item with "all languages". i tried to switch after 5 languages to select box and not after 5 radio items. Looks better and is more consistent in UI.

AttachmentSize
language_search_string.png 5.33 KB

#6

Gábor Hojtsy - January 2, 2008 - 20:53

Uh. It does not contain English, and it adds one more, so that's why we should do <= 3 to have the same effect: dropdown if more then 5 options, right?

#7

hass - January 2, 2008 - 22:34

Well, we could do this at 3, if we'd like to switch at 5 radio items, but i think we should only change to select if more then "5 languages" as we do in l10_server and on the user/x/edit form. I know it's an exception to the switch at 6 radio items, but i think this is more consistent not to sum up the "all language" item together with the 5 active languages... i leave this to you.

#8

Gábor Hojtsy - January 2, 2008 - 22:49
Status:needs work» fixed

OK, committed a fix to have this at 3 + 2 = 5 options (not 5 languages). BTW l10n_server does the switch after 3 languages already, so it is not a good reference :) Also, core should not adhere to contrib module practices, when it comes to consistency, and we can do better here.

#9

hijas - January 14, 2008 - 09:22

i want to set my languages in select box..... plz help... iam using arabic and english language

#10

Anonymous (not verified) - January 28, 2008 - 09:31
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.