We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

[SDK] RPM validator marks hard coded paths in translation strings as 'hard coded' [answered]

asked 2018-08-20 20:57:56 +0300

updated 2018-08-22 11:01:10 +0300

jiit gravatar image

What's happening

If you write an app with ID-based translations where a /home/nemo path is hard coded the string will be marked as a hard coded path.

What's supposed to happen.

The RPM validator is right about the hard coded part but it shouldn't mark translations strings as invalid.

For example: ERROR [/usr/share/harbour-sailfinder/qml/pages/TermsPage.qml] Hardcoded path: //% "%0 keeps a minimalistic log in /home/nemo/.cache/%1/logging/log.txt for debugging purposes.

How to reproduce

  1. Create an app with ID based translations
  2. Add a path to your translation string
  3. Run the RPM validator on the generated RPM file

Environment

  • Sailfish SDK 1804
  • Sailfish OS 2.2.0.29
edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by Dylan Van Assche
close date 2018-08-31 12:57:13.323733

Comments

1

Why you think this is bug? You don't use /home/nemo in your code, isn't it? So do the same for translation strings.

coderus ( 2018-08-21 08:29:24 +0300 )edit

IMHO the developer should be free in what she/he writes in the translation strings. It might be an issue with other things that the validator checks or might check in the future.

Dylan Van Assche ( 2018-08-21 13:00:32 +0300 )edit

Can you replace /home/nemo with $HOME? Of course that is not such clear for the user than the actual path.

Rikujolla ( 2018-08-21 15:44:15 +0300 )edit

Well that's possible too to fix this issue, but still, the RPM validator should avoid any translations IMHO.

Dylan Van Assche ( 2018-08-31 09:19:12 +0300 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2018-08-31 11:10:00 +0300

martyone gravatar image

The point of all kind of rules enforced on Harbour intake is to ensure forward compatibility of your application in its binary form with Sailfish OS, including its variants.

The /home/nemo path may change in future versions of Sailfish OS, it may change in Sailfish OS variants, it may also change with sandboxing or multi-user use cases. It was never considered stable and so it should newer be hard-coded anywhere in the code base including dumb data like README files.

The RPM validator also suggests how to deal with it in a situation similar to your case:

As a rule of thumb follow the XDG Base Directory Specification and use $HOME instead of /home/nemo.

If you do not like displaying $HOME to the user, you can do what you already did with your application name and display name, utilizing QDir::homePath().

I would also suggest not to hard-code any part of the path in the translation string - it is not subject to localization and I am sure it is already programmatically available for substitution:

//% "%0 keeps a minimalistic log in %1 for debugging purposes.

For more information see our FAQ here: https://harbour.jolla.com/faq#2.13.0

edit flag offensive delete publish link more

Comments

Yeah, that's an option. Thanks for the info.

Dylan Van Assche ( 2018-08-31 12:56:50 +0300 )edit

Question tools

Follow
2 followers

Stats

Asked: 2018-08-20 20:57:56 +0300

Seen: 295 times

Last updated: Aug 31 '18