Zum Inhalt springen

Xfce/Sprache

Aus Foxwiki

Language in Xfce

1. Overview

In multi-user environments, we might need to change the user interface or graphical user interface (GUI) language to interact with the system in our preferred language. For instance, this task becomes essential when we want to personalize the computing environment and standardize its visual elements according to our native language.

In this tutorial, we’ll check out methods for changing the UI language on a Ubuntu 22.04 Xfce desktop.

Notably, our examples involve changing the UI language to Aragonese using the shell and the Language Support utility.

2. Using the Shell

We can change the UI language in Xfce through the shell in case we prefer command-line interactions.

Particularly, in this method, we’ll configure the locale settings and modify specific files to set the desired language as Aragonese.

For this, let’s open the terminal and use locale-gen to generate locale for Aragonese which is an_ES.UTF-8:

$ sudo locale-gen an_ES.UTF-8

Generating locales (this might take a while)...

 an_ES.UTF-8... done

Generation complete.

Once the locale generation is complete, we edit the ~/.i18n file in a text editor like nano:

$ sudo nano ~/.i18n

Then, we add the code to export the language-related environment variables:

export LANGUAGE=an_ES.utf8

export LANG=an_ES.utf8 export LC_ALL=an_ES.utf8

In the above script, we specify an_ES.utf8 as the value of the LANGUAGE, LANG, and LC_ALL variables, respectively.

Thus, we set the language, and default locale, and override all other locale settings with the Aragonese locale.

After adding the code, we press CTRL+O and Return to save the ~/.i18n file and CTRL+X to exit the nano editor:

"saving .i18n script in xfce"

Then, we modify the ~/.config/xfce4/xinitrc file to include the language settings during Xfce session initialization:

$ sudo nano ~/.config/xfce4/xinitrc

Next, we add the code in the ~/.config/xfce4/xinitrc file:

#!/bin/sh

if [ -f "$HOME/.i18n" ]; then

   . "$HOME/.i18n"

fi . /etc/xdg/xfce4/xinitrc

In the above script, the if statement with the -f option checks if the $HOME/.i18n file exists. If so, the dot . which is shorthand for the source command, reads and executes commands from $HOME/.i18n containing the environment variable settings for UI language configurations.

Next, we source the /etc/xdg/xfce4/xinitrc script with . to incorporate its functionality into the current shell session.

After adding the code, we press CTRL+O and Return to save the ~/.config/xfce4/xinitrc file and CTRL+X to exit the nano editor:

"saving content of xinitrc file in xfce linux"

Lastly, we reboot the system to apply the language and switch to the new UI language:

$ reboot

Now, we open any application, such as Calendar on our system to test the configured settings:

"viewing calendar in xfce for testing"

As a result, we can see Aragonese as the UI language of the components of the Calendar application.

3. Using the Language Support Utility

In Xfce, Language Support is a graphical tool that enables us to manage the language-related configuration. Specifically, this method is often more user-friendly and doesn’t require extensive command-line interactions.

In particular, we use the Language Support tool to change the UI language of our Xfce desktop environment to Aragonese.

To do so, first, we type Language Support in the Activities menu and open the application:

"opening language support in xfce linux"

Then, we click on the Install/Remove Languages… button to install a new UI language:


"clicking on install or remove languages button in language tab of language support"

Next, we look for Aragonese in the Language list, mark its checkbox for installation, and click Apply:

"installing aragonese language on xfce"

After that, we drag the Aragonese entry at the top of the Language for menus and windows and click on the Apply system-wide button:

"applying system wide language settings"

Now, we enter the Password for root and click Authenticate:

"entering system password for authentication to apply changes"

This process may take a few minutes to apply the language changes to the system interface:

"waiting for applying language changes on xfce"

Then, we open the Log Out prompt window via the Activities menu to log out of  the current session:

"logging out of current screen in xfce"

After that, we enter the password to again log into the system:

"logging in again in xfce"

Now, we open any application like the Text Editor to test the UI language changes:

"opening text editor for testing in xfce"

Thus, we can see Aragonese as the UI language of the Text Editor on our desktop.

4. Conclusion

In this article, we learned different methods for changing the UI language of an Xfce desktop.

Particularly, we can edit the ~/.i18n in the shell to set the language-related environment variables. On the other hand, the Language Support utility enables us to change the UI language via a user-friendly interface.

Ultimately, we can select any of these methods based on our preference for using the command line or graphical user interface.


  1. https://www.baeldung.com/linux/xfce-change-ui-language#bd-using-the-shell


TMP

Hier wird beschrieben, wie man unter Arch Linux ein auf UTF-8 basierendes System mit deutschem Tastaturlayout erhält. Die folgenden Arbeiten müssen als root ausgeführt werden! Wichtig: ALLE Schritte müssen gemacht werden.

Grundkonfiguration

Deutsches Deutsch

echo LANG=de_DE.UTF-8 > /etc/locale.conf
echo KEYMAP=de-latin1-nodeadkeys > /etc/vconsole.conf
ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Wenn Akzent-Zeichen wie é, è, â benutzt und z. B. aus ' und E zusammengesetzt werden sollen, muss KEYMAP="de-latin1" verwendet werden.

Schweizerisches Deutsch

Für ein System, das auf „schweizerischem Deutsch“ betrieben werden soll, sind geringfügig andere Optionen nötig.

echo LANG=de_CH.UTF-8 > /etc/locale.conf
echo KEYMAP=de_CH-latin1 > /etc/vconsole.conf
ln -s /usr/share/zoneinfo/Europe/Zurich /etc/localtime

Österreichisches Deutsch

Österreichische Systeme werden analog dazu wie folgt konfiguriert.

echo LANG=de_AT.UTF-8 > /etc/locale.conf
echo KEYMAP=de-latin1-nodeadkeys > /etc/vconsole.conf
ln -s /usr/share/zoneinfo/Europe/Vienna /etc/localtime

Im Beispiel mit deutschem Tastaturlayout.

Für alle Varianten: Falls die Tastatureinstellung durch direktes Schreiben der Datei /etc/vconsole nicht funktioniert, mit dem Befehl localectl versuchen (siehe weiter unten).

Hardwareuhr

Die Hardwareuhr sollte auf die UTC Zeit eingestellt sein, ansonsten könnte es unter Umständen zu Problemen mit Programmen kommen, die als Grundlage die Hardwareuhr verwenden, und UTC voraussetzen.

timedatectl set-local-rtc 0

Die lokale Uhrzeit wird anhand der Zeitzonenangabe (siehe vorheriger Abschnitt) aus der UTC-Zeit berechnet.

Locales

Damit die Locales auch verwendet werden können, müssen diese noch generiert werden. Die gewünschten Locales werden in der Datei /etc/locale.gen aktiviert. In der Datei befinden sich alle generierbaren Locales. Vor den gewünschten Angaben muss das Kommentarzeichen entfernt werden.

de_DE.UTF-8 UTF-8    # Für Deutschland
de_CH.UTF-8 UTF-8    # Für die Schweiz
de_AT.UTF-8 UTF-8    # Für Österreich

Generieren

Nach der Konfiguration werden die Locales dann generiert.

locale-gen
Generating locales...
de_DE.UTF-8... done
Generation complete.

Spätestens nach einem Neustart ergibt sich beim Überprüfen nun folgendes Bild.

locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

Das Setzen der LC-Variablen kann systemweit in /etc/locale.conf, oder useraccountbezogen in ~/.config/locale.conf vorgenommen werden.

export LC_DATE=de_DE.utf8
export LC_NUMERIC=de_DE.utf8
export LC_TIME=de_DE.utf8
export LANG=de_DE.utf8

Nach Änderungen sollte man sich zumindest einmal ab- und wieder anmelden.

X.org

X nutzt udev zur Erkennung von Eingabegeräten. Diese können unter /etc/X11/xorg.conf.d/ konfiguriert werden. Ein deutsches Tastaturlayout wird für alle angeschlossenen Tastaturen mit dem Anlegen der Datei /etc/X11/xorg.conf.d/00-keyboard.conf definiert.

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "de"
        Option "XkbVariant" "deadgraveacute"
EndSection

Das Schweizer Layout erreicht man mittels Option "XkbLayout" "ch". Bei Verwendung einer Tastatur mit Deutschem Layout kann man Option "XkbVariant" "de" belassen.

Mit der Option "XkbVariant" "deadgraveacute" werden nur die Gravis (`) und Akut (´) Taste als "dead key" behandelt und der Zirkumflex (^) nicht. Bei einem "dead key" wird erst einen Tastendruck später ein Buchstabe erstellt, womit man Café anstatt Caf´e schreibt.

Anschließend muss X neugestartet werden.

localectl

Anstatt die Konfigurationsdateien manuell zu bearbeiten, kann auch localectl genutzt werden.

Aktuelle Einstellungen anzeigen

localectl status
System Locale: LANG=de_DE.UTF-8
               LANGUAGE=de_DE
    VC Keymap: de-latin1-nodeadkeys
   X11 Layout: de
    X11 Model: pc105
  X11 Variant: nodeadkeys

Tastaturlayout einstellen

Deutsches Deutsch

localectl --no-convert set-keymap de-latin1-nodeadkeys
localectl --no-convert set-x11-keymap de pc105 deadgraveacute

Schweizer Deutsch

Es scheint, dass die Untersektion de_sundeadkeys aus dem ch Key-Mapping mit Update vom 17.02.2021 entfernt wurde. Der bisherige localectl Befehl meldet:

Failed to set keymap: Specified keymap cannot be compiled, refusing as invalid. 

Nachfolgend die aktuellen Befehle:

localectl --no-convert set-keymap de_CH-latin1
localectl --no-convert set-x11-keymap ch pc106

Allerdings hat das Key-Mapping (nach wie vor?) den Fehler, dass AltGr-1 einen Bar (|) anstatt des Broken-Bars (¦) produziert.

Die Einstellungen werden in /etc/vconsole.conf und /etc/X11/xorg.conf.d/00-keyboard.conf gespeichert. Manuelle Änderungen an diesen Dateien werden beim nächsten Aufruf von localectl überschrieben.

Die Option --no-convert verhindert, dass set-keymap auch das Xorg Layout ändert. Beziehungsweise set-x11-keymap das Layout für die Konsole. Mehr Optionen man localectl.

Siehe auch

  • Locale
  • locale.conf

Weblinks

  • Locale Helper über de_DE