| 46 | | |
| 47 | | ## Wraps the supplied .ts files in lrelease commands |
| 48 | | macro(QT4_ADD_TRANSLATIONS outfiles) |
| | 58 | ## Adds custom commands to the specified target that will update each of the |
| | 59 | ## supplied .po files |
| | 60 | macro(VIDALIA_UPDATE_PO TARGET) |
| | 61 | ## Gather a list of all the files that might contain translated strings |
| | 62 | FILE(GLOB_RECURSE translate_SRCS ${Vidalia_SOURCE_DIR}/*.cpp) |
| | 63 | FILE(GLOB_RECURSE translate_HDRS ${Vidalia_SOURCE_DIR}/*.h) |
| | 64 | FILE(GLOB_RECURSE translate_UIS ${Vidalia_SOURCE_DIR}/*.ui) |
| | 65 | set(translate_SRCS ${translate_SRCS} ${translate_HDRS} ${translate_UIS}) |
| | 66 | |
| 53 | | ## XXX: Ideally we would output the .qm files to CMAKE_CURRENT_BINARY_DIR, |
| 54 | | ## but then RCC can't find them when doing out-of-source builds. Is |
| 55 | | ## there an easy fix for this? |
| 56 | | set(outfile ${CMAKE_CURRENT_SOURCE_DIR}/${outfile}.qm) |
| 57 | | add_custom_command(OUTPUT ${outfile} |
| | 72 | set(ts ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.ts) |
| | 73 | add_custom_command(TARGET ${TARGET} |
| | 74 | # Convert the current .po files to .ts |
| | 75 | COMMAND ${VIDALIA_PO2TS_EXECUTABLE} |
| | 76 | ARGS -q -i ${po} -o ${ts} |
| | 77 | # Update the .ts files |
| | 78 | COMMAND ${QT_LUPDATE_EXECUTABLE} |
| | 79 | ARGS -silent -noobsolete ${translate_SRCS} -ts ${ts} |
| | 80 | # Convert the updated .ts files back to .po |
| | 81 | COMMAND ${VIDALIA_TS2PO_EXECUTABLE} |
| | 82 | ARGS -q -i ${ts} -o ${po} |
| | 83 | DEPENDS ${VIDALIA_TS2PO_EXECUTABLE} ${VIDALIA_PO2TS_EXECUTABLE} |
| | 84 | COMMENT "Updating translation ${it}" |
| | 85 | ) |
| | 86 | endforeach(it) |
| | 87 | add_dependencies(${TARGET} ts2po) |
| | 88 | add_dependencies(${TARGET} po2ts) |
| | 89 | endmacro(VIDALIA_UPDATE_PO) |
| | 90 | |
| | 91 | |
| | 92 | ## Wraps the supplied .po files with commands to convert them to Qt's .qm |
| | 93 | ## format |
| | 94 | macro(VIDALIA_ADD_PO outfiles) |
| | 95 | foreach (it ${ARGN}) |
| | 96 | get_filename_component(po ${it} ABSOLUTE) |
| | 97 | get_filename_component(outfile ${it} NAME_WE) |
| | 98 | |
| | 99 | ## Create the .po -> .ts conversion step |
| | 100 | set(ts ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.ts) |
| | 101 | set(qm ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.qm) |
| | 102 | add_custom_command(OUTPUT ${qm} |
| | 103 | COMMAND ${VIDALIA_PO2TS_EXECUTABLE} |
| | 104 | ARGS -q -i ${po} -o ${ts} |