[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #12773 [BridgeDB]: Be more flexible when deciding if we should render RTL



#12773: Be more flexible when deciding if we should render RTL
-----------------------------+----------------------------
     Reporter:  cypherpunks  |      Owner:  isis
         Type:  defect       |     Status:  closed
     Priority:  normal       |  Milestone:
    Component:  BridgeDB     |    Version:
   Resolution:  not a bug    |   Keywords:  bridgedb-https
Actual Points:               |  Parent ID:
       Points:               |
-----------------------------+----------------------------
Changes (by isis):

 * keywords:   => bridgedb-https
 * cc: isis (added)
 * status:  new => closed
 * resolution:   => not a bug


Comment:

 [https://gitweb.torproject.org/bridgedb.git/blob/HEAD:/lib/bridgedb/parse/headers.py#l25
 We already do this:]

 {{{
 def parseAcceptLanguage(header):
     """Parse the contents of a client 'Accept-Language' header.
 }}}
 [...]
 {{{
     4. Add a fallback language of the same type if it is missing. For
        example, if we only got ['es-ES', 'de-DE'], add 'es' after 'es-ES'
        and add 'de' after'de-DE'.
 }}}
 [...]
 {{{
     """
 }}}
 [...]
 {{{
     # Add a fallback language of the same type if it is missing.
     langsWithLocales = filter(lambda x: '-' in x, langs)
     langsOnly = map(lambda x: x.split('-')[0], langsWithLocales)
     for only in langsOnly:
         if only not in langs:
             # Add the fallback after the other languages like it:
             insertAfter = filter(lambda x: x.startswith(only),
                                  [x for x in langs])
             if insertAfter:
                 placement = langs.index(insertAfter[0]) + 1
                 langs.insert(placement, only)
                 continue
             # Otherwise just put it at the end
             langs.append(only)

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/12773#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs