Plasma 5 splashscreen: how to change language and region?


I have not yet found any plasma splash screen that values the regional time and date settings and language. They all tell me that “today is Sunday, March 24, 2024” or something similar. I would like to change this message to German format, like this: “Heute ist Sonntag, der 24. März 2024.” I know how to change “Today is” into “Heute ist”, but how do I make the following function return German names of months and days of the week?

text:Qt.formatDateTime(new Date(),“dddd MMMM d yyyy”)

Thanks very much in advance.

As documented in the reference for Qt.formatDateTime(), the second parameter can either be a text string (as in your example), an enum value that represents some known format (such as ISO 8601) or a locale object. The first option will render the text using the “C” locale (hard-coded English names).

If you want to use automatic local names, you can either remove the second parameter - as described in the above linked reference, if you don’t specify it then Qt will use the “short format” date string from the default locale, which should be the one you configured in Plasma - or you can specifically send the second parameter as the locale object you want to use: see the QLocale reference as to how to get one.

Thanks for your answer, but I have to tell you I don’t understand it, because I am not into coding these things. This is not “my” line, I just want to change this line in “Splash.qml” so that I am greeted with a German date.

If I simply remove the string, I am presented the localized short date format. That is a start. :slight_smile:

But how do I define my own localized format? I’d like to see the date presented as:

“Heute ist Sonntag, der 24. März 2024”

I have no idea how to achieve this, and sadly, I can’t make any sense out of all those options and parameters on the linked page. If you could provide the solution to this riddle to my, I’d be very thankful.

Well, if removing the string (2nd) parameter from Qt.formatDateTime() resulting in a correct date (i.e. using the correct locale), it means that your default locale is set correctly.

In that case, you can use the locale’s date formatting method - that is locale aware and will use the correct output: Qt.locale().toString(new Date(), "dddd MMM d yyyy") - or use any other format string that makes sense - using the Locale’s “stringifier” will produce the correct names.

I’m not a 100% sure how to produce the exact format you showed in the example, but it may be this: "dddd', der' d'.' MMMM YYYY". The format section at the end of the reference for Qt.formatDateTime() explains the meaning of things, but specifically note the use of single quotes to specify that text should be output as is and not as a placeholder for date parts.

BTW - if you can point me at the specific theme you are using that is doing the “english-standard” format, maybe I can suggest that fix that will use the locale’s format instead.

1 Like

Thank you very much for your patience and help!