def generate_kotlin()

in library/scripts/find_movable_strings.py [0:0]


def generate_kotlin(string_pack_ids):
    if len(string_pack_ids) <= MAX_IDS_PER_METHOD:
        # No need for sub-methods, just create the whole array in the main method
        return generate_kotlin_internal(string_pack_ids, "getStringPacksMapping")

    result = []
    result += "fun getStringPacksMapping(): Array<Int> {\n"
    result += " " * 4 + "val result = int[" + str(len(string_pack_ids)) + "]\n"
    result += " " * 4 + "var part: Array<Int>\n"

    parts = math.ceil(len(string_pack_ids) / MAX_IDS_PER_METHOD)
    for i in range(0, parts):
        result += " " * 4 + "part = getStringPacksMappingPart" + str(i) + "()\n"
        result += (
            " " * 4
            + "System.arraycopy(part, 0, result, "
            + str(MAX_IDS_PER_METHOD * i)
            + ", part.length)\n"
        )

    result += " " * 4 + "result\n"
    result += "}\n"
    result += "\n"

    # Create submethods
    for i in range(0, parts):
        start = i * MAX_IDS_PER_METHOD
        end = start + MAX_IDS_PER_METHOD
        result += generate_kotlin_internal(
            string_pack_ids[start:end], "getStringPacksMappingPart%s" % i
        )

    return result