from ordereddict import OrderedDict things_list=db().select(db.ref_thing.id, db.ref_thing.thing) things = [] if T.accepted_language.split('-')[0] == 'en': for r in things_list: things.append((en_ui_tables_names[r.thing],r.id, r.thing)) things.sort(key=lambda x: x[0].lower()) elif T.accepted_language.split('-')[0] == 'fr': for r in things_list: things.append((T(en_ui_tables_names[r.thing]),r.id, r.thing)) things.sort(key=lambda x: x[0].lower()) thing_names_dict = OrderedDict()
Then BUILD A ORDERED DICT, So, I can loop over my ordered dict like if it was a list and just use one variable... :) Richard On Thu, Jul 19, 2012 at 4:10 PM, Richard Vézina <ml.richard.vez...@gmail.com > wrote: > Is T.accepted_language could be empty? > > Richard > > > On Thu, Jul 19, 2012 at 4:08 PM, Richard Vézina < > ml.richard.vez...@gmail.com> wrote: > >> I read about it, but I wasn't sure if it contain the first prefered >> language set in the browser of visitor... >> >> But I think, it's what I was searching for. >> >> Thanks Bruno! >> >> Richard >> >> >> On Thu, Jul 19, 2012 at 3:17 PM, Bruno Rocha <rochacbr...@gmail.com>wrote: >> >>> *T.accepted_languag*e does not helps? >>> >>> On Thu, Jul 19, 2012 at 3:59 PM, Richard Vézina < >>> ml.richard.vez...@gmail.com> wrote: >>> >>>> Hello, >>>> >>>> I need to render a form with ordered input label in alphabetic order >>>> base on the browser language, so I thought that that I could get the user >>>> setted browser languages from request.env.http_accept_language in order to >>>> determine which sorted label to return, >>>> but request.env.http_accept_language returns a string which as far as I >>>> understand is a list of tuples. >>>> >>>> Do the browser accepted language are in order of preference >>>> in request.env.http_accept_language?? >>>> >>>> I would like to do something like this : >>>> >>>> if request.env.http_accept_language == 'en': >>>> ... >>>> elif request.env.http_accept_language == 'fr': >>>> ... >>>> >>>> So, is there an other environnement variable that can help me more then >>>> having to split request.env.http_accept_language?? >>>> >>>> Thanks. >>>> >>>> Richard >>>> >>>> -- >>>> >>>> >>>> >>>> >>> >>> -- >>> >>> >>> >>> >> >> > --