share/hedgewars/Data/Locale/CMakeLists.txt
author sheepluva
Sat, 12 Sep 2015 20:01:26 +0200
branchgettext
changeset 11168 e104e060911b
parent 10388 665d8b699d35
child 11172 db1d14179b6c
permissions -rw-r--r--
experimental gettext for lua
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
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    12
#QT4_ADD_TRANSLATION(QM ${tsfiles})
3822
ee85a9c73ece *patch by arrom: fix installation of fort images
koda
parents: 3683
diff changeset
    13
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    14
set(qtpro "${PROJECT_SOURCE_DIR}/project_files/hedgewars.pro")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    15
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    16
add_custom_target(release-translation-qt
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    17
        COMMAND ${QT_LRELEASE_EXECUTABLE} -silent ${qtpro}
8443
2debc9b9f917 remove trailing whitespaces from share too
koda
parents: 6059
diff changeset
    18
        COMMENT "Compiling ts files"
3822
ee85a9c73ece *patch by arrom: fix installation of fort images
koda
parents: 3683
diff changeset
    19
)
1026
a415f436fe3a Add German translation
unc0rr
parents: 932
diff changeset
    20
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    21
file(GLOB pofiles *.po)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    22
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    23
string(REGEX REPLACE "(^|;)[^;]*/([^/]+).po($|;)" "\\1${CMAKE_CURRENT_BINARY_DIR}/\\2.mo\\3" mofiles "${pofiles}")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    24
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    25
add_custom_target(release-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    26
        DEPENDS ${pofiles}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    27
        COMMENT "Compiling po files"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    28
)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    29
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    30
# compile all the pofiles
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    31
foreach(pofile ${pofiles})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    32
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    33
    string(REGEX REPLACE "^.*/([^/]+).po" "\\1.mo" mofile ${pofile})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    34
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    35
#    add_custom_command(OUTPUT ${mofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    36
    add_custom_command(TARGET release-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    37
        #COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--statistics" "--output=${mofile}" ${pofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    38
        COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--output=${mofile}" ${pofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    39
        #DEPENDS ${pofile}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    40
#        COMMENT "Compiling po file ${mofile}"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    41
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    42
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    43
endforeach(pofile)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    44
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    45
add_custom_target(release-translation ALL
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    46
        DEPENDS release-translation-qt release-translation-lua
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
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    50
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    51
if(UPDATE_TRANSLATIONS)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    52
    # lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    53
    set(loctemplate "messages.pot")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    54
    #set(luasearchroot "${PROJECT_SOURCE_DIR}/share/hedgewars/Data")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    55
    set(luasearchroot "..")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    56
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    57
    set(poargs
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    58
            "--no-wrap"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    59
            "--add-location"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    60
            "--sort-by-file"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    61
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    62
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    63
    # make sure to pass relative paths
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    64
    file(GLOB_RECURSE luafiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${luasearchroot}/*.lua")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    65
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    66
    add_custom_command(OUTPUT ${loctemplate}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    67
        COMMAND "xgettext"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    68
            "--output=${CMAKE_CURRENT_BINARY_DIR}/${loctemplate}"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    69
            "--from-code=UTF-8"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    70
            "-k" "--keyword=loc"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    71
            ${poargs}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    72
            #"--add-comments=@loc"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    73
            ${luafiles}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    74
        DEPENDS ${luafiles}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    75
        # 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
    76
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    77
        COMMENT "Creating po template"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    78
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    79
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    80
    add_custom_target(update-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    81
            COMMENT "Updating po files"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    82
            DEPENDS ${loctemplate}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    83
    )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    84
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    85
    # merge template with existing PO files
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    86
    foreach(pofile ${pofiles})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    87
        add_custom_command(TARGET update-translation-lua
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    88
            COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} "--quiet" "--update" "--backup=off" ${poargs} ${pofile} ${loctemplate}
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    89
#COMMENT "Updating file ${pofile}"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    90
        )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    91
    endforeach(pofile)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    92
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    93
    add_dependencies(release-translation-lua update-translation-lua)
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    94
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    95
    # qt
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    96
    set(svrmsgsfile "${CMAKE_SOURCE_DIR}/QTfrontend/servermessages.h")
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    97
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    98
    if(NOT EXISTS ${svrmsgsfile})
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
    99
        message(WARNING "\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   100
            "${svrmsgs} not found.\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   101
            "It is required for a proper QT translation files update!\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   102
            "\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   103
            "This is normal for out-of-dir builds.\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   104
            "Make a symlink to the file in the build-dir.\n"
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   105
        )
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   106
    endif()
e104e060911b experimental gettext for lua
sheepluva
parents: 10388
diff changeset
   107
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