Z16836

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z16836"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z16812",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z16812( Z16812K1 ) {\n\tfunction is_cyr_letter( letter ) {\n\t\treturn lower_case_cyr.includes( letter ) || upper_case_cyr.includes( letter );\n\t}\n\n\tfunction is_low_letter( letter ) {\n\t\treturn lower_case_cyr.includes( letter );\n\t}\n\n\tfunction is_apostr( letter ) {\n\t\treturn letter === \"'\" || letter === \"`\" || letter === \"’\";\n\t}\n\n\tfunction is_first_letter_of_word( text, letter_index ) {\n\t\treturn letter_index === 0 || !is_cyr_letter( text[i - 1] );\n\t}\n\n\tfunction should_text_be_caps( text ) {\n\t\t// If there is only one Cyrillic letter, it should not\n\t\tvar i,\n\t\t\tcount = 0;\n\n\t\tfor ( i = 0; i \u003C text.length; i++ ) {\n\t\t\tif ( is_cyr_letter( text[i] ) ) {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif ( count \u003E= 2 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( count \u003C 2 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// If there is any lowercase letter, it should not\n\t\tfor ( i = 0; i \u003C text.length; i++ ) {\n\t\t\tif ( is_low_letter( text[i] ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// Otherwise, it should\n\t\treturn true;\n\t}\n\n\tconst upper_case_cyr = [\"А\", \"Б\", \"В\", \"Г\", \"Ґ\", \"Д\", \"Е\", \"Є\", \"Ж\", \"З\", \"И\", \"І\", \"Ї\", \"Й\", \"К\", \"Л\", \"М\", \"Н\", \"О\", \"П\", \"Р\", \"С\", \"Т\", \"У\", \"Ф\", \"Х\", \"Ц\", \"Ч\", \"Ш\", \"Щ\", \"Ь\", \"Ю\", \"Я\"];\n\tconst lower_case_cyr = [\"а\", \"б\", \"в\", \"г\", \"ґ\", \"д\", \"е\", \"є\", \"ж\", \"з\", \"и\", \"і\", \"ї\", \"й\", \"к\", \"л\", \"м\", \"н\", \"о\", \"п\", \"р\", \"с\", \"т\", \"у\", \"ф\", \"х\", \"ц\", \"ч\", \"ш\", \"щ\", \"ь\", \"ю\", \"я\"];\n\n\tconst cyr_to_lat = {\n\t\t\"а\": \"a\",\n\t\t\"б\": \"b\",\n\t\t\"в\": \"v\",\n\t\t\"г\": \"h\",\n\t\t\"ґ\": \"g\",\n\t\t\"д\": \"d\",\n\t\t\"е\": \"e\",\n\t\t\"є\": [\"ie\", \"ye\"],\n\t\t\"ж\": \"zh\",\n\t\t\"з\": \"z\",\n\t\t\"и\": \"y\",\n\t\t\"і\": \"i\",\n\t\t\"ї\": [\"i\", \"yi\"],\n\t\t\"й\": [\"i\", \"y\"],\n\t\t\"к\": \"k\",\n\t\t\"л\": \"l\",\n\t\t\"м\": \"m\",\n\t\t\"н\": \"n\",\n\t\t\"о\": \"o\",\n\t\t\"п\": \"p\",\n\t\t\"р\": \"r\",\n\t\t\"с\": \"s\",\n\t\t\"т\": \"t\",\n\t\t\"у\": \"u\",\n\t\t\"ф\": \"f\",\n\t\t\"х\": \"kh\",\n\t\t\"ц\": \"ts\",\n\t\t\"ч\": \"ch\",\n\t\t\"ш\": \"sh\",\n\t\t\"щ\": \"shch\",\n\t\t\"ю\": [\"iu\", \"yu\"],\n\t\t\"я\": [\"ia\", \"ya\"],\n\t\t\"А\": \"A\",\n\t\t\"Б\": \"B\",\n\t\t\"В\": \"V\",\n\t\t\"Г\": \"H\",\n\t\t\"Ґ\": \"G\",\n\t\t\"Д\": \"D\",\n\t\t\"Е\": \"E\",\n\t\t\"Є\": [\"Ie\", \"Ye\", \"IE\", \"YE\"],\n\t\t\"Ж\": [\"Zh\", \"Zh\", \"ZH\", \"ZH\"],\n\t\t\"З\": \"Z\",\n\t\t\"И\": \"Y\",\n\t\t\"І\": \"I\",\n\t\t\"Ї\": [\"I\", \"Yi\", \"I\", \"YI\"],\n\t\t\"Й\": [\"I\", \"Y\", \"I\", \"Y\"],\n\t\t\"К\": \"K\",\n\t\t\"Л\": \"L\",\n\t\t\"М\": \"M\",\n\t\t\"Н\": \"N\",\n\t\t\"О\": \"O\",\n\t\t\"П\": \"P\",\n\t\t\"Р\": \"R\",\n\t\t\"С\": \"S\",\n\t\t\"Т\": \"T\",\n\t\t\"У\": \"U\",\n\t\t\"Ф\": \"F\",\n\t\t\"Х\": [\"Kh\", \"Kh\", \"KH\", \"KH\"],\n\t\t\"Ц\": [\"Ts\", \"Ts\", \"TS\", \"TS\"],\n\t\t\"Ч\": [\"Ch\", \"Ch\", \"CH\", \"CH\"],\n\t\t\"Ш\": [\"Sh\", \"Sh\", \"SH\", \"SH\"],\n\t\t\"Щ\": [\"Shch\", \"Shch\", \"SHCH\", \"SHCH\"],\n\t\t\"Ю\": [\"Iu\", \"Yu\", \"IU\", \"YU\"],\n\t\t\"Я\": [\"Ia\", \"Ya\", \"IA\", \"YA\"]\n\t};\n\n\tvar result = [];\n\n\t// Remove all soft signs, as they are skipped at transliteration\n\tvar text = Z16812K1.replace( /ь/gi, \"\" );\n\n\t// Is this text written in caps\n\tvar is_caps = should_text_be_caps( text );\n\n\t// Process letters one by one\n\tfor ( var i = 0; i \u003C text.length; i++ ) {\n\t\tif ( is_apostr( text[i] ) \u0026\u0026 i \u003E 0 \u0026\u0026 i \u003C ( text.length - 1 ) \u0026\u0026 is_cyr_letter( text[i - 1] ) \u0026\u0026 is_cyr_letter( text[i + 1] ) ) {\n\t\t\ttext = text.substring( 0, i ) + text.substring( i + 1, text.length );\n\t\t\ti--;\n\t\t} else if ( !is_cyr_letter( text[i] ) ) {\n\t\t\tresult.push( text[i] );\n\t\t} else if ( typeof( cyr_to_lat[text[i]] ) === \"string\" ) {\n\t\t\tresult.push( cyr_to_lat[text[i]] );\n\t\t\tif ( i \u003C ( text.length - 1 ) \u0026\u0026 ( text[i] === \"з\" || text[i] === \"З\" ) \u0026\u0026 ( text[i + 1] === \"г\" || text[i + 1] === \"Г\" ) ) {\n\t\t\t\tresult.push( text[i] === \"з\" ? \"g\" : ( is_caps ? \"G\" : \"g\" ) );\n\t\t\t}\n\t\t} else {\n\t\t\tvar case_number = 0;\n\t\t\tif ( is_first_letter_of_word( text, i ) ) {\n\t\t\t\tcase_number += 1;\n\t\t\t}\n\t\t\tif ( is_caps ) {\n\t\t\t\tcase_number += 2;\n\t\t\t}\n\t\t\tresult.push( cyr_to_lat[text[i]][case_number] );\n\t\t}\n\t}\n\n\treturn result.join( \"\" );\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "JavaScript implemetation for Z16812"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1430",
                "Z11K2": "Ukrainisch in lateinische Zeichen, JavaScript"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}