Get format according to algorithm defined in RFC 5646 section 2.1.1.


        :return: formatted tag string.

def format(self):
        """
        Get format according to algorithm defined in RFC 5646 section 2.1.1.


        :return: formatted tag string.
        """
        tag = self.data['tag']
        subtags = tag.split('-')
        if len(subtags) == 1:
            return subtags[0]

        formatted_tag = subtags[0]
        private_tag = False
        for i, subtag in enumerate(subtags[1:]):

            if len(subtags[i]) == 1 or private_tag:
                formatted_tag += '-' + subtag
                private_tag = True

            elif len(subtag) == 2:
                formatted_tag += '-' + subtag.upper()

            elif len(subtag) == 4:
                formatted_tag += '-' + subtag.capitalize()
            else:
                formatted_tag += '-' + subtag

        return formatted_tag