WeblateOrg / WeblateOrg/weblate

Support explanation attribute for Android string resources

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

Description

### Describe the problem

As far as I can tell -- based on reading https://docs.weblate.org/en/latest/formats.html#format-explanation and https://docs.weblate.org/en/latest/formats.html#format-description -- there's no clear mechanism for adding an explanation for a string's usage to Android string resources.

### Describe the solution you would like

Since Android string resources are XML you could define a Weblate specific namespace for Weblate-supported attributes. Then Android string resources could declare this namespace and add Weblate-specific attributes for each string.

For example:

```xml

...
...

```

### Describe alternatives you have considered

Adding a comment to the string, e.g.,

```

...
```

is quite fragile; for example, if Android string resources are moved between different Android project modules it's easy for the comments that are "attached" to the string to get lost.

Since XML provides a standardised mechanism for additional metadata to be attached to elements it seems sensible to use that mechanism, instead of inventing new ad-hoc approaches.

### Screenshots

_No response_

### Additional context

This is prompted by noticing translation mistakes in my project. For example, I have a string that looks like this in the source language:

```xml
%1$s • %2$s
```

The comment's to provide additional context to translators for the contents of the two placeholders (exactly what I'd use the explanation for).

In practice I've seen translators inadvertently corrupt this, so for example the translation becomes:

```xml
" <!-- 15 votes • 1 hour left --> %1$s • %2$s"
%1$s • %2$s
```

(i.e., the comment markers are stripped and the comment becomes visible text in the app's UI)

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.