Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Translations are not working in ksnip snap package #662

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

Open
Lvaskz opened this issue Jun 5, 2021 · 45 comments
Open

Translations are not working in ksnip snap package #662

Lvaskz opened this issue Jun 5, 2021 · 45 comments
Assignees
Labels

Comments

@Lvaskz
Copy link
Contributor

Lvaskz commented Jun 5, 2021

Describe the bug
Ksnip is not translated to spanish

To Reproduce
Steps to reproduce the behavior:

  1. Set system language to spanish
  2. Go to kde discover, find ksnip snap package
  3. Click on install
  4. Open ksnip
  5. See error not translated to spanish

Expected behavior
Ksnip translated to spanish language

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [kde neon 5.21.5]
  • Distribution in case of Linux [e.g. Ubuntu]
  • Window System in case of Linux [e.g. X11]
  • ksnip version [1.90]
  • How did you install ksnip [snap package]

Additional context
Add any other context about the problem here.

@Lvaskz Lvaskz added the bug label Jun 5, 2021
@DamirPorobic
Copy link
Member

@LyzardKing could this be a Plasma only issue or is it affecting Gnome too?

@LyzardKing
Copy link
Contributor

Strange... I'll look into it, the snap should have the different languages included, and we didn't explicitly set a language

@DamirPorobic
Copy link
Member

@LyzardKing have you had the chance to look into this?

@LyzardKing
Copy link
Contributor

I looked at this today, and the status is:
The translation files are in the snap (in share/ksnip/translations/*.qm)
ksnip fails to load them, but I'm not sure if it's looking in the correct paths.

@Lvaskz
Copy link
Contributor Author

Lvaskz commented Jul 15, 2021

hi, any progress?

@DamirPorobic
Copy link
Member

Sorry, haven't had time to look into it yet.

@LyzardKing
Copy link
Contributor

I haven't had too much time either...
but I keep getting the error when I open ksnip: Warning: Unable to find any translation files for ksnip.

Where should ksnip look for the translations? Is there a debug option that can show the files it's trying to access? I tried an strace but that didn't return anything useful

@DamirPorobic
Copy link
Member

@LyzardKing we are looking here for the translation files on Unix based system:
image

I'll try to add some logging that shows where we're looking for translations.

@LyzardKing
Copy link
Contributor

That folder is in the snap at /snap/ksnip/current/share/ksnip/translations.
If you could add some logs that would be very useful. Also, what is it using to detect the system language? Is it looking at env variables (like LANG)?

@DamirPorobic
Copy link
Member

It's written into the buildConfig.h file by cmake, then you get fixed values:
image

I'm writing the logger right now.

@DamirPorobic
Copy link
Member

@LyzardKing I've added a debug logger, you have to enable it through the application settings. It doesn't log to much at the moment but the translation search paths should be there.

@LyzardKing
Copy link
Contributor

LyzardKing commented Sep 17, 2021

it's looking in the wrong folders...

Debug: Loading translation for ksnip from /share/ksnip/translations, failed.
Debug: Loading translation for ksnip from /snap/ksnip/388/bin//share/ksnip/translations, failed.
Debug: Loading translation for ksnip from /snap/ksnip/388/bin/../../share/ksnip/translations, failed.

I'll debug the snap builder and test it

EDIT: Just as a note, it should be looking in snap/ksnip/388/share/ksnip/translations

@DamirPorobic
Copy link
Member

The "current" folder is breaking the search, where does that come from? Without the current the third search would have found it.

@LyzardKing
Copy link
Contributor

@DamirPorobic In the third attempt, why is it going up two directories? Is that intended?

@LyzardKing
Copy link
Contributor

The "current" folder is replaced by the 388 folder.
It's a symlink to the latest installed version of the snap package.
You could have versions 386, 387, 388 installed, and current would point to 388 by default

@LyzardKing
Copy link
Contributor

LyzardKing commented Sep 17, 2021

in set(KSNIP_LANG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ksnip/translations")
the variable CMAKE_INSTALL_PREFIX should be /snap/ksnip/388

and DATAROOTDIR should only add share

@DamirPorobic
Copy link
Member

Yes, it's intended because at run time we only know where the executable is, that being in the bin directory and we assume from that position, up two directories should be the shared folder. I think that was done for the snap specifically.
So we should actually go only one up? I think that used to work, is that number in the structure new?

@LyzardKing
Copy link
Contributor

shouldn't the loadTranslationFromRelativePath function look up one directory? Since it starts from the executable, you have to go up one, then in shared. The shared folder would not be found in the bin folder

@DamirPorobic
Copy link
Member

We are located in /snap/ksnip/388/bin and we are told that the translations are in /share/ksnip/translations. We can look in the absolute path /share/ksnip/translations or relative from us, that would be /snap/ksnip/388/bin/share/ksnip/translations but none of them is correct, we should be going one back and then check for it /snap/ksnip/388/share/ksnip/translations.

And I was wrong, that two directories up was for the AppImage, not the snap.

@LyzardKing
Copy link
Contributor

But the problem is that the "appimage" one is not going back one, but two directories.
If it were looking in /snap/ksnip/388/share/ksnip/translations it would be correct

@LyzardKing
Copy link
Contributor

in TranslationLoader.cpp the two paths are set as:
auto relativePathToAppDir = QCoreApplication::applicationDirPath() + QLatin1String("/");
and
auto relativePathToAppDir = QCoreApplication::applicationDirPath() + QLatin1String("/../..");

So it's never going up one folder, only none ore 2

@DamirPorobic
Copy link
Member

Yeah, we need an additional search. Strange thought that it used to work and now doesn't.

@LyzardKing
Copy link
Contributor

but what system uses the bin/share structure?

@LyzardKing
Copy link
Contributor

we could fix it in the snap directly with a layout probably... I'll test it

@DamirPorobic
Copy link
Member

but what system uses the bin/share structure?

Under windows the translations are next to the executable in a folder called translations. Under Unix, they're in this share directory. Cross-platform, different binaries, sandboxing, dude, it's crazy xD

@DamirPorobic
Copy link
Member

@LyzardKing have you tried this layout or should I extend the translation loader?

@LyzardKing
Copy link
Contributor

I tried but unfortunately it cannot link properly to the desired folder.

@LyzardKing
Copy link
Contributor

but wait a second.. I have another idea

@LyzardKing
Copy link
Contributor

No.. it doesn't work. If you want to add the translation loader (making it look one directory up) it should work.
If we then find a better way we can revisit

@DamirPorobic
Copy link
Member

Fix pushed, can someone test please?

@LyzardKing
Copy link
Contributor

Debug: Loading translation for ksnip from /share/ksnip/translations, failed.
Debug: Loading translation for ksnip from /snap/ksnip/389/bin//share/ksnip/translations, failed.
Debug: Loading translation for ksnip from /snap/ksnip/389/bin/../../share/ksnip/translations, failed.

It's not up yet I guess

@LyzardKing
Copy link
Contributor

I managed to link the folder in the snap to the correct location, but it's still not finding the translation files, even though it's looking in a folder that has the files

@DamirPorobic
Copy link
Member

Have you tried with the updated translation loader?

@LyzardKing
Copy link
Contributor

I tried the latest edge version, and it doesn't make a difference

@LyzardKing
Copy link
Contributor

to be sure that it is the latest you could trigger a rebuild from the snapcraft website

@DamirPorobic
Copy link
Member

I have triggered a new build. The last build was 7 hours old.

@LyzardKing
Copy link
Contributor

Debug: Loading translation for ksnip from /share/ksnip/translations, failed.
Debug: Loading translation for ksnip from /snap/ksnip/390/bin//share/ksnip/translations, failed.
Debug: Loading translation for ksnip from /snap/ksnip/390/bin/../../share/ksnip/translations, failed.
Debug: Loading translation for ksnip from /snap/ksnip/390/bin/../share/ksnip/translations, failed.

It still doesn't work. There is something weird in how ksnip is loading the folder...
I'll try something else now and let you know

@DamirPorobic
Copy link
Member

Could it be a permission issue? That we're not allowed to access that directory?

@DamirPorobic
Copy link
Member

@LyzardKing any updates?

@LyzardKing
Copy link
Contributor

I can't get it to work...
I don't have too much time to debug this before the weekend.. so I'll look at it more in the next days.
I want to try with a symlink in the "correct" folder, and adding a preload to remove the issue of hardcoded paths.
I'll let you know if it works

@DamirPorobic
Copy link
Member

Ok, thanks!

@DamirPorobic
Copy link
Member

@LyzardKing did you have time to look into this further? Maybe have a look at other projects, this seems to be a standard use case that you have translations in snaps.

@DamirPorobic
Copy link
Member

@LyzardKing any change we get this into 1.9.2? I'll be wrapping up the patch release soon, would be nice to close this one finally.

@LyzardKing
Copy link
Contributor

I tried, but the snap continues to give the same error. Even if I force the translation to the correct folder I still get the same error.
Does the translation system have dependencies that we did not include in the snap?

@DamirPorobic
Copy link
Member

For translations there is as qt5-linguist component but under Ubuntu I think it's part of qttools5-dev. But if the component would be missing, shouldn't we get an error, probably not even be able to build. Can we check some other Qt based Snaps, how they're doing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants