Describe the bug
Hello, I use the addon Component discovery to get new Po files from a git repository. At first, their extension works great, but when I add a new po on the git and merge on the local repository, the addon reads automatically and sets the first option (app store metadata) instead of "Gettext Po file".
To Reproduce
Steps to reproduce the behavior:
Screenshots







Try saving the addon settings. The problem is probably caused by having there automatic file format which was removed in recent Weblate versions, but the po is default, that's why it's shown.
We configured the add-on in the previous release 3.6. I think by that time the default automatic option was already removed, right?
Well it behaves like the auto format is stored there, can you please try saving the addon configuration?
I've just fixed migrating the addon configuration from the auto format.
We will try thanks!
And I think you were right, I have received this email from rollback:
Message
KeyError: 'auto'
Traceback
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/views/decorators/http.py", line 40, in inner
return func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/views/git.py", line 148, in update_project
return perform_update(request, obj)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/views/git.py", line 70, in perform_update
method=request.GET.get('method'),
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/views/git.py", line 36, in execute_locked
result = call(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/project.py", line 265, in do_update
True, 'do_update', request, method=method
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/project.py", line 245, in on_repo_components
res = getattr(component, call)(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 120, in on_link_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 866, in do_update
self.create_translations(request=request)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1337, in create_translations
component.create_translations(force, langs, request=request, from_link=True)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1256, in create_translations
if self.has_template():
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1762, in has_template
monolingual = self.file_format_cls.monolingual
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1757, in file_format_cls
self._file_format = FILE_FORMATS[self.file_format]
File "/usr/local/lib/python3.7/dist-packages/weblate/utils/classloader.py", line 78, in __getitem__
return self.data.__getitem__(key)
KeyError: 'auto'
Params
context update_project
environment production
framework django
language python 3.7.3
level error
Hmm, so the component was actually created with invalid settings. To fix that (assuming you have only PO files messed up this way) run following in the management shell (./manage.py shell):
from weblate.trans.models import Component
components = Component.objects.filter(file_format='auto')
components.update(file_format='po')
for component in components:
component.create_translations()
Thanks for the tip!
We already updated the type of each component by hand but I will save this snippet in case it happens the next time.
The addons configuration should be fixed by https://github.com/WeblateOrg/weblate/commit/d012953898ac5a6ce520775e91f9677f55a8118c (or you can manually save them if you don't have too much of these).