You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of passing modules directly into SL10n, now you can use parsing implementations:
fromsl10nimportSL10n, SLocalefromsl10n.pimplimportJSONImplimportujson# not a stdlib
...
sl10n=Sl10n(MyLocale, parsing_impl=JSONImpl(ujson))
This allows me to add compatibility with more modules in the future and also you to add custom parsing implementations.
Just subclass the sl10n.pimpl.ParsingImpl and implement your load and dump methods.
json, simplejson and ujson use JSONImpl.
python-rapidjson now marked as supported and uses JSONImpl.
Added support for orjson - use ORJSONImpl for it.
Simple demonstation of each usage:
fromsl10n.pimplimportJSONImpl, ORJSONImplJSONImpl(json)
JSONImpl(simplejson)
JSONImpl(ujson)
JSONImpl(rapidjson) # `python-rapidjson` in pipORJSONImpl() # for `orjson`
New modifier - lang_code
Changes lang_code property of respected locale container.
Doesn't change the access key in SL10n.locale(key) - be aware!
json_impl argument in SL10n.__init__ was renamed to parsing_impl to better mirror new changes
UnexpectedLocale warning was renamed to UndefinedLocale