After upgrading to Weblate 5.4.1.1 (and now 5.4.2.1) we can no longer setup the pseudolocale plugin on a component housed inside a project and pressing "Save". We receive an error message. TypeError: Object of type Translation is not JSON serializable
[X] I've searched for similar filed issues in this repository.
Steps to reproduce the behavior
Make a component in a project
In settings: Add-On, add the Pseudolocale add-on
Configure the source strings and target translation (en and en-XA, in my case)
Click save
Expected behavior
The target translation should now be filled in where the source strings get pseudolocalled?
ie. "hallo" -> "$_____hallo_____$"
Screenshots
Exception traceback
Environment:
Request Method: POST
Request URL: ***********************************************
Django Version: 4.2.10
Python Version: 3.12.2
Installed Applications:
['customize',
'weblate.addons',
'weblate.auth',
'weblate.checks',
'weblate.formats',
'weblate.glossary',
'weblate.machinery',
'weblate.trans',
'weblate.lang',
'weblate_language_data',
'weblate.memory',
'weblate.screenshots',
'weblate.fonts',
'weblate.accounts',
'weblate.configuration',
'weblate.utils',
'weblate.vcs',
'weblate.wladmin',
'weblate.metrics',
'weblate',
'weblate.gitexport',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.admindocs',
'django.contrib.sitemaps',
'django.contrib.humanize',
'social_django',
'crispy_forms',
'crispy_bootstrap3',
'compressor',
'rest_framework',
'rest_framework.authtoken',
'django_filters',
'django_celery_beat',
'corsheaders']
Installed Middleware:
['weblate.middleware.RedirectMiddleware',
'weblate.middleware.ProxyMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'weblate.accounts.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'weblate.accounts.middleware.RequireLoginMiddleware',
'weblate.api.middleware.ThrottlingMiddleware',
'weblate.middleware.SecurityMiddleware']
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 114, in debug_sql
yield
^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 102, in execute
return super().execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/cursor.py", line 728, in execute
self._conn.wait(
^
File "/usr/local/lib/python3.12/site-packages/psycopg/connection.py", line 969, in wait
return waiting.wait(gen, self.pgconn.socket, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "psycopg_binary/_psycopg/waiting.pyx", line 190, in psycopg_binary._psycopg.wait_c
<source code not available>
File "/usr/local/lib/python3.12/site-packages/psycopg/cursor.py", line 210, in _execute_gen
pgq = self._convert_query(query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/client_cursor.py", line 79, in _convert_query
pgq.convert(query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/_queries.py", line 213, in convert
self.dump(vars)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/_queries.py", line 223, in dump
self.params = tuple(
File "/usr/local/lib/python3.12/site-packages/psycopg/_queries.py", line 224, in <genexpr>
self._tx.as_literal(p) if p is not None else b"NULL" for p in params
^^^^^^^^^^^^^^^^^^^^^^
File "psycopg_binary/_psycopg/transform.pyx", line 206, in psycopg_binary._psycopg.Transformer.as_literal
<source code not available>
File "psycopg_binary/_psycopg/transform.pyx", line 215, in psycopg_binary._psycopg.Transformer.as_literal
<source code not available>
File "/usr/local/lib/python3.12/site-packages/psycopg/adapt.py", line 57, in quote
value = self.dump(obj)
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/types/json.py", line 151, in dump
data = dumps(obj)
^^^^^^^^^^
File "/usr/local/lib/python3.12/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
During handling of the above exception (Object of type Translation is not JSON serializable), another exception occurred:
File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/weblate/addons/views.py", line 73, in post
instance = form.save()
^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/weblate/addons/forms.py", line 34, in save
self._addon.configure(self.serialize_form())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/weblate/addons/base.py", line 113, in configure
self.instance.save()
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/weblate/addons/models.py", line 87, in save
self.store_change(
^
File "/usr/local/lib/python3.12/site-packages/weblate/addons/models.py", line 104, in store_change
self.component.change_set.create(
^
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/related_descriptors.py", line 799, in create
return super(RelatedManager, self.db_manager(db)).create(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/weblate/trans/models/change.py", line 205, in create
return super().create(user=user, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 658, in create
obj.save(force_insert=True, using=self.db)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/weblate/trans/models/change.py", line 610, in save
super().save(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 814, in save
self.save_base(
^
File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 877, in save_base
updated = self._save_table(
File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1020, in _save_table
results = self._do_insert(
File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1061, in _do_insert
return manager._insert(
File "/usr/local/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1805, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1822, in execute_sql
cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 101, in execute
with self.debug_sql(sql, params, use_last_executed_query=True):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 119, in debug_sql
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/postgresql/operations.py", line 301, in last_executed_query
return self.compose_sql(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/postgresql/operations.py", line 194, in compose_sql
return mogrify(sql, params, self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/backends/postgresql/psycopg_any.py", line 22, in mogrify
return ClientCursor(cursor.connection).mogrify(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/client_cursor.py", line 40, in mogrify
pgq = self._convert_query(query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/client_cursor.py", line 79, in _convert_query
pgq.convert(query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/_queries.py", line 213, in convert
self.dump(vars)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/_queries.py", line 223, in dump
self.params = tuple(
File "/usr/local/lib/python3.12/site-packages/psycopg/_queries.py", line 224, in <genexpr>
self._tx.as_literal(p) if p is not None else b"NULL" for p in params
^^^^^^^^^^^^^^^^^^^^^^
File "psycopg_binary/_psycopg/transform.pyx", line 206, in psycopg_binary._psycopg.Transformer.as_literal
<source code not available>
File "psycopg_binary/_psycopg/transform.pyx", line 215, in psycopg_binary._psycopg.Transformer.as_literal
<source code not available>
File "/usr/local/lib/python3.12/site-packages/psycopg/adapt.py", line 57, in quote
value = self.dump(obj)
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/psycopg/types/json.py", line 151, in dump
data = dumps(obj)
^^^^^^^^^^
File "/usr/local/lib/python3.12/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: TypeError at /addons/testproject/testcompinent/
Exception Value: Object of type Translation is not JSON serializable
SystemCheckError: System check identified some issues:
CRITICALS:
?: (weblate.E027) The path /app/data/weblateSettingsFull.py is owned by a different user, check your DATA_DIR settings.
HINT: https://docs.weblate.org/en/weblate-5.4.2/admin/install.html#file-permissions
WARNINGS:
?: (security.W004) You have not set a value for the SECURE_HSTS_SECONDS setting. If your entire site is served only over SSL, you may want to consider setting a value and enabling HTTP Strict Transport Security. Be sure to read the documentation first; enabling HSTS carelessly can cause serious, irreversible problems.
?: (security.W008) Your SECURE_SSL_REDIRECT setting is not set to True. Unless your site should be available over both SSL and non-SSL connections, you may want to either set this setting True or configure a load balancer or reverse-proxy server to redirect all connections to HTTPS.
?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W018) You should not have DEBUG set to True in deployment.
INFOS:
?: (weblate.I021) Error collection is not set up, it is highly recommended for production use
HINT: https://docs.weblate.org/en/weblate-5.4.2/admin/install.html#collecting-errors
?: (weblate.I028) Backups are not configured, it is highly recommended for production use
HINT: https://docs.weblate.org/en/weblate-5.4.2/admin/backup.html
System check identified 7 issues (1 silenced).
Additional context
We are not running a deployed production instance, only a locally served test instance.
We successfully added the pseudolocale to components in Weblate 4.14,
We cannot add it since upgrading to 5.4.1.1 and 5.4.2.
Describe the issue
After upgrading to Weblate 5.4.1.1 (and now 5.4.2.1) we can no longer setup the pseudolocale plugin on a component housed inside a project and pressing "Save". We receive an error message.
TypeError: Object of type Translation is not JSON serializable
I already tried
Steps to reproduce the behavior
Expected behavior
The target translation should now be filled in where the source strings get pseudolocalled? ie. "hallo" -> "$_____hallo_____$"
Screenshots
Exception traceback
How do you run Weblate?
Docker container
Weblate versions
Weblate deploy checks
Additional context
We are not running a deployed production instance, only a locally served test instance.
We successfully added the pseudolocale to components in Weblate 4.14, We cannot add it since upgrading to 5.4.1.1 and 5.4.2.