You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks very much for assembling the list of languages.
We needed a select tag of common languages, but with English and Spanish shown first. We also wanted to list both Mandarin and Cantonese, and remove the parentheticals. We used iso_639_3 to get a code for Cantonese. Others may find this useful:
# app/application_helper.rbdefour_languages# Fix names, add Cantonese, and bring English and Spanish to the frontLanguageList::COMMON_LANGUAGES.mapdo |language|
[language.name.gsub('Modern Greek (1453-)','Greek').gsub('Tonga (Tonga Islands)','Tongan').gsub('Chinese','Chinese Mandarin'),language.iso_639_3]end.push(['Chinese Cantonese','yue']).sort.promote(%w(Spanishspa)).promote(%w(Englisheng))endclassActionView::Helpers::FormBuilder# http://stackoverflow.com/a/2625727/1935918includeApplicationHelperincludeActionView::Helpers::FormTagHelperincludeActionView::Helpers::FormOptionsHelperdeflanguage_select(name,options={include_blank: true})select_tag"#{@object_name}[#{name}]",options_for_select(our_languages,selected: @object.send(name)),optionsendclassArraydefpromote(promoted_element)returnselfunless(found_index=find_index(promoted_element))unshift(delete_at(found_index))endend
The text was updated successfully, but these errors were encountered:
Thanks very much for assembling the list of languages.
We needed a select tag of common languages, but with English and Spanish shown first. We also wanted to list both Mandarin and Cantonese, and remove the parentheticals. We used
iso_639_3
to get a code for Cantonese. Others may find this useful:The text was updated successfully, but these errors were encountered: