<commit_before>
project(cura)
cmake_minimum_required(VERSION 2.8.12)

include(GNUInstallDirs)

set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY "The location of the scripts directory of the Uranium repository")

if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
    # Extract Strings
    add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)

    # Build Translations
    find_package(Gettext)
    find_package(Qt5LinguistTools QUIET CONFIG)
    if(GETTEXT_FOUND AND Qt5LinguistTools_FOUND)
        include(${URANIUM_SCRIPTS_DIR}/ECMPoQmTools.cmake)

        # translations target will convert .po files into .mo and .qm as needed.
        # The files are checked for a _qt suffix and if it is found, converted to
        # qm, otherwise they are converted to .po.
        add_custom_target(translations ALL)
        # copy-translations can be used to copy the built translation files from the
        # build directory to the source resources directory. This is mostly a convenience
        # during development, normally you want to simply use the install target to install
        # the files along side the rest of the application.
        add_custom_target(copy-translations)

        #TODO: Properly install the built files. This should be done after we move the applications out of the Uranium repo.
        set(languages
            en
            x-test
            ru
            fr
            de
            it
            es
            fi
        )
        foreach(lang ${languages})
            file(GLOB po_files resources/i18n/${lang}/*.po)
            foreach(file ${po_files})
                string(REGEX MATCH "qt\\.po$" match "${file}")
                if(match)
                    ecm_process_po_files_as_qm(${lang} PO_FILES ${file})
                else()
                    string(REGEX REPLACE ".*/(.*).po" "${lang}/\\1.mo" mofile ${file})
                    add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${lang} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${file} -o ${mofile})
                endif()
            endforeach()

            file(GLOB qm_files ${CMAKE_BINARY_DIR}/${lang}/*.qm)
            file(GLOB mo_files ${CMAKE_BINARY_DIR}/${lang}/*.mo)
            foreach(file ${qm_files} ${mo_files})
                add_custom_command(TARGET copy-translations POST_BUILD COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMAND cp ARGS ${file} ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMENT "Copying ${file}...")
            endforeach()

            install(FILES ${qm_files} ${mo_files} DESTINATION ${CMAKE_INSTALL_DATADIR}/uranium/resources/i18n/${lang}/LC_MESSAGES/)
        endforeach()<commit_msg>Remove Qt translation generation and only use gettext for extracting translations<commit_after>
project(cura)
cmake_minimum_required(VERSION 2.8.12)

include(GNUInstallDirs)

set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY "The location of the scripts directory of the Uranium repository")

if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
    # Extract Strings
    add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)

    # Build Translations
    find_package(Gettext)
    if(GETTEXT_FOUND)
        # translations target will convert .po files into .mo and .qm as needed.
        # The files are checked for a _qt suffix and if it is found, converted to
        # qm, otherwise they are converted to .po.
        add_custom_target(translations ALL)
        # copy-translations can be used to copy the built translation files from the
        # build directory to the source resources directory. This is mostly a convenience
        # during development, normally you want to simply use the install target to install
        # the files along side the rest of the application.
        add_custom_target(copy-translations)

        #TODO: Properly install the built files. This should be done after we move the applications out of the Uranium repo.
        set(languages
            en
            x-test
            ru
            fr
            de
            it
            es
            fi
            pl
            cs
            bg
        )
        foreach(lang ${languages})
            file(GLOB po_files resources/i18n/${lang}/*.po)
            foreach(file ${po_files})
                string(REGEX REPLACE ".*/(.*).po" "${lang}/\\1.mo" mofile ${file})
                add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${lang} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${file} -o ${mofile})
            endforeach()

            file(GLOB mo_files ${CMAKE_BINARY_DIR}/${lang}/*.mo)
            foreach(file ${mo_files})
                add_custom_command(TARGET copy-translations POST_BUILD COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMAND cp ARGS ${file} ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMENT "Copying ${file}...")
            endforeach()

            install(FILES ${mo_files} DESTINATION ${CMAKE_INSTALL_DATADIR}/uranium/resources/i18n/${lang}/LC_MESSAGES/)
        endforeach()
{'fraction_non_alphanumeric': 0.09316533027873235, 'fraction_numerical': 0.005345551737304314, 'mean_word_length': 2.5615227736233854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7098272', 'n_tokens_mistral': 1612, 'n_tokens_neox': 1518, 'n_words': 432}