Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

My custom glibc locale

The narrative

It all started when I saw in Thunar that the default display of time for items older than a day, showed timestamp as "1/30/2022 at 1:30PM". I appreciate the use of the date format "Today at 1:30PM" format in general, but I like to use a 24-hour clock, and also I adopted ISO 8601 date stamps in 2013, Thunar's format just kind of bugged me.

So I flexed my great Internet searching skills, memory, and poking at things in silly ways, until I got what I wanted! I learned how to set up a new locale file, for which I picked the name en_BS (for B. Stack). I adjusted the time formats to be the exact way I want! That was the easy part.

Getting the locale compiled isn't that hard: you run localedef(1). The trouble lies in distributing it in the distro-appropriate ways! Everything I do gets deployed to a number of systems, so I'm not about to run a manual command on a heterogenous (distro, not OS) fleet. I had the keystrokes down in a non-free OS for getting all the formats correct in that one dialog.

I remembered that a long time ago I came across a project or English in Russia locale project, and they helpfully produce an rpm! So I just ripped off their work for how to deploy. The simple answer: have the maintainer script for postinstall just run the localedef command.

I found a great answer for this task on Ask Ubuntu, the manual way. So I decided to just make a dpkg for Devuan GNU+Linux with the same design as the rpm: use the maintainer scripts.

And now my Thunar displays the "Today" preference with rational timestamps otherwise!

The readme file

Readme for locale-en_BS

locale-en_BS upstream

This is an original package. It contains merely the customized locale for GNU C Library that I prefer.

Reason for existing

To practice with locales, as well as make the default date stamps more sane (I'm looking at you, Thunar!).

Alternatives

Use en_US like the majority of the systems in this great nation.

Dependencies

Glibc. The internationalization of other C libraries is undetermined, but also not important for my use case.

Package recipes are available for rpm and dpkg.

Installing

Rpm

Visit the copr package.

Dpkg

Visit the obs package.

Manual

The en_BS file is the bare locale file. You can use it in your own GNU environment by manually compiling it and setting your system to use it.

Compile the file to the default location (requires root).

sudo localedef -i en_BS -f UTF-8 en_BS.UTF-8

Now the locale is available to use, until the next time glibc is updated. Use the packages for persistence. To use the locale, you can do this on Devuan:

sudo update-locale LC_TIME=en_BS

Or this on Fedora:

sudo localectl set-locale LC_TIME=en_BS

Or alternatively:

echo 'export LC_TME=en_BS.utf8' | sudo tee -a /etc/environment

References

Weblinks
  1. en_RU project: Readme and main Sourceforge page
  2. customization - How can I customize a system locale? - Ask Ubuntu
  3. Set custom locales in Gnome3 (on Fedora 20) - Unix & Linux Stack Exchange
  4. command line - How can I change the default date format (using LC_TIME)? - Ask Ubuntu
Man pages

localedef(1) update-locale(8)

Comments