# Buggy code
def get_available_translations():
    """
    List available translations for spyder based on the folders found in the
    locale folder. This function checks if LANGUAGE_CODES contain the same
    information that is found in the 'locale' folder to ensure that when a new
    language is added, LANGUAGE_CODES is updated.
    """
    locale_path = get_module_data_path(
        "spyder", relpath="locale", attr_name="LOCALEPATH"
    )
    listdir = os.listdir(locale_path)
    langs = [d for d in listdir if osp.isdir(osp.join(locale_path, d))]
    langs = [DEFAULT_LANGUAGE] + langs

    # Remove disabled languages
    langs = list(set(langs) - set(DISABLED_LANGUAGES))

    # Check that there is a language code available in case a new translation
    # is added, to ensure LANGUAGE_CODES is updated.
    for lang in langs:
        if lang not in LANGUAGE_CODES:
            error = _(
                "Update LANGUAGE_CODES (inside config/base.py) if a new "
                "translation has been added to Spyder"
            )
            raise Exception(error)
    return langs


# Traceback (NameError)
Traceback (most recent call last):
File "/home/yang/anaconda3/bin/spyder", line 7, in <module>
from spyder.app.start import main
File "/home/yang/anaconda3/lib/python3.6/site-packages/spyder/app/start.py", line 37, in <module>
from spyder.config.base import (get_conf_path, running_in_mac_app,
File "/home/yang/anaconda3/lib/python3.6/site-packages/spyder/config/base.py", line 415, in <module>
_ = get_translation("spyder")
File "/home/yang/anaconda3/lib/python3.6/site-packages/spyder/config/base.py", line 386, in get_translation
language = load_lang_conf()
File "/home/yang/anaconda3/lib/python3.6/site-packages/spyder/config/base.py", line 359, in load_lang_conf
lang = get_interface_language()
File "/home/yang/anaconda3/lib/python3.6/site-packages/spyder/config/base.py", line 330, in get_interface_language
spyder_languages = get_available_translations()
File "/home/yang/anaconda3/lib/python3.6/site-packages/spyder/config/base.py", line 297, in get_available_translations
error = _('Update LANGUAGE_CODES (inside config/base.py) if a new '
NameError: name '_' is not defined

# Fixed code
def get_available_translations():
    """
    List available translations for spyder based on the folders found in the
    locale folder. This function checks if LANGUAGE_CODES contain the same
    information that is found in the 'locale' folder to ensure that when a new
    language is added, LANGUAGE_CODES is updated.
    """
    locale_path = get_module_data_path(
        "spyder", relpath="locale", attr_name="LOCALEPATH"
    )
    listdir = os.listdir(locale_path)
    langs = [d for d in listdir if osp.isdir(osp.join(locale_path, d))]
    langs = [DEFAULT_LANGUAGE] + langs

    # Remove disabled languages
    langs = list(set(langs) - set(DISABLED_LANGUAGES))

    # Check that there is a language code available in case a new translation
    # is added, to ensure LANGUAGE_CODES is updated.
    for lang in langs:
        if lang not in LANGUAGE_CODES:
            error = (
                "Update LANGUAGE_CODES (inside config/base.py) if a new "
                "translation has been added to Spyder"
            )
            print(error)  # spyder: test-skip
            return ["en"]
    return langs