As far as modern versions of Ubuntu go—which use LibreOffice instead of OpenOffice—start by clearing out unused language packs. Find them with:
apt list --installed | grep firefox-locale
apt list --installed | grep libreoffice-help
apt list --installed | grep libreoffice-l10n
Then execute the sudo apt remove command followed by a space‐separated list of the packages one wants to remove. After restarting Firefox, the list of spellchecking dictionaries will be reduced if those packages had dictionaries associated with them. (There’s no dictionary to remove for Chinese, for example.)
This still leaves to be addressed dictionaries associated with unused national locales. For Firefox, this can be addressed by creating a new dictionary directory containing symbolic links to only the dictionaries that one wants to use and linking this directory to Firefox using the spellchecker.dictionary_path preference.
Example:
mkdir ~/hunspell/
ln --symbolic /usr/share/hunspell/en_US.aff /usr/share/hunspell/en_US.dic /usr/share/hunspell/es_US.aff /usr/share/hunspell/es_US.dic ~/hunspell/
After executing the above commands, open the about:config page in Firefox, and change the value of the spellchecker.dictionary_path preference so that it references the directory containing the symbolic links. In the preceding example, one would use the path value ~/hunspell. After restarting Firefox, there should only be two dictionaries offered for spellchecking: English (United States) and Spanish (United States).