You can change the locale or only parts of it for a specific process before you create it by changing its environment.
Check it out by launching gnome-calculator via
env LC_NUMERIC=de_DE.UTF-8 gnome-calculator
if you currently use a period as your decimal point and via
env LC_NUMERIC=en_IE.UTF-8 gnome-calculator
if you currently use a comma as you decimal point.
The gnome-calculator process will use the locale stated before its call.
Note that this doesn't persist if you close the application and open it via the Dash or just call gnome-calculator in a terminal. In fact, it is process-specific and you can use several instances of gnome-calculator, some of them using periods and some of them using commas as their decimal points. Check it out by running gnome-calculator in a different terminal. It will use your normal settings.
Finding the right locale
You don't need to find a single locale which matches your needs for everything. Instead, it's sufficient to find one that matches what you want in a specific localization category. Here, we only care about the time format which can be changed by manipulating the environment variable LC_TIME.
You're probably interested in the international time format (ISO 8601) or the time format of some country of which you know the time format. For the former, use en_DK.UTF-8. For the latter, use the 2-letters abbreviation of the language in lowercase letters, an underscore, the 2-letters abbreviation for the county in capital letters, and then .UTF-8. For example, en_IE.UTF-8 is Irish English, de_DE.UTF-8 is German German, de_CH.UTF-8 is Swiss German, and fr_CH.UTF-8 is Swiss French.
Practical part
Now that you learned a bit about how cool Linux is, let's get to the practical part.
You probably launch your application via the Dash. If you do so, you use a desktop file. Find your desktop file. It's either in /usr/share/applications or in ~/.local/share/applications. The former is system-wide, the latter is user-specific.
I'll use Firefox as the example application. It's desktop file is /usr/share/applications/firefox.desktop.
After you found the desktop file you want to manipulate, copy it to your user's desktop file folder:
You can now manipulate the copy such that your changes only affect the user-local version.
Open it in a text editor. It doesn't matter whether you use a command line one or a graphical one. Normal Ubuntu comes with GEdit as its default graphical text editor:
gedit ~/.local/share/applications/firefox.desktop
If it doesn't work because you use a flavor of Ubuntu which doesn't come with GEdit, just use nano:
nano ~/.local/share/applications/firefox.desktop
Find the line which begins with Exec=. For Firefox, it's Exec=firefox %u. Then take whatever comes after Exec= and get it into this format with the locale you want instead of en_DK.UTF-8:
Exec=env LC_TIME=en_DK.UTF-8 firefox %u
Of course, you need to substitute en_DK.UTF-8 by whatever locale you want to use.
Save the file.
After you made your changes, you need to make the desktop file executable. The file you copied was executable but that property isn't copied, so you need to set it again for the new file. Do do so, run this command:
Dash usually updates the desktop files automatically but on slow systems, it might take a while. Or at least it did in some version. If it doesn't work instantly, log out and back in again.
Theoretical part
You can change the locale or only parts of it for a specific process before you create it by changing its environment.
Check it out by launching
gnome-calculator
viaif you currently use a period as your decimal point and via
if you currently use a comma as you decimal point.
The
gnome-calculator
process will use the locale stated before its call.Note that this doesn't persist if you close the application and open it via the Dash or just call
gnome-calculator
in a terminal. In fact, it is process-specific and you can use several instances ofgnome-calculator
, some of them using periods and some of them using commas as their decimal points. Check it out by runninggnome-calculator
in a different terminal. It will use your normal settings.Finding the right locale
You don't need to find a single locale which matches your needs for everything. Instead, it's sufficient to find one that matches what you want in a specific localization category. Here, we only care about the time format which can be changed by manipulating the environment variable
LC_TIME
.You're probably interested in the international time format (ISO 8601) or the time format of some country of which you know the time format. For the former, use
en_DK.UTF-8
. For the latter, use the 2-letters abbreviation of the language in lowercase letters, an underscore, the 2-letters abbreviation for the county in capital letters, and then.UTF-8
. For example,en_IE.UTF-8
is Irish English,de_DE.UTF-8
is German German,de_CH.UTF-8
is Swiss German, andfr_CH.UTF-8
is Swiss French.Practical part
Now that you learned a bit about how cool Linux is, let's get to the practical part.
You probably launch your application via the Dash. If you do so, you use a desktop file. Find your desktop file. It's either in
/usr/share/applications
or in~/.local/share/applications
. The former is system-wide, the latter is user-specific.I'll use Firefox as the example application. It's desktop file is
/usr/share/applications/firefox.desktop
.After you found the desktop file you want to manipulate, copy it to your user's desktop file folder:
You can now manipulate the copy such that your changes only affect the user-local version.
Open it in a text editor. It doesn't matter whether you use a command line one or a graphical one. Normal Ubuntu comes with GEdit as its default graphical text editor:
If it doesn't work because you use a flavor of Ubuntu which doesn't come with GEdit, just use
nano
:Find the line which begins with
Exec=
. For Firefox, it'sExec=firefox %u
. Then take whatever comes afterExec=
and get it into this format with the locale you want instead ofen_DK.UTF-8
:Of course, you need to substitute
en_DK.UTF-8
by whatever locale you want to use.Save the file.
After you made your changes, you need to make the desktop file executable. The file you copied was executable but that property isn't copied, so you need to set it again for the new file. Do do so, run this command:
Now, restart your application.
Dash usually updates the desktop files automatically but on slow systems, it might take a while. Or at least it did in some version. If it doesn't work instantly, log out and back in again.
I prefer a wrapper shell script for doing it. First create the script with a text editor of your choice. Example script:
Then make it executable:
Advantages with this method:
.desktop
file which would override possible changes to the original.desktop
file when the package is updated.