WeblateOrg / WeblateOrg/weblate

Cannot use `ini` file containing values with no section as monolingual base language file

Open
#9,702 5 comments 0 reactions 0 assignees View on GitHub
Blocked by upstream enhancement Waiting for: Demand
Dominant language
Python
Stars
6.1k
Forks
1.4k
Avg merge
9h 53m
Merged PRs (30d)
395

Description

### Describe the issue

I've tried to translate the [Gitea repo](https://github.com/go-gitea/gitea) with Weblate.
Gitea has its translation files inside [/options/locale](https://github.com/go-gitea/gitea/tree/main/options/locale).
If I understand the concept of the `Monolingual base language file` correctly, it should be the file [options/locale/locale_en-US.ini](https://github.com/go-gitea/gitea/tree/main/options/locale/locale_en-US.ini) in this context.
However, it is apparently not possible at the moment to read that file as there are some keys that don't belong to any section.
At the moment, the file starts with the lines
```ini
home = Home
dashboard = Dashboard
explore = Explore
help = Help
logo = Logo

```
that don't belong to any section.
Apparently, that cannot be parsed at the moment.

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

1. Go to `Add new translation component`
2. Try to migrate a repo containing monolingual sources where the base file contains keys that don't belong to any section
3. Enjoy.

### Expected behavior

I am able to initialize the project.

### Screenshots

![grafik](https://github.com/WeblateOrg/weblate/assets/51889757/b7073cd3-0e24-4e65-8672-ba499441176a)

### Exception traceback

```pytb
weblate-docker-weblate-1 | gunicorn stderr | [2023-08-08 13:56:50,036: WARNING/417] Template parse error: MissingSectionHeaderError: File contains no section headers.
weblate-docker-weblate-1 | gunicorn stderr | file: '', line: 1
weblate-docker-weblate-1 | gunicorn stderr | 'home = Home\n'
```

### How do you run Weblate?

Docker container

### Weblate versions

* Weblate: 4.18.2
* Django: 4.2.4
* siphashc: 2.1
* translate-toolkit: 3.9.2
* lxml: 4.9.3
* Pillow: 9.5.0
* nh3: 0.2.14
* python-dateutil: 2.8.2
* social-auth-core: 4.4.2
* social-auth-app-django: 5.2.0
* django-crispy-forms: 2.0
* oauthlib: 3.2.2
* django-compressor: 4.4
* djangorestframework: 3.14.0
* django-filter: 23.2
* django-appconf: 1.0.5
* user-agents: 2.2.0
* filelock: 3.12.2
* rapidfuzz: 3.1.2
* openpyxl: 3.1.2
* celery: 5.3.1
* django-celery-beat: 2.5.0
* kombu: 5.3.1
* translation-finder: 2.15
* weblate-language-data: 2023.5
* html2text: 2020.1.16
* pycairo: 1.24.0
* PyGObject: 3.44.1
* diff-match-patch: 20230430
* requests: 2.31.0
* django-redis: 5.3.0
* hiredis: 2.2.3
* sentry-sdk: 1.29.2
* Cython: 0.29.36
* misaka: 2.1.1
* GitPython: 3.1.32
* borgbackup: 1.2.4
* pyparsing: 3.0.9
* pyahocorasick: 2.0.0
* python-redis-lock: 4.0.0
* charset-normalizer: 3.2.0
* Python: 3.11.4
* Git: 2.30.2
* psycopg2: 2.9.6
* phply: 1.2.6
* ruamel.yaml: 0.17.32
* tesserocr: 2.6.0
* boto3: 1.26.165
* zeep: 4.2.1
* aeidon: 1.12
* iniparse: 0.5
* mysqlclient: 2.2.0
* Mercurial: 6.5
* git-svn: 2.30.2
* git-review: 2.3.1
* Redis server: 7.0.12
* PostgreSQL server: 15.3
* Database backends: django.db.backends.postgresql
* Cache backends: default:RedisCache, avatar:FileBasedCache
* Email setup: django.core.mail.backends.smtp.EmailBackend: smtp.example.com
* OS encoding: filesystem=utf-8, default=utf-8
* Celery: redis://cache:6379/1, redis://cache:6379/1, regular
* Platform: Linux 6.2.0-26-generic (x86_64)

### Weblate deploy checks

```shell
# Irrelevant.
SystemCheckError: System check identified some issues:

CRITICALS:
?: (weblate.E003) Cannot send e-mail ([Errno -2] Name or service not known), please check EMAIL_* settings.
HINT: https://docs.weblate.org/en/weblate-4.18.2/admin/install.html#out-mail
?: (weblate.E012) The server e-mail address should be changed from its default value
HINT: https://docs.weblate.org/en/weblate-4.18.2/admin/install.html#production-email
?: (weblate.E013) The "From" e-mail address should be changed from its default value
HINT: https://docs.weblate.org/en/weblate-4.18.2/admin/install.html#production-email

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.

INFOS:
?: (weblate.I021) Error collection is not set up, it is highly recommended for production use
HINT: https://docs.weblate.org/en/weblate-4.18.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-4.18.2/admin/backup.html

System check identified 8 issues (1 silenced).
```

### Additional context

I find the help text
> Filename of translation base file, containing all strings and their source; it is **recommended** for monolingual translation formats.

a bit ironic as it is apparently **required** (I've only noticed this bug as the dialogue complained about a missing monolingual base language file in the first place.

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.