def Translation(model):
    """
    Return a class which can be used as inheritance base for translation models
    """

    class Inner(models.Model):
        parent = models.ForeignKey(
            model, related_name="translations", on_delete=models.CASCADE
        )
        language_code = models.CharField(
            _("language"),
            max_length=10,
            choices=settings.LANGUAGES,
            default=settings.LANGUAGES[0][0],
            editable=len(settings.LANGUAGES) > 1,
        )

        class Meta:
            unique_together = ("parent", "language_code")
            # (beware the above will not be inherited automatically if you
            #  provide a Meta class within your translation subclass)
            abstract = True

        def short_language_code(self):
            return short_language_code(self.language_code)

        def save(self, *args, **kwargs):
            super().save(*args, **kwargs)
            self.parent.purge_translation_cache()

        save.alters_data = True

        def delete(self, *args, **kwargs):
            super().delete(*args, **kwargs)
            self.parent.purge_translation_cache()

        delete.alters_data = True

    return Inner

    Return a class which can be used as inheritance base for translation models
    
feincms/translations.py