Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[qBittorrent webui] custom theme is broken by default #18109

Open
MahdiMirzade opened this issue Nov 30, 2022 · 7 comments
Open

[qBittorrent webui] custom theme is broken by default #18109

MahdiMirzade opened this issue Nov 30, 2022 · 7 comments
Labels
Themes Waiting info Waiting for participants to supply more info/fulfill template requirements WebUI WebUI-related issues/changes

Comments

@MahdiMirzade
Copy link

MahdiMirzade commented Nov 30, 2022

qBittorrent & operating system versions

qBittorrent: v4.5.0 (64-bit)
Operating system: Fedora Linux 37 (Workstation Edition) (64-bit)
Qt: 5.15.7
libtorrent-rasterbar: 1.2.18.0

What is the problem?

I've followed the Developing alternate WebUIs (WIP) document, my commands are as followed:

git clone https://github.com/qbittorrent/qBittorrent.git
cp -rf qBittorrent/src/webui/www/ webui
cp -rf qBittorrent/src/icons/ webui/public/
cp -rf qBittorrent/src/icons/ webui/private/

And then changed my webui settings to match this path.
Result is as show in the screenshot.

I thought maybe the git version was the problem, so I downloaded the latest tag (v4.5.0) and:

tar xzvf qBittorrent-release-4.5.0.tar.gz
cp -rf ~/Downloads/qBittorrent-release-4.5.0/src/webui/www/ webui
cp -rf ~/Downloads/qBittorrent-release-4.5.0/src/icons/ webui/private/
cp -rf ~/Downloads/qBittorrent-release-4.5.0/src/icons/ webui/public/

But the result didn't change. This seems to be an issue with translation, so I changed my client's language to "فارسی" to see if that would fix it, but it was the same.

Steps to reproduce

No response

Additional context

image

This issue was first witnessed by my theme's issues page.

Log(s) & preferences file(s)

No response

@hugalafutro
Copy link

For what it's worth I can also replicate this with themes from https://github.com/GilbN/theme.park, they have a issue open too: themepark-dev/theme.park#458

@sledgehammer999
Copy link
Member

sledgehammer999 commented Nov 30, 2022

With PR #17616 only the builtin WebUI gets translated. The builtin WebUI uses this construct QBT_TR(string)QBT_TR[CONTEXT=context] to denote translatable strings to the server (qbt). With 4.5.0 the server does the translation only for the buildin webui.

As a fix you should apply a search+replace regex on all copied files.
These two regexes match the expression

QBT_TR\((.*)\)QBT_TR\[CONTEXT=.*\]
QBT_TR\((.*)\)QBT_TR

and capture the translatable string in the 1st capturing group. Then use \1 or $1 to replace/substitute it.

ATTENTION: Apply the first regex before the second one, otherwise it won't work.

@MahdiMirzade
Copy link
Author

MahdiMirzade commented Nov 30, 2022

Thank you @sledgehammer999 for your solution,
But I think this regex does the trick better:

QBT_TR\((([^\)]|\)(?!QBT_TR))+)\)QBT_TR\[CONTEXT=([a-zA-Z_][a-zA-Z0-9_]*)\]

In pycharm I did it like this: Ctrl-Shift-R -> Enable regex search by pressing Alt-x -> Paste expression in find input -> Type $1 in replace input.

But this solution won't fix everything, since when strings which translate combined by a number or another string (shown in the sidebar) are still broken as shown in this picture:
image

Better solution:
Changing the tstool.py in order to translate each context with its own original source, but I don't know if this can truly work or how much dependency qBittorrent webui has on this file so I didn't look into it.

Best solution:
Wait for it to be fixed from upstream, because these hacks will break translations.

@sledgehammer999
Copy link
Member

Better solution:
Changing the tstool.py in order to translate each context with its own original source, but I don't know if this can truly work or how much dependency qBittorrent webui has on this file so I didn't look into it.

tstool.py job is to extract the translatable strings into Qt's .ts file. Those .ts files are used to provide translations per locale.

Best solution:
Wait for it to be fixed from upstream, because these hacks will break translations.

qBittorrent will no longer offer translated string to 3rd party webuis. The 3rd party webuis are supposed to handle the translation themselves (usually client-side).

Hint: The builtin webui files when copied and loaded as an alternative webui == 3rd party webui.

But this solution won't fix everything, since when strings which translate combined by a number or another string (shown in the sidebar) are still broken as shown in this picture:

The copied webui is offered as a base/example to start off coding. It sucks that the contained strings aren't immediately usable as a 3rd party webui.

@MahdiMirzade
Copy link
Author

@sledgehammer999

tstool.py job is to extract the translatable strings into Qt's .ts file. Those .ts files are used to provide translations per locale.

Thank you for clarifying that.

qBittorrent will no longer offer translated string to 3rd party webuis. The 3rd party webuis are supposed to handle the translation themselves (usually client-side).
The copied webui is offered as a base/example to start off coding. It sucks that the contained strings aren't immediately usable as a 3rd party webui.

That's unfortunate, this requires extra code and effort when you simple want to change a background color (I know this is possible through extensions like dark reader) or an icon you don't like, It would be better if handling i18n translations from webui was at least it an option from settings.
Removing it killed a lot of themes out there.

However... thank you for guiding me.

@luzpaz
Copy link
Contributor

luzpaz commented Apr 9, 2024

Is this issue still valid ?

@luzpaz luzpaz added the Waiting info Waiting for participants to supply more info/fulfill template requirements label Apr 9, 2024
@HSHallucinations
Copy link

yes, i just found this thread while searching info on how to fix this :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Themes Waiting info Waiting for participants to supply more info/fulfill template requirements WebUI WebUI-related issues/changes
Projects
None yet
Development

No branches or pull requests

5 participants