Don't use formatDateTime to get weekday names, as it doesn't use LANG

Tracked by Jolla

asked 2018-09-13 10:12:52 +0300

Mohjive gravatar image

I like my interface language to be English but I like the number and date formats to be in my locale (sv_SE), so I've manually changed my locale to reflect this. This have the effect that short weekday names are shown in Swedish, while the rest of the UI is in English. This is because Qt.formatDateTime(date, "ddd") uses LC_TIME setting instead of LANG. Suggestion is to use a localized string, like the long weekday names: Format.formatDate(date, Formatter.WeekdayNameStandalone).

I've found four instances this happens so far:

  • DateGrid in Calendar
  • forecast view in weather app
  • Edit alarm view in clock
  • account sync settings in settings app

I've worked around it for now using a temporary variables with the Formatter string and then using substring(0,3) method on that.

edit retag flag offensive close delete

Comments

Aren't you supposed to generate your own locale in this case? I guess this is how it is done in a regular linux distro. E.g. you set en_SE and run locale-gen. Then set it in the system. If this works in Sailfish, I have no idea.

johanh ( 2018-09-13 10:39:08 +0300 )edit

@johanh: maybe you're right; I know too little about localization. But I do know that in my computers (windows and MacOS), when I set language and format to different values, I don't get this issue. Maybe it's a Linux thing (it was too many years ago I ran Linux on my laptop)?

Mohjive ( 2018-09-13 10:55:46 +0300 )edit

I think Sailfish is lacking something. In my Linux computers I'm able to set sv_FI as locale (this has worked as long as I can remember, probably 10 years or more), but in Sailfish, there is only Swedish or Finnish setting. So when I select Swedish, the locale is set to sv_SE. The standard set of locales in glibc corresponds to official languages in countries, so that is why you can find e.g. sv_FI, nl_BE or fr_CA. Then again, en_SE or en_FI is not part of the standard glibc locale set, but you are supposed to be able to generate it. One exception is en_DK that someone managed to slip into the glibc repository one time when the maintainer wasn't observant. But since that, no other non-standard combination has slipped through.

johanh ( 2018-09-13 11:08:29 +0300 )edit
1

Yes, but you should be able to set language and format locales separately. I have manually set LANG=en_US and LC_ALL=sv_SE and it should work without Swedish language slipping through to the UI.

It really comes down to that I think UI should use localized strings, and not trust output from a library function to be in the correct language.

Mohjive ( 2018-09-13 11:08:29 +0300 )edit
1

Thanks for the suggestion @Mohjive, I passed this forward as a request.

jiit ( 2018-09-13 11:47:37 +0300 )edit