This is a bug. Please open a ticket.

English is not a special case, it simply is the default language. Which 
means that it assumes it does not need to check translation files for 
english. 

On Tuesday, 25 February 2014 20:33:34 UTC-6, User wrote:
>
> One minor downside to T.force(T.http_accept_language) is that when using 
> the web2py shell with models it gives an error:
>
> Traceback (most recent call last):
>   File "C:\www\web2py\gluon\restricted.py", line 217, in restricted
>     exec ccode in environment
>   File "applications\my_app\models\0.py", line 6, in <module>
>     T.force(T.http_accept_language)
>   File "C:\www\web2py\gluon\languages.py", line 661, in force
>     self.accepted_language = language or self.current_languages[0]
> IndexError: list index out of range
>
>
>
>
> On Tuesday, February 25, 2014 9:09:55 PM UTC-5, User wrote:
>
>> Thanks this does work.  Most of my site visitors will be English language 
>> speakers, is there any important performance hit I should be aware of?  Why 
>> is en-us a special case?
>>
>> On Tuesday, February 25, 2014 12:46:41 AM UTC-5, Massimo Di Pierro wrote:
>>>
>>> For now do this:
>>>
>>> T.current_languages = []
>>> T.force(T.http_accept_language)
>>>
>>> This should work. I will try figure out why T.set_current_languages() 
>>> does not.
>>>
>>> On Monday, 24 February 2014 18:07:40 UTC-6, User wrote:
>>>>
>>>> This does not appear to work the string is not translated.  Also the 
>>>> following doesn't work either:
>>>>
>>>> T.set_current_languages()
>>>> T.force('en-us')
>>>>
>>>> However, as mentioned above changing this back to: 
>>>>
>>>> T.current_languages = []
>>>> T.force('en-us')
>>>>
>>>>
>>>> Does work
>>>>
>>>>
>>>> On Monday, February 24, 2014 6:45:18 PM UTC-5, Massimo Di Pierro wrote:
>>>>
>>>>> Ok. One more try:
>>>>>
>>>>> T.set_current_languages()
>>>>>
>>>>>
>>>>> On Monday, 24 February 2014 17:36:10 UTC-6, User wrote:
>>>>>>
>>>>>> I added T.current_languages = [] to the end of my model but this did 
>>>>>> nothing.  Then I tried:
>>>>>>
>>>>>> T.current_languages = []
>>>>>> T.force('en-us')
>>>>>>
>>>>>> This caused the translated string in en-us.py to show up in the 
>>>>>> rendered html (and also caused the filling of en-us.py with default 
>>>>>> strings).  However, I still don't seem to have a solution, because I 
>>>>>> don't 
>>>>>> want to force the language to be en-us.  I want to use whatever the 
>>>>>> user's 
>>>>>> accept-language is.  And in general this already works, except for 
>>>>>> en-us.  
>>>>>> Thoughts?
>>>>>>
>>>>>>
>>>>>> On Monday, February 24, 2014 8:17:24 AM UTC-5, Massimo Di Pierro 
>>>>>> wrote:
>>>>>>
>>>>>>> I get it now. You need:
>>>>>>>  
>>>>>>>   T.current_languages = []
>>>>>>>
>>>>>>> Otherwise this is set to
>>>>>>>
>>>>>>>   T.current_languages = ['en']
>>>>>>>
>>>>>>> and it things the current language is english and therefore it does 
>>>>>>> not need translation.
>>>>>>>
>>>>>>>
>>>>>>> On Monday, 24 February 2014 01:45:49 UTC-6, User wrote:
>>>>>>>>
>>>>>>>> In fact, if I put an entry in en-gb.py and set my browser 
>>>>>>>> accept-language to en-gb it will correctly pick up this string, but 
>>>>>>>> for 
>>>>>>>> some reason it's not picking up the string in en-us (unless I'm doing 
>>>>>>>> something wrong). 
>>>>>>>>
>>>>>>>> Also interesting to note, is when I view my site with en-gb or es 
>>>>>>>> as the accept lang, web2py seems to automatically modify the en-gb.py 
>>>>>>>> and 
>>>>>>>> es.py files with default entries for every default string, whereas 
>>>>>>>> it's not 
>>>>>>>> doing that for en-us.py
>>>>>>>>
>>>>>>>> Does this have to with en-us.py being a default or something?
>>>>>>>>
>>>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to