At System → Administration → Language support → Text. I can only choose standard locales, but I would like to fine-tune. For example in Windows I could customise things like time and date format, measure units, decimal separator, currency, etc manually – how can I do this in Ubuntu?
Ubuntu – How to customize a system locale
customizationlocale
Related Solutions
If you execute locale
you can see the language variables that are used for various sections of the operating system:
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
More about locale variables in the gettext manual: Locale Environment Variables - GNU `gettext' utilities
You can export these variables e.g. export LC_PAPER="ru_RU.UTF-8"
- this will make a temporary change.
If you want to make it permanent you can change the regional formats using gnome-language-selector
. Or you can add the export command in ~/.profile and/or ~/.bashrc
For the papersize, I found that you can edit /etc/papersize
- change "letter" to "a4".
You might also need to set export LC_PAPER="en_GB.UTF_8"
(or maybe export LC_PAPER="ru_RU.UTF_8"
if ru_RU defaults to A4)
Source: answers.launchpad.net: Question #6846 : Questions : “evince” package : Ubuntu
P.S. Personally I use en_GB (English / United Kingdom) for everything since it uses the SI metric system instead of American English and US units.
You can manually edit the localisation settings. From your example I would suggest that you use some English version as the base language and add other bits according to your needs. Other bits you can get from other locale settings that must be also installed in your system. That is, if you want the system to be in Italian, dates in Russian style and numbers in Finnish the these packages to support those languages must be installed in your system.
You can see the full list of locales installed in your system by running this command in the terminal:
$ locale -a.
Or you can open System settings->Language support->Install/Remove languages. All the installed languages will be checked. To add or remove languages just check some more or uncheck unwanted ones. From your example I advise you use just English(includes many versions)+Spanish. The specifics of your current localisation settings can be checked with this command:
$ locale
Here is what these settings refer to:
LANG - Provides default value for LC_* variables that have not been explicitly set.
LC_ALL - Overrides individual LC_* settings: if LC_ALL is set, none of the below have any effect.
LC_CTYPE - How characters are classified as letters, numbers etc. This determines things like how characters are converted between upper and lower case.
LC_NUMERIC - How you format your numbers. For example, in many countries a period (.) is used as a decimal separator, while others use a comma (,).
LC_TIME - How your time and date are formatted. Use for example "en_DK.UTF-8" to get a 24-hour-clock in some programs.
LC_COLLATE - How strings (file names...) are alphabetically sorted. Using the "C" or "POSIX" locale here results in a strcmp()-like sort order, which may be preferable to language-specific locales.
LC_MONETARY - What currency you use, its name, and its symbol.
LC_MESSAGES - What language should be used for system messages.
LC_PAPER - Paper sizes: 11 x 17 inches, A4, etc.
LC_NAME - How names are represented (surname first or last, etc.).
LC_ADDRESS - How addresses are formatted (country first or last, where zip code goes etc.).
LC_TELEPHONE - What your telephone numbers look like.
LC_MEASUREMENT - What units of measurement are used (feet, meters, pounds, kilos etc.).
LC_IDENTIFICATION - Metadata about the locale information.
Here is your fix (hopefully):
For folders and the system use chosen English language as the main language and that's it.
For numeric values (with dots to separate decimals and commas to separate thousands) you could either just use the British English as the base for your system. But if you chose to use US English instead modify the “.profile” file in your home directory by adding this line to it:
export LC_NUMERIC=”en_GB.utf8”
For the dates and calendar you just need to change the time format localisation to Spanish (as far as I know then also the weeks will start with Mondays). So add also this line to the same .profile file in your home directory:
export LC_TIME="es_ES.utf8"
Localisation will be applied on the next time you login to Ubuntu. You can check then the results by running “locale” command once more or just see if everything functions as you would like to.
Keyboard settings are separate from localisation settings and for your specific problem with the Apple keyboard use “console-data” package. For this run:
sudo dpkg-reconfigure console-data
But as probably the package is not yet installed in your system run this:
sudo apt-get install console-data
The install includes configuring your keyboard settings, so probably that is all you need. The mac Spanish keyboard was listed there – hopefully that is what you need.
Hopefully these tips will solve your problems.
Related Question
- Ubuntu – English as a system language but Russian regional settings
- Ubuntu – How to reconfigure locales properly on the desktop after installation
- locale – How to Change System Locale When Setup in a Non-Official Language
- How to Create a New System Locale
- Language Support – Set System Language to English with Swedish Locale on Kubuntu
Best Answer
This answer will demonstrate how to fully customize a locale, optionally using an existing locale as a base. The type of locale that will be used in this answer is the
i18n
type; such type of locale will be implied in every mention of the word "locale" in the body of the answer.Find a guide
The first thing you need to customize a locale, is get to know the format of the locale. This web locale editor has a comprehensive description of every field in a locale, despite not being usable by just anyone in a right-away manner. This will be the guide to use.
Needed tools
The only tools you need to work with locales are
I recommend you to create a directory and save everything related with the work you will do on the locale to it.
Text-to-unicode converter (encodestr)
NOTE: if you are using non-common characters you may have problems with the script I write below; you might want to take a look at the alternative scripts linked by nass.
Save the following code to a file. This file will be identified by your system as a python script, which is alright because it is one. This guide assumes you called the script
encodestr
.After you have saved it, give the file execution permission - this will come in handy. You can do that using nautilus, or by running from a terminal the following command, on the directory in which you saved the script:
chmod +x encodestr
.You can now test this script by running on the same directory:
./encodestr hello
. You should get an output equal to<U0068><U0065><U006C><U006C><U006F>
.Modify an existing locale
Modifying an existing locale is the easiest case, as ideally you will pick a locale that fits your needs almost totally, in which case you need to make only small modifications. To tailor it, you can use the guide to know which of the sections are the ones you want to change, and how you can change them. All the installed locales reside in
/usr/share/i18n/locales
, however the guide contains pretty much every locale ever created.However, the first thing you will notice when you open a locale is that you will read english words as much as weird
<UXXXX>
codes. You will need to be able to create these codes - this is where theencodestr
script comes.When you know which sections you have to change, you need to know each field contained in the section.
Now that you know which fields to modify, use the guide again to find out what values does the field accept.
Just when you know what to write on the fields you want to modify, run the text through the
encodestr
script to get its encoded equivalent.NOTE: Not every field needs to be encoded, use an existing locale as a reference if needed.
After you have modified every field you wanted to, you will need to proceed to install the locale to the system, so it can be used. Proceed to the installation section for this.
Creating a locale from scratch
As opposed to modifying one, the other method you can use to create your custom locale is working on it from scratch. This is not very difficult if - again - you use the guide. Here's a useful tip though: you can copy sections from other locales without actual copy and paste methods. You just have to follow this format:
Where
LC_SECTION
is the section you want to modify, andlocale
is the locale you want to copy that section from.Installing your custom locale
The steps I am going to show below may not be optimal, but work.
Compile your locale. Don't panic! This takes no time. Just run the command
sudo localedef -i custom -f UTF-8 custom.UTF-8 -c -v
wherecustom
is the name of your locale.Copy your locale to the
/usr/share/i18n/locales/
directory. You will definitely need sudo priviledges to do this, and you can do it with the commandsudo cp locale /usr/share/i18n/locales/
wherelocale
is the filename of your custom locale.Specify your locale in
/var/lib/locales/supported.d/
. For example, create a file name/var/lib/locales/supported.d/asd
and add the linecustom UTF-8
, where custom is the name of your locale.Run the magic command. I actually don't know what exactly this command does, but it is crucial. Run
sudo locale-gen
. It is most probable it generates references to the available locales where needed.Tell your system to use the locale. If you want the locale to be used on a system-wide manner, modify the
/etc/environment
file. If not, you can modify your~/.profile
file, or any other one that is sourced at startup. If you don't know what the latter means don't worry, just use the~/.profile
file. To know what you have to write in it, first run thelocale
command. It should issue a list with items likeLANGUAGE
,LC_MESSAGES
,LC_CTYPE
and many others. You will write, for each of the sections you want (listed by the previous command), on separate lines, thisSECTION="locale"
whereSECTION
is the section andlocale
the name of your custom locale.NOTE: If you want to use one locale for every locale setting, write
LC_ALL="locale"
wherelocale
is the name of your custom locale. If you want to use a locale for everything but for the language, you can writeLANG="locale"
and (on another line, of course)LANGUAGE="locale":XX
whereXX
is the 2 letter code for the language you want.You have finished
The next time you log in, your locale should be in use. You can test this by running the
locale
command again.Please comment about inconsistencies or false statements in this guide!