from mstrio.server.language import list_languages
from mstrio.utils.version_helper import is_server_min_version


# TODO remove completely when deprecation period for Locale is over
def get_locales(connection):
    if is_server_min_version(connection=connection, version_str='11.3.1060'):
        locales = []
        for language in list_languages(connection=connection, base_language_lcid=0):
            locales.append(
                {
                    "id": language.id,
                    "name": language.name,
                    "abbreviation": language.abbreviation,
                }
            )
        return locales
    else:
        return [
            {
                "id": "000008044F95EF3956E52781700C1E7A",
                "name": "Chinese (Simplified)",
                "abbreviation": "zh-CN",
            },
            {
                "id": "000004044F95EF3956E52781700C1E7A",
                "name": "Chinese (Traditional)",
                "abbreviation": "zh-TW",
            },
            {
                "id": "000004064F95EF3956E52781700C1E7A",
                "name": "Danish (Denmark)",
                "abbreviation": "da-DK",
            },
            {
                "id": "000004134F95EF3956E52781700C1E7A",
                "name": "Dutch (Netherlands)",
                "abbreviation": "nl-NL",
            },
            {
                "id": "000008094F95EF3956E52781700C1E7A",
                "name": "English (United Kingdom)",
                "abbreviation": "en-UK",
            },
            {
                "id": "000004094F95EF3956E52781700C1E7A",
                "name": "English (United States)",
                "abbreviation": "en-US",
            },
            {
                "id": "0000080C4F95EF3956E52781700C1E7A",
                "name": "French (Belgium)",
                "abbreviation": "fr-BE",
            },
            {
                "id": "0000040C4F95EF3956E52781700C1E7A",
                "name": "French (France)",
                "abbreviation": "fr-FR",
            },
            {
                "id": "0000100C4F95EF3956E52781700C1E7A",
                "name": "French (Switzerland)",
                "abbreviation": "fr-CH",
            },
            {
                "id": "000004074F95EF3956E52781700C1E7A",
                "name": "German (Germany)",
                "abbreviation": "de-DE",
            },
            {
                "id": "000008074F95EF3956E52781700C1E7A",
                "name": "German (Switzerland)",
                "abbreviation": "de-CH",
            },
            {
                "id": "000004104F95EF3956E52781700C1E7A",
                "name": "Italian (Italy)",
                "abbreviation": "it-IT",
            },
            {
                "id": "000008104F95EF3956E52781700C1E7A",
                "name": "Italian (Switzerland)",
                "abbreviation": "it-CH",
            },
            {
                "id": "000004114F95EF3956E52781700C1E7A",
                "name": "Japanese",
                "abbreviation": "ja-JP",
            },
            {
                "id": "000004124F95EF3956E52781700C1E7A",
                "name": "Korean",
                "abbreviation": "ko-KR",
            },
            {
                "id": "000004154F95EF3956E52781700C1E7A",
                "name": "Polish",
                "abbreviation": "pl-PL",
            },
            {
                "id": "000004164F95EF3956E52781700C1E7A",
                "name": "Portuguese (Brazil)",
                "abbreviation": "pt-PT",
            },
            {
                "id": "000004194F95EF3956E52781700C1E7A",
                "name": "Russian",
                "abbreviation": "ru-RU",
            },
            {
                "id": "00000C0A4F95EF3956E52781700C1E7A",
                "name": "Spanish (Spain)",
                "abbreviation": "es-ES",
            },
            {
                "id": "0000041D4F95EF3956E52781700C1E7A",
                "name": "Swedish (Sweden)",
                "abbreviation": "sv-SE",
            },
        ]
