from rest_framework import serializers
from translation import models


class LanguageSerializer(serializers.ModelSerializer):
    """Serializer for model Language"""

    class Meta:
        model = models.Language
        fields = [
            'id',
            'title',
            'locale'
        ]


class SiteInterfaceDictionarySerializer(serializers.ModelSerializer):
    """Serializer for model SiteInterfaceDictionary."""

    text_trans = serializers.CharField(read_only=True)
    text = serializers.JSONField(write_only=True)

    class Meta:
        """Meta class."""
        model = models.SiteInterfaceDictionary
        fields = [
            'id',
            'page',
            'keywords',
            'text',
            'text_trans',
        ]
