Comments (2)
The schema is dumped to json before sending to the browser. We'll have to run the lazy translations before dumping to json.
Meanwhile, you can use a callable schema with regular (non-lazy) translation function to get your desired functionality:
from django.utils.translation import gettext as _
def get_schema():
# This function is called on every request
schema = {
'type': 'object',
'keys': {
'show': {
'type': 'boolean',
'title': _('Show') # non-lazy translation will process immediately as per current request locale
},
},
}
return schema
field = JSONField(schema=get_schema)
from django-jsonform.
Hi, I've added support for lazy strings. You can now use lazy strings anywhere in the schema, not just for titles such as choices, default values, etc. I'll include it in the next release.
Example:
{
'type': 'string',
'title': _('Occupation'),
'choices': [_('Teacher'), _('Doctor'), _('Engineer')]
...
}
from django-jsonform.
Related Issues (20)
- Default layout of jsonform in Django Admin HOT 4
- Bug when using multi select with custom title HOT 5
- Object of type UUID is not JSON serializable HOT 1
- New release HOT 1
- Custom validation of object properties not showing error next to field HOT 2
- Form dynamics not working after reloading django-jsonform with HTMX HOT 3
- Using an object with empty Properties, having all properties inside AdditionalProperties HOT 3
- Setting JSONField schema dynamically HOT 3
- Copy-pasting / Duplications for Array items and Objects
- Horizontal display of properties HOT 1
- Dynamic header generation for array items HOT 2
- Customising "Add key" and "Add item" texts HOT 1
- Add button to open link in URLField HOT 5
- Decimal values not allowed when entering integer minimum and maximum for 'number' types HOT 4
- Define defaults for an array HOT 3
- Subfields in ArrayField should get the relevant input type
- Issue with errors for fields inside an anyOf schema not displaying correctly HOT 1
- validators for jsonfield are not updated with dynamic schema HOT 3
- Cooperation with other repository `django-pydantic-field` for model schema validation HOT 1
- Title is not populated for `oneOf` when referenced through `$ref` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-jsonform.