Starting Another X Server with Different Locale - Ubuntu¶
While playing with quemu+lfslivecd under ubuntu, I came to know about the following commands which sets the locale environment for a linux system(atleast for lfslivecd). Using the following steps, I’ll share the commands and start a new X server with the modified environment.
Press
ctrl+alt+F1to go to virtual terminal 1 ortty1(To switch back to current gnome session, usectrl+alt+f7). Login to that terminal with different userid then the current userid who already logged into current gnome session.type the following command to set the timezone. you can see the timezone data file in /usr/share/zoneinfo/posix/{continent}/{country} where {continent} is the name of your continent like
Europe,Asiaetc., and {country} is your country name. This file should be pointed by TZ environment variable. The below command will change Timezone toEurope/Spain.$ export TZ="Europe/Spain" $ date
The date command will show the date according to the new timezone.
localedefcommand is used to create binary definitions in /usr/lib/locale directory from /usr/share/i18n/ directory, thei18ndirectory containscharmapsdirectory which contains encodings(likeUTF-8etc).i18nalso containslocalesdirectory which contains definitions for locales.localedefwill use these two directories to generate a definiton for particular language termed in{LANG}_{COUNTRY}.{ENCODING}(eg: es_ES.utf8 - means language codees(spanish), countryES(spain) and encoding inutf8). The following command will compile language definition for spanish language inutf8encoding.$ sudo localedef -f UTF-8 -i es_ES --no-archive 'es_ES.utf8' $ locale -a | grep 'es_ES.utf8'
locale -awill show whether language definition added or not.Now we are ready to change the LANG variable, this variable is used by all
glibc's language awareapplications to switch their output to a particular language, the ourput strings for a particular application for a particular language should be available in{application}.mofile inside /usr/share/locale/{LANG}/LC_MESSAGES directory(Distros provide.mofiles through language specific packages). Now switch the glibc applications to spanish using the following command,$ export LANG="es_ES.utf8" $ locale
localecommand will tell the current language.Finally start a new X server using the following command with modified locale. You can switch back to old X server using
ctrl+alt+F7. To switch to new X server, usectrl+alt+F9(orctrl+alt+F10if it started intty10virtual terminal)$ startx -- :1 -br -audit 0 -nolisten tcp
At first, it will ask to change the name of the directories to suite the new language, don’t rename unless you always going to work in the new locale environment.
Once you done,
Logoutfrom the New X server(new gnome session), it will stop the newly startedX serverand put you intty1virtual terminal.exitcommand will exit you from the tty1 terminal. Finally, switch back to old X server’s gnome session usingctrl+alt+F7.
Thats all.
