[SOLVED] Capitalize datetime when locale is lowercase?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm using the extension Clock Override to format the top bar datetime on Ubuntu 18.04, and I'm using the %A option to display my locale's (Norwegian) full weekday. This, however, is in all lowercase ("søndag", which is grammatically correct Norwegian), but I want to have it capitalized in my top bar ("Søndag").
Thank you for replying!
I believe that the all-lowercase locale is correct, as weekdays are generally not capitalized in Norwegian.
However, when the weekday is written by itself in the top bar, I'd like to have it capitalized nevertheless (as if it was at the beginning of a sentence, or in a title).
Is there any way to tweak the datetime output, without modifying the locale? (As mentioned, I believe the locale is correct – just not what I want)
In your login, create a sub-directory called myProgs - say.
In this, create a script called that takes the date and substitutes montag with Montag and so on. A simple if .. elif .. fi would do. The script can have the same name as date with options.
Make the script executable.
Put this sub directory first in your path like PATH=~myProgs:$PATH
Now date (which is your date command) should work as the regular date but Capitalizing (really Properizing) the day names.
I was wondering why it was never fixed if it wasn't correct.
do you know what is actually displaying it?
I suspect the extension is just adding the format string to the configuration for that
if its not an option the code could be hacked to change the string
can you set the font?
since the first letter is not repeated ( in the days at least ) you could hack a custom font to have the lowercase s m t o f l be upper. but that is ugly.
it is probably easier ( and cleaner ) to just add a capitalise option to the "top bar" or the extension depending on what sets the string
so it looks like a problem in the locales-all package
which comes from glibc source
The same is true in other languages, like Dutch (both nl_NL as well as nl_NL.utf8):
all weekdays AND months names are all lowercase, while in en_US.utf8 they are all capitalized.
For fun I tested German (de_DE*) and French (fr_FR*) too: the first is (properly) capitalized (in German all nouns are capitalized), the latter is not.
function overrider(lbl) {
var FORMAT = settings.get_string("override-string");
var now = GLib.DateTime.new_now_local();
var desired = Format.format(FORMAT, now);
//var Desired = desired.charAt(0).toUpperCase() + name.slice(1)var Desired = desired.charAt(0).toUpperCase() + desired.slice(1)
// I believe that would make the fist char. Uppercase
var t = lbl.get_text();
//if (t != desired) {
if (t != Desired) {
last = t;
//lbl.set_text(desired);
lbl.set_text(Desired);
}
}
That assumes day is the first thing in the string
I have no idea if it would work ( or is anywhere near correct )
It is a proof of concept, an ugly hack
I don't use gnome, so can't test it right now
I may install gnome soon, because now I just want to know if it works
Edit, was an error in my original edit
which is moot, since it doesn't work anyway
I'll plug away at it
I'm using the extension Clock Override to format the top bar datetime on Ubuntu 18.04, and I'm using the %A option to display my locale's (Norwegian) full weekday. This, however, is in all lowercase ("søndag", which is grammatically correct Norwegian), but I want to have it capitalized in my top bar ("Søndag").
Is there any way I can achieve this?
Unless you want to get into coding, this depends on two things:
The capabilities of the clock override extension.
If it can execute external commands, we can help, if not I'm guessing you're dependent on the formatting options available, most likely only what is provided by strtime. See
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.