<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_available_languages(self, related_name=None, include_unsaved=False):
 """ Return the language codes of all translated variations. .. versionadded 1.2 Added the ``include_unsaved`` and ``related_name`` parameters. """

        meta = self._parler_meta._get_extension_by_related_name(related_name)

        prefetch = self._get_prefetched_translations(meta=meta)
        if prefetch is not None:
            # TODO: this will break when using custom Django 1.8 Prefetch objects?
            db_languages = sorted(obj.language_code for obj in prefetch)
        else:
            qs = self._get_translated_queryset(meta=meta)
            db_languages = qs.values_list('language_code', flat=True).order_by('language_code')

        if include_unsaved:
            local_languages = (k for k, v in six.iteritems(self._translations_cache[meta.model]) if not is_missing(v))
            return list(set(db_languages) | set(local_languages))
        else:
            return db_languages