To clarify further, I made an entry in languages/es.py and when I set my browser preferred language to "es" I get the entry I put in the es.py file. So translation is working. However, when I set my browser to en-us it does not seem to pick up the entry in en-us.py file
On Monday, February 24, 2014 2:13:04 AM UTC-5, User wrote: > > Also I tried in web2py shell: > > str(T('this-is-a-test', language='en-us')) > > which returns: > > 'this-is-a-test' > > Not sure if this makes any sense calling from the shell but figured I try > it. > > On Monday, February 24, 2014 2:02:25 AM UTC-5, User wrote: > >> This in layout.html. Viewing the rendered source in the browser the >> output is >> >> var dateFormat = "dd mmm yyyy"; >> >> Putting T.force('en-us') at the end of models/models.py didn't change >> anything. >> >> In fact, to take javascript out of the picture I just put a simple T >> statement in the footer of my layout.html: >> >> {{=T('this-is-a-test')}} >> >> And added an entry for it in en-us.py >> >> { >> '!langcode!': 'en-us', >> '!langname!': 'English (United States)', >> 'dd mmm yyyy':'mmm dd, yyyy', >> 'this-is-a-test': 'PASS' >> } >> >> >> The output remains: this-is-a-test >> >> I can easily insert an debug breakpoint: import ipdb; ipdb.set_trace() if >> that will help examine anything. >> >> >> >> On Monday, February 24, 2014 1:27:10 AM UTC-5, Massimo Di Pierro wrote: >> >>> This should work. I do not think the problem is in T. Anyway, let's rule >>> that out. >>> >>> Where is this, in a HTML file? >>> >>> When you look at the source file, is the string "{{=T('dd mmm yyyy')}}" >>> ) translated? >>> What if you add the following to your model? >>> >>> T.force('en-us') >>> >>> >>> >>> >>> On Sunday, 23 February 2014 23:08:14 UTC-6, User wrote: >>>> >>>> Sorry I'm not following the relevance of that forum topic. What I'm >>>> trying to do for example is: >>>> >>>> I have a date in javascript in a view : >>>> >>>> var dateFormat = "{{=T('dd mmm yyyy')}}") >>>> >>>> >>>> Later on this will get expanded to for example "20 January 2014". This >>>> works and the date display as expected. For the US, I want the date >>>> displayed as "January 20, 2014". So I created a en-us.py language file >>>> with >>>> the following content: >>>> >>>> { >>>> '!langcode!': 'en-us', >>>> '!langname!': 'English (United States)', >>>> 'dd mmm yyyy':'mmm dd, yyyy' >>>> } >>>> >>>> >>>> I restarted web2py. However, with my browser Accept-Language set to >>>> en-us I still see the date as "20 January 2014". My full firefox header >>>> is: >>>> Accept-Language en-us,en;q=0.5 >>>> >>>> What am I missing about how T works? >>>> >>>> >>>> On Sunday, February 23, 2014 8:39:56 PM UTC-5, Massimo Di Pierro wrote: >>>> >>>>> https://groups.google.com/forum/#!msg/web2py/ZxdTaSM1Fpk/hGryHgztlPQJ >>>>> >>>>> On Sunday, 23 February 2014 19:06:56 UTC-6, User wrote: >>>>>> >>>>>> I have some dates that I want to display in the proper culture >>>>>> specific format. I want a simple solution so what I want is rather than >>>>>> me >>>>>> having to specify the date format for every possible culture is to use >>>>>> the >>>>>> following default: >>>>>> >>>>>> dd-mm-yyyy >>>>>> >>>>>> and then specify a handful of exceptions, e.g. for United States: >>>>>> >>>>>> mm-dd-yyyy >>>>>> >>>>>> How can I achieve this in web2py where it's switched based on the >>>>>> Accept-Language header? >>>>>> >>>>>> >>>>>> -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.