WeblateOrg / WeblateOrg/weblate

Weblate prints non-dismissable false warning about "misconfigured monolingual files" when they're not monolingual

Open
#15,955 1 comment 1 reaction 0 assignees View on GitHub
Waiting for: Demand
Dominant language
Python
Stars
6.1k
Forks
1.4k
Avg merge
9h 53m
Merged PRs (30d)
395

Description

### Describe the issue

It appears to me that when a component contains a very simple translation where all source strings and all translations are only one word long, Weblate displays this annoying, incorrect, non-dismissable warning:

> The translation component looks monolingual, but it is not set up to be.
> Please add a monolingual base language file in the component settings.

The "looks monolingual" raises an eyebrow. IMO non-dismissable warnings should not be based on guesses. Either Weblate *knows* the file is actually monolingual, or it doesn't. If it just *believes* the file to be monolingual, that doesn't really justify the warning IMO.

Because this warning is annoying, causes false-positives and is not dismissable, I suggest to remove it entirely from Weblate.

----

_Originally posted by @Wuzzy2 in https://github.com/WeblateOrg/weblate/discussions/14448#discussioncomment-13943567_

### I already tried

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

### Steps to reproduce the behavior

Create a multilingual component based on Gettext PO in which you add a few source string, and every source string is exactly 1 word. Then add a language in which every translation is also exactly 1 word (i.e. no whitespace in the string). This component should now get this warning.
For comparision, add another language to the component, but this time put two words into the translations.

### Expected behavior

The warning never appears because it has been removed from Weblate entirely.

### How do you run Weblate?

Other

### Weblate versions

5.12.2

### Additional context

#### Code analysis

It seems Weblate does just use a heuristic to trigger the warning.

(`weblate/trans/models/alert.py`, class `MonolingualTranslation`)

```
def check_component(component: Component) -> bool | dict | None:
if (
component.is_glossary
or component.template
or not component.source_language.uses_whitespace()
):
return False

# Pick translation with translated strings except source one
translation: Translation | None = None
for current in (
component.translation_set.filter(unit__state__gte=STATE_TRANSLATED)
.exclude(language_id=component.source_language_id)
.select_related("language")
):
if not current.language.uses_whitespace():
continue
translation = current

# Bail out if there is no suitable translation
if translation is None:
return False

allunits = translation.unit_set

source_space = allunits.filter(source__contains=" ")
target_space = allunits.filter(
state__gte=STATE_TRANSLATED, target__contains=" "
)
return (
allunits.count() > 3 and not source_space.exists() and target_space.exists()
)
```

The final part is what looks relevant.

`allunits.count() > 3 and not source_space.exists() and target_space.exists()`

Let’s pretend `allunits.count() > 3` is `True`.

Then the function returns True if the source strings contain no whitespace, but a translation strings does.

So wait a minute, is this warning basically just a whitespace checker? That doesn’t sound right.

I don’t remember the gettext manual saying that all msgids without whitespace have any special meaning. The only special msgid I know of is the empty string, which is used for the PO file metadata. (Feel free to point me to the part of the manual that proves me wrong.)

#### Suggestion: Fix this by removing the warning entirely

Therefore, I think this warning is completely broken by design and should be removed entirely (especially since it cannot be dismissed by the user). Unless this warning can be rewritten to be completely fact-based and not guess-based ("looks monolingual").
Weblate probably shouldn’t make any assumptions just because of the presence or lack of whitespace. Unless it is actually officially defined to have meaning somewhere.

#### How I found this

I bumped into this issue in .

It contains 4 strings: "Clear", "Drizzle", "Rain" and "Storm". This is the only component with the warning, all others work.
I have looked into the PO file itself multiple times now, nothing strange. POT is also fine.

Today I made a workaround: I added a 5th dummy string "The sun is shining.", i.e. just a string that contains some spaces. And after uploading it to Weblate and updating it, the warning vanished.

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.