I have been looking at how forms can be internationalized, submit button and the different messages and texts of the widgets.
After a few tests, it starts to work, but I don’t know if it is a correct and valid approach.
I have added a new parameter (T=lambda text: text) in init of all widgets
Something like this:
class Widget:
"""Prototype widget object for all form widgets"""
type_map = {
"string": "text",
"date": "date",
"time": "time",
}
def __init__(self, T=lambda text: text):
self.T = T
def make(self, field, value, error, title, placeholder="", readonly=False):
"""converts the widget to an HTML helper"""
return INPUT(
_value=value,
_type=self.type_map.get(field.type, "text"),
_id=to_id(field),
_name=field.name,
_placeholder=self.T(placeholder),
_title=self.T(title),
_readonly=readonly,
)
Also to FormStyleFactory and Formclass FormStyleFactory:
...
...
def __init__(self, T=lambda text: text):
...
...
class Form(object):
...
...
define __init__(
self,
table,
record=None,
readonly=False,
deleteable=True,
noncreate=True,
formstyle=FormStyleDefault,
dbio=True,
keep_values=False,
form_name=None,
hidden=None,
validation=None,
csrf_session=None,
csrf_protection=True,
lifespan=None,
signing_info=None,
submit_value="Submit",
show_id=True,
T=lambda text: text,
**kwargs
)
...
...
What is your opinion?
Carlos.
--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/12f93427-3318-4615-8433-a16a2844d11en%40googlegroups.com.