WeblateOrg / WeblateOrg/weblate

API: upload translation as field instead of file

Open
#20,127 3 comments 0 reactions 1 assignee Claimed by @gersona View on GitHub
Area: API Waiting for: Implementation
Dominant language
Python
Stars
6.1k
Forks
1.4k
Avg merge
9h 53m
Merged PRs (30d)
395

Description

### Describe the problem

A third party system can't upload translations via API because it can't provide the [`filename=` parameter](https://www.rfc-editor.org/info/rfc2183/#section-2.3) required by DRF on the `file` param in the [`POST /api/translations/(project)/(component)/(language)/file/`](https://docs.weblate.org/en/latest/api.html#post--api-translations-(string-project)-(string-component)-(string-language)-file-) request to Weblate.

### Solution brainstorm

Either:
- make it optional to provide a `filename=`, or
- add a additional form parameter (e.g. `file_content`) as a alternative to the `file` param.

The filename provided is not used by Weblate.

### Describe alternatives you have considered

- Additional endpoint that is not called `/api/translation/.../file/` but something like `/api/translation/.../update/`: might be cleaner, but adds even more API surface for little benefit.
- Getting the vendor of the third party system to support `filename=` in their API client for form-encoded data: lot's of patience required...

### Screenshots

_No response_

### Additional context

Based on the [example in the docs](https://docs.weblate.org/en/latest/api.html#post--api-translations-(string-project)-(string-component)-(string-language)-file-), I'd basically like to do the following:
```
curl -X POST \
-F file=

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.