<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Knowledge Base (Posts about i18n)</title><link>https://bgstack15.ddns.net/blog/</link><description></description><atom:link href="https://bgstack15.ddns.net/blog/categories/i18n.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2022 &lt;a href="mailto:bgstack15@gmail.com"&gt;bgstack15&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-SA"
style="border-width:0; margin-bottom:12px;"
src="https://bgstack15.ddns.net/.images/l_by-sa_4.0_88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Mon, 07 Mar 2022 20:15:29 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>My custom glibc locale</title><link>https://bgstack15.ddns.net/blog/posts/2022/03/06/my-custom-glibc-locale/</link><dc:creator>bgstack15</dc:creator><description>&lt;h2&gt;The narrative&lt;/h2&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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 &lt;strong&gt;en_BS&lt;/strong&gt; (for B. Stack). I adjusted the time formats to be the exact way I want! That was the easy part.&lt;/p&gt;
&lt;p&gt;Getting the locale compiled isn't that hard: you run &lt;code&gt;localedef(1)&lt;/code&gt;. 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.&lt;/p&gt;
&lt;p&gt;I remembered that a long time ago I came across a project or &lt;a href="https://en-ru.sourceforge.io/en.html"&gt;English in Russia locale&lt;/a&gt; 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.&lt;/p&gt;
&lt;p&gt;I found a great answer for this task on &lt;a href="https://askubuntu.com/questions/21316/how-can-i-customize-a-system-locale/162714#162714"&gt;Ask Ubuntu&lt;/a&gt;, 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.&lt;/p&gt;
&lt;p&gt;And now my Thunar displays the "Today" preference with rational timestamps otherwise!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://bgstack15.ddns.net/blog/2022/03/thunar_with_my_locale.png"&gt;&lt;img alt="" src="https://bgstack15.ddns.net/blog/2022/03/thunar_with_my_locale.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;The readme file&lt;/h2&gt;
&lt;h3&gt;Readme for &lt;code&gt;locale-en_BS&lt;/code&gt;&lt;/h3&gt;
&lt;h4&gt;&lt;code&gt;locale-en_BS&lt;/code&gt; upstream&lt;/h4&gt;
&lt;p&gt;This is an original &lt;a href="https://gitlab.com/bgstack15/locale-en_BS"&gt;package&lt;/a&gt;. It contains merely the customized locale for GNU C Library that I prefer.&lt;/p&gt;
&lt;h4&gt;Reason for existing&lt;/h4&gt;
&lt;p&gt;To practice with locales, as well as make the default date stamps more sane (I'm looking at you, Thunar!).&lt;/p&gt;
&lt;h4&gt;Alternatives&lt;/h4&gt;
&lt;p&gt;Use &lt;code&gt;en_US&lt;/code&gt; like the majority of the systems in this great nation.&lt;/p&gt;
&lt;h4&gt;Dependencies&lt;/h4&gt;
&lt;p&gt;Glibc. The internationalization of other C libraries is undetermined, but also not important for my use case.&lt;/p&gt;
&lt;p&gt;Package recipes are available for &lt;a href="https://gitlab.com/bgstack15/locale-en_BS/-/blob/master/locale-en_BS.spec"&gt;rpm&lt;/a&gt; and &lt;a href="https://gitlab.com/bgstack15/locale-en_BS/-/tree/master/debian"&gt;dpkg&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;Installing&lt;/h4&gt;
&lt;h5&gt;Rpm&lt;/h5&gt;
&lt;p&gt;Visit the &lt;a href="https://copr.fedorainfracloud.org/coprs/bgstack15/stackrpms/package/locale-en_BS/"&gt;copr package&lt;/a&gt;.&lt;/p&gt;
&lt;h5&gt;Dpkg&lt;/h5&gt;
&lt;p&gt;Visit the &lt;a href="https://build.opensuse.org/package/show/home:bgstack15/locale-en-bs"&gt;obs package&lt;/a&gt;.&lt;/p&gt;
&lt;h5&gt;Manual&lt;/h5&gt;
&lt;p&gt;The &lt;code&gt;en_BS&lt;/code&gt; 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.&lt;/p&gt;
&lt;p&gt;Compile the file to the default location (requires root).&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo localedef -i en_BS -f UTF-8 en_BS.UTF-8
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;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:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo update-locale LC_TIME=en_BS
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or this on Fedora:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo localectl set-locale LC_TIME=en_BS
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or alternatively:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'export LC_TME=en_BS.utf8'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sudo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tee&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;environment&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;References&lt;/h4&gt;
&lt;h5&gt;Weblinks&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;en_RU&lt;/code&gt; project: &lt;a href="https://en-ru.sourceforge.io/en.html"&gt;Readme&lt;/a&gt; and main &lt;a href="https://sourceforge.net/projects/en-ru/"&gt;Sourceforge page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://askubuntu.com/questions/21316/how-can-i-customize-a-system-locale/162714#162714"&gt;customization - How can I customize a system locale? - Ask Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://unix.stackexchange.com/questions/136920/set-custom-locales-in-gnome3-on-fedora-20"&gt;Set custom locales in Gnome3 (on Fedora 20) - Unix &amp;amp; Linux Stack Exchange&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://askubuntu.com/questions/1064167/how-can-i-change-the-default-date-format-using-lc-time"&gt;command line - How can I change the default date format (using LC_TIME)? - Ask Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h5&gt;Man pages&lt;/h5&gt;
&lt;p&gt;&lt;code&gt;localedef(1)&lt;/code&gt;
&lt;code&gt;update-locale(8)&lt;/code&gt;&lt;/p&gt;</description><category>glibc</category><category>i18n</category><category>lc_time</category><category>locale</category><category>localization</category><category>time</category><guid>https://bgstack15.ddns.net/blog/posts/2022/03/06/my-custom-glibc-locale/</guid><pubDate>Sun, 06 Mar 2022 13:58:08 GMT</pubDate></item></channel></rss>