aboutsummaryrefslogtreecommitdiff
path: root/cmake/ConvertPo.cmake
blob: 202cd3fbb35fb4d1a54a1c11a54bb6a894a8b24d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
string(TOUPPER ${INPUT_ENC} upperInputEnc)
string(TOLOWER ${INPUT_ENC} lowerInputEnc)
get_filename_component(inputName ${INPUT_FILE} NAME)
execute_process(
  COMMAND ${ICONV_PRG} -f ${INPUT_ENC} -t ${OUTPUT_ENC} ${INPUT_FILE}
  OUTPUT_VARIABLE trans
  ERROR_VARIABLE err
  RESULT_VARIABLE res)
if(res)
  message(FATAL_ERROR "iconv failed to run correctly: ${err}")
endif()

string(REPLACE "charset=${lowerInputEnc}" "charset=${OUTPUT_CHARSET}"
  trans "${trans}")
string(REPLACE "charset=${upperInputEnc}" "charset=${OUTPUT_CHARSET}"
  trans "${trans}")
string(REPLACE "# Original translations"
  "# Generated from ${inputName}, DO NOT EDIT"
  trans "${trans}")

file(WRITE ${OUTPUT_FILE} "${trans}")