share/hedgewars/Data/Locale/CMakeLists.txt
author sheepluva
Mon, 02 Nov 2015 06:23:46 +0100
branchgettext
changeset 11172 db1d14179b6c
parent 11168 e104e060911b
permissions -rw-r--r--
silent qm-compile did not play well with out-of-source building
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10388
665d8b699d35 part of patch in issue 803 (ty) - this hopefully should fix issues with cmake Makefiles trying to run "Qt4::lrelease" in the shell
sheepluva
parents: 9832
diff changeset
     1
find_package(Qt4 REQUIRED)
665d8b699d35 part of patch in issue 803 (ty) - this hopefully should fix issues with cmake Makefiles trying to run "Qt4::lrelease" in the shell
sheepluva
parents: 9832
diff changeset
     2
include(${QT_USE_FILE})
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
     3
find_package(Gettext REQUIRED)
10388
665d8b699d35 part of patch in issue 803 (ty) - this hopefully should fix issues with cmake Makefiles trying to run "Qt4::lrelease" in the shell
sheepluva
parents: 9832
diff changeset
     4
1993
66ac34be63d1 Fix some locale files installation
unc0rr
parents: 1523
diff changeset
     5
file(GLOB txttrans2 ??.txt)
66ac34be63d1 Fix some locale files installation
unc0rr
parents: 1523
diff changeset
     6
file(GLOB txttrans5 ?????.txt)
3822
ee85a9c73ece *patch by arrom: fix installation of fort images
koda
parents: 3683
diff changeset
     7
file(GLOB tsfiles *.ts)
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 4502
diff changeset
     8
file(GLOB missionfiles missions_*.txt)
9237
b2f4bd758a0b added campaign descriptions in CMakeList
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8443
diff changeset
     9
file(GLOB campaignfiles campaigns_*.txt)
9832
b1038b4373cc Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents: 9237
diff changeset
    10
file(GLOB tipfiles tips_*.xml)
3822
ee85a9c73ece *patch by arrom: fix installation of fort images
koda
parents: 3683
diff changeset
    11
11172
db1d14179b6c silent qm-compile did not play well with out-of-source building
sheepluva
parents: 11168
diff changeset
    12
QT4_ADD_TRANSLATION(QM ${tsfiles})
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    13
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    14
add_custom_target(release-translation-qt
11172
db1d14179b6c silent qm-compile did not play well with out-of-source building
sheepluva
parents: 11168
diff changeset
    15
        DEPENDS ${QM}
8443
2debc9b9f917 remove trailing whitespaces from share too
koda
parents: 6059
diff changeset
    16
        COMMENT "Compiling ts files"
3822
ee85a9c73ece *patch by arrom: fix installation of fort images
koda
parents: 3683
diff changeset
    17
)
1026
a415f436fe3a Add German translation
unc0rr
parents: 932
diff changeset
    18
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    19
file(GLOB pofiles *.po)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    20
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    21
string(REGEX REPLACE "(^|;)[^;]*/([^/]+).po($|;)" "\\1${CMAKE_CURRENT_BINARY_DIR}/\\2.mo\\3" mofiles "${pofiles}")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    22
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    23
add_custom_target(release-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    24
        DEPENDS ${pofiles}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    25
        COMMENT "Compiling po files"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    26
)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    27
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    28
# compile all the pofiles
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    29
foreach(pofile ${pofiles})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    30
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    31
    string(REGEX REPLACE "^.*/([^/]+).po" "\\1.mo" mofile ${pofile})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    32
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    33
#    add_custom_command(OUTPUT ${mofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    34
    add_custom_command(TARGET release-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    35
        #COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--statistics" "--output=${mofile}" ${pofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    36
        COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--output=${mofile}" ${pofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    37
        #DEPENDS ${pofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    38
#        COMMENT "Compiling po file ${mofile}"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    39
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    40
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    41
endforeach(pofile)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    42
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    43
add_custom_target(release-translation ALL
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    44
        DEPENDS release-translation-qt release-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    45
)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    46
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    47
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    48
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    49
if(UPDATE_TRANSLATIONS)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    50
    # lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    51
    set(loctemplate "messages.pot")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    52
    #set(luasearchroot "${PROJECT_SOURCE_DIR}/share/hedgewars/Data")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    53
    set(luasearchroot "..")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    54
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    55
    set(poargs
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    56
            "--no-wrap"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    57
            "--add-location"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    58
            "--sort-by-file"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    59
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    60
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    61
    # make sure to pass relative paths
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    62
    file(GLOB_RECURSE luafiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${luasearchroot}/*.lua")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    63
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    64
    add_custom_command(OUTPUT ${loctemplate}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    65
        COMMAND "xgettext"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    66
            "--output=${CMAKE_CURRENT_BINARY_DIR}/${loctemplate}"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    67
            "--from-code=UTF-8"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    68
            "-k" "--keyword=loc"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    69
            ${poargs}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    70
            #"--add-comments=@loc"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    71
            ${luafiles}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    72
        DEPENDS ${luafiles}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    73
        # since we're using relative paths we need to work from within the source dir
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    74
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    75
        COMMENT "Creating po template"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    76
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    77
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    78
    add_custom_target(update-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    79
            COMMENT "Updating po files"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    80
            DEPENDS ${loctemplate}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    81
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    82
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    83
    # merge template with existing PO files
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    84
    foreach(pofile ${pofiles})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    85
        add_custom_command(TARGET update-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    86
            COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} "--quiet" "--update" "--backup=off" ${poargs} ${pofile} ${loctemplate}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    87
#COMMENT "Updating file ${pofile}"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    88
        )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    89
    endforeach(pofile)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    90
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    91
    add_dependencies(release-translation-lua update-translation-lua)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    92
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    93
    # qt
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    94
    set(svrmsgsfile "${CMAKE_SOURCE_DIR}/QTfrontend/servermessages.h")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    95
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    96
    if(NOT EXISTS ${svrmsgsfile})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    97
        message(WARNING "\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    98
            "${svrmsgs} not found.\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    99
            "It is required for a proper QT translation files update!\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   100
            "\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   101
            "This is normal for out-of-dir builds.\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   102
            "Make a symlink to the file in the build-dir.\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   103
        )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   104
    endif()
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   105
11172
db1d14179b6c silent qm-compile did not play well with out-of-source building
sheepluva
parents: 11168
diff changeset
   106
    set(qtpro "${PROJECT_SOURCE_DIR}/project_files/hedgewars.pro")
db1d14179b6c silent qm-compile did not play well with out-of-source building
sheepluva
parents: 11168
diff changeset
   107
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   108
    add_custom_target(update-translation-qt
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   109
        COMMAND ${QT_LUPDATE_EXECUTABLE} -silent -locations absolute -pro ${qtpro}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   110
        DEPENDS ${svrmsgsfile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   111
        COMMENT "Updating ts files"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   112
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   113
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   114
    add_dependencies(release-translation-qt update-translation-qt)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   115
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   116
endif(UPDATE_TRANSLATIONS)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   117
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   118
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   119
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   120
#install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DESTINATION "${SHAREPATH}Data"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   121
#        FILES_MATCHING PATTERN "*.mo"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   122
#        PATTERN "*/CMakeFiles" EXCLUDE
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   123
#)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   124
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   125
#file(GLOB luafiles *.lua)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   126
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 98
diff changeset
   127
install(FILES
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   128
    ${mofiles}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   129
    #${luafiles}
8443
2debc9b9f917 remove trailing whitespaces from share too
koda
parents: 6059
diff changeset
   130
    ${txttrans2}
2debc9b9f917 remove trailing whitespaces from share too
koda
parents: 6059
diff changeset
   131
    ${txttrans5}
2debc9b9f917 remove trailing whitespaces from share too
koda
parents: 6059
diff changeset
   132
    ${QM}
2debc9b9f917 remove trailing whitespaces from share too
koda
parents: 6059
diff changeset
   133
    ${missionfiles}
9237
b2f4bd758a0b added campaign descriptions in CMakeList
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8443
diff changeset
   134
    ${campaignfiles}
9832
b1038b4373cc Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents: 9237
diff changeset
   135
    ${tipfiles}
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   136
    DESTINATION "${SHAREPATH}Data/Locale"
3822
ee85a9c73ece *patch by arrom: fix installation of fort images
koda
parents: 3683
diff changeset
   137
)
ee85a9c73ece *patch by arrom: fix installation of fort images
koda
parents: 3683
diff changeset
   138