Merge pull request #84 from niphlod/issue/1464-1465

better T in grid/smartgrid
This commit is contained in:
mdipierro
2013-05-01 06:44:04 -07:00
+10 -10
View File
@@ -21,7 +21,7 @@ import os
from http import HTTP from http import HTTP
from html import XmlComponent from html import XmlComponent
from html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG, SCRIPT from html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG, SCRIPT
from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON from html import FORM, INPUT, LABEL, OPTION, SELECT
from html import TABLE, THEAD, TBODY, TR, TD, TH, STYLE from html import TABLE, THEAD, TBODY, TR, TD, TH, STYLE
from html import URL, truncate_string, FIELDSET from html import URL, truncate_string, FIELDSET
from dal import DAL, Field, Table, Row, CALLABLETYPES, smart_query, \ from dal import DAL, Field, Table, Row, CALLABLETYPES, smart_query, \
@@ -36,7 +36,7 @@ import datetime
import urllib import urllib
import re import re
import cStringIO import cStringIO
from gluon import current, redirect, A, URL, DIV, H3, UL, LI, SPAN, INPUT from gluon import current, redirect
import inspect import inspect
import settings import settings
is_gae = settings.global_settings.web2py_runtime_gae is_gae = settings.global_settings.web2py_runtime_gae
@@ -2269,7 +2269,7 @@ class SQLFORM(FORM):
message = T('at least %(nrows)s records found') % dict(nrows=nrows) message = T('at least %(nrows)s records found') % dict(nrows=nrows)
else: else:
message = T('%(nrows)s records found') % dict(nrows=nrows) message = T('%(nrows)s records found') % dict(nrows=nrows)
console.append(DIV(message,_class='web2py_counter')) console.append(DIV(message or T('None'),_class='web2py_counter'))
paginator = UL() paginator = UL()
if paginate and dbset._db._adapter.dbengine=='google:datastore': if paginate and dbset._db._adapter.dbengine=='google:datastore':
@@ -2356,9 +2356,9 @@ class SQLFORM(FORM):
if value: if value:
if callable(upload): if callable(upload):
value = A( value = A(
current.T('file'), _href=upload(value)) T('file'), _href=upload(value))
elif upload: elif upload:
value = A(current.T('file'), value = A(T('file'),
_href='%s/%s' % (upload, value)) _href='%s/%s' % (upload, value))
else: else:
value = '' value = ''
@@ -2430,7 +2430,7 @@ class SQLFORM(FORM):
selectable(records) selectable(records)
redirect(referrer) redirect(referrer)
else: else:
htmltable = DIV(current.T('No records found')) htmltable = DIV(T('No records found'))
if csv and nrows: if csv and nrows:
export_links = [] export_links = []
@@ -2520,7 +2520,7 @@ class SQLFORM(FORM):
name = None name = None
def format(table,row): def format(table,row):
if not row: if not row:
return 'Unknown' return T('Unknown')
elif isinstance(table._format,str): elif isinstance(table._format,str):
return table._format % row return table._format % row
elif callable(table._format): elif callable(table._format):
@@ -2650,11 +2650,11 @@ class SQLFORM(FORM):
SPAN(divider, _class='divider') if next else '', SPAN(divider, _class='divider') if next else '',
_class='active w2p_grid_breadcrumb_elem')) _class='active w2p_grid_breadcrumb_elem'))
if grid.create_form: if grid.create_form:
header = T('New %s' % table._singular) header = T('New %(entity)s') % dict(entity=table._singular)
elif grid.update_form: elif grid.update_form:
header = T('Edit %s' % format(table,grid.update_form.record)) header = T('Edit %(entity)s') % dict(entity=format(table,grid.update_form.record))
elif grid.view_form: elif grid.view_form:
header = T('View %s' % format(table,grid.view_form.record)) header = T('View %(entity)s') % dict(entity=format(table,grid.view_form.record))
if next: if next:
breadcrumbs.append(LI( breadcrumbs.append(LI(
A(T(header), _class=trap_class(),_href=url()), A(T(header), _class=trap_class(),_href=url()),