WeblateOrg / WeblateOrg/weblate
Component Discovery: set the category
- Dominant language
- Python
- Stars
- 6.1k
- Forks
- 1.4k
- Avg merge
- 9h 53m
- Merged PRs (30d)
- 395
Description
### Describe the problem
Component Discovery does not allow setting the category programmatically.
Use case: I'd like to preserve the hierarchical structure of my project in Weblate. See context below.
### Describe the solution you would like
There should be a Category option in the addon's setup, with a pattern. In my case (see context below), I'd be able to use this regex:
`translated/(?P[^/]+)/`**`(?Pplayers/(?:.+/)*)`**`(?P[^/]+)\.md`
`translated/language/`**`players/path/to/`**`file.md`
...and set the category to `{{ category }}`. This would result in the final URL being `/players/path/to/file`, and the project's home page would show the same hierarchical structure of the repo.
Note: it should also create categories that do not exist.
### Describe alternatives you have considered
1. Manually setting the categories post-discovery, but this defeats the purpose of the addon
2. Keep the auto-generated globs, which will not be grouped by folder and will clutter the home page.
- they might also create non-trivially predictable conflicts, for example `installing/java.md` and `installing-java.md` in the same directory.
### Screenshots
Not applicable
### Additional context
See full Discussion here:
Read more
> We're evaluating Weblate as a potential alternative to Crowdin for the open-source [Fabric Documentation project](https://github.com/FabricMC/fabric-docs). Our translation file structure is:
>
> - Source: `a/**.md`, `b/**.md`
> - Translated: `translated/*/a/**.md`, `translated/*/b/**.md`
>
> I'd like Weblate's translation URLs to **preserve the original file path**; for example `a/path-to/file.md` should have its translation at `/a/path-to/file`.
> However, Weblate does not allow `/` in the `slug`, but categories do allow a hierarchical structure.
>
> The question is: **can Component Discovery automatically create and set the correct category?**
>
>
> Current Component Discovery setup
>
> - Regex: `translated/(?P[^/]+)/(?Pplayers/(?:.+/)*)(?P[^/]+)\.md`
> - Base: `{{ category }}{{ component }}.md`
>
>
Contributor guide
Assessment
This issue has not been assessed yet.