It is true that you can only have 4 keyboard layouts installed by default. This limitation does not come from Ubuntu, but from Xorg.
While a scripted approach to make multiple sets of 4 keyboard layouts available should work, IMHO it is cumbersome to use and vulnerable to breakage in the future.
You can, however, have as many input methods as you need, assuming the input method exists for the language you need. One other point is not to confuse language support in general with the keyboard layout.
My recommendation is to use the input editor ibus
for as many languages as possible; and then to use a keyboard layout that works well with the other languages.
Ibus
Ibus is the standard input method for Ubuntu. To enable it, use Language Support in System Settings.
For the fullest range of input methods, you also need to install ibus-m17n
Set Ibus Preferences and Input Methods
After logging out and back in, you will see the ibus
indicator (a little keyboard, similar to the keyboard layouts indicator. Use the drop-down menu to open the Preferences dialog. You can also start the preferences dialog from the command line with ibus-setup.
As an aside, on the General tab, it's a good idea to change Show language panel to When active or Always. There is a bug or conflict somewhere that keeps the default option of Embedded in Menu from working. The language panel provides additional functionality for the various input methods.
Then choose the Input Method tab. Choose Customize active input methods. Please note that installing the ibus-m17n
package or language support for a language does not automatically set up an input method. You still need to do this separately.
Use the Select an input method button to access the sub-menus for a long list of languages.
After choosing the one you want, the text will change to that input method. Click Add and the Close.
Keyboard layouts for the remaining languages
Most languages that use the Roman alphabet with diacritics do not necessarily need a specific keyboard layout. If after setting up input methods, you only have 3 or 4 left, by all means use the specific keyboard layouts.
But in most cases, you can insert whatever characters with diacritics you need by using the English international keyboard with dead keys or by enabling the compose key in Keyboard layout options.
How you input the characters is completely separate from how programs such as LibreOffice provide language support and spell checking.