How to change the abbreviations of layouts shown in keyboard layout indicator of GNOME panel?

This method only works with Xorg*

(* Update from the original asker: It seems the changes made in an Xorg session persist after rebooting to a Wayland session.)


Introduction

Basically, GNOME-Shell seem to be obtaining the abbreviations of the keyboard layouts from a configuration file ( /usr/share/X11/xkb/rules/evdev.xml). So to change them, we first need to open the configuration file in a text editor and then change them to whatever we want!

There are two different ways to do it. Though the graphical interface which includes the mouse or the command line interface which is only the keyboard.


Common first step

First open a terminal.

There is many way to do this. This method is the simplistic. Press Alt + F2 on your keyboard. You will see a dialog box come up and type in gnome-terminal or the name of your terminal. It should look like this now.

Dialog1

Now, press Enter. It should close and bring up an terminal.

Blank Terminal

Form here there are two ways: First the graphical way, or the Command interface.


Graphical Method

  1. Now type in

    sudo -i gedit /usr/share/X11/xkb/rules/evdev.xml
    

    This is how it should look.

    Terminal with filename1

  2. Now, press Enter and it should open the file in which we need to edit. This is how it should look:

    Gedit_1

  3. Now click on the bottom with the three dots. Highlighted in blue, then find and click on "Find and Replace..." Highlighted in lighter gray.

    enter image description here

    Now it should bring up an dialog

    Dialog_2

  4. Now we can edit this file to change "en" to "Eng". This will change all of the layouts that uses "en"

    Now, type into the text-box with "Find" to the left of it with this <shortDescription>en</shortDescription> Next, with the textbook below it and text to the left that says "Replace with", type this in it <shortDescription>Eng</shortDescription>. Now it should look like this.

    Dialog 2

    However, if you only want to change one layout then you will need to find it individually instead of changing all of them. I would just used the Find function to search for the name of it which needs to be spell exactly to find it.

  5. Now click on the button that says "Replace all" now that dialog box should disappeared with it saying it's found and replace 9 or so occurrences.

    Gedit_2

  6. Now save it by clicking on the save button highlighted in light gray.

    Gedit_4

    Now, notice that the asterisk in the title should go away like this. If it didn't then it didn't save.

    Gedit_1

  7. Restart your PC. Now it should look like this. Notice, that I did it with "eng" instead of "Eng"

    enter image description here


Command line interface

  1. Type in

    sudo sed -i -e 's/<shortDescription>en</shortDescription>/<shortDescription>Eng</shortDescription>/g' /usr/share/X11/xkb/rules/evdev.xml
    
  2. Press Enter on your keyboard.

  3. Type in your password.

  4. Press Enter on your keyboard.

  5. Restart your PC.