@@ -112,9 +112,29 @@ macro(slicerMacroBuildScriptedModule)
112112 # --------------------------------------------------------------------------
113113 # Translations
114114 # --------------------------------------------------------------------------
115- if ("${CTK_COMPILE_PYTHON_SCRIPTS_GLOBAL_TARGET_NAME} " STREQUAL "" )
116- SlicerFunctionAddPythonScriptTrFilesTargets(${MY_SLICER_NAME} )
117- endif ()
115+
116+ set (scripts )
117+ foreach (file IN ITEMS ${MY_SLICER_SCRIPTS} )
118+ # Append "py" extension if needed
119+ get_filename_component (file_ext ${file} EXT )
120+ if (NOT "${file_ext} " MATCHES "py" )
121+ set (file "${file} .py" )
122+ endif ()
123+ list (APPEND scripts ${file} )
124+ endforeach ()
125+
126+ set (TS_DIR "${CMAKE_CURRENT_SOURCE_DIR} /Resources/Translations" )
127+ include (SlicerMacroTranslation)
128+ SlicerMacroTranslation(
129+ SRCS ${scripts}
130+ TS_DIR ${TS_DIR}
131+ TS_BASEFILENAME ${MY_SLICER_NAME}
132+ TS_LANGUAGES ${Slicer_LANGUAGES}
133+ )
134+
135+ #if("${CTK_COMPILE_PYTHON_SCRIPTS_GLOBAL_TARGET_NAME}" STREQUAL "")
136+ # SlicerFunctionAddPythonScriptTrFilesTargets(${MY_SLICER_NAME})
137+ #endif()
118138
119139 # --------------------------------------------------------------------------
120140 # Tests
@@ -134,57 +154,3 @@ macro(slicerMacroBuildScriptedModule)
134154 endif ()
135155
136156endmacro ()
137-
138- function (SlicerFunctionAddPythonScriptTrFilesTargets target )
139-
140- set (rewrite_script "${Slicer_CMAKE_DIR} /RewriteTr.py" )
141- if (NOT EXISTS ${rewrite_script} )
142- message (FATAL_ERROR "Rewrite script does not exist [${rewrite_script} ]" )
143- endif ()
144-
145- set (TS_DIR "${CMAKE_CURRENT_SOURCE_DIR} /Resources/Translations/" )
146-
147- #get_property(Slicer_LANGUAGES GLOBAL PROPERTY Slicer_LANGUAGES)
148-
149- get_property (_CTK_${target} _PYTHON_SCRIPTS GLOBAL PROPERTY _CTK_${target} _PYTHON_SCRIPTS)
150-
151- set (rewritten_srcs)
152- foreach (entry IN LISTS _CTK_${target} _PYTHON_SCRIPTS)
153- string (REPLACE "|" ";" tuple "${entry} " )
154- list (GET tuple 0 src)
155- list (GET tuple 1 tgt_file)
156- list (GET tuple 2 dest_dir)
157-
158- set (rewritten_src_file "${tgt_file} .tr" )
159- set (rewritten_src "${dest_dir} /${rewritten_src_file} " )
160-
161- add_custom_command (DEPENDS ${src}
162- COMMAND ${PYTHON_EXECUTABLE}
163- ${rewrite_script} -i ${src} -o ${rewritten_src}
164- OUTPUT ${rewritten_src}
165- COMMENT "Generating .py.tr file into binary directory: ${rewritten_src_file} " )
166-
167- list (APPEND rewritten_srcs ${rewritten_src} )
168- endforeach ()
169-
170- include (SlicerMacroTranslation)
171- SlicerMacroTranslation(
172- SRCS ${rewritten_srcs}
173- TS_DIR ${TS_DIR}
174- TS_BASEFILENAME ${target}
175- TS_LANGUAGES ${Slicer_LANGUAGES}
176- QM_OUTPUT_DIR_VAR QM_OUTPUT_DIR
177- QM_OUTPUT_FILES_VAR QM_OUTPUT_FILES
178- )
179-
180- # store the paths where the qm files are located
181- set_property (GLOBAL APPEND PROPERTY Slicer_QM_OUTPUT_DIRS ${QM_OUTPUT_DIR} )
182-
183- # store the qm files associated with scripted modules
184- set_property (GLOBAL APPEND PROPERTY QM_SCRIPTED_MODULE_FILES ${QM_OUTPUT_FILES} )
185-
186- set (target_name Add${target} PythonScriptTrFiles)
187- if (NOT TARGET ${target_name} )
188- add_custom_target (${target_name} DEPENDS ${rewritten_srcs} ${ARGN} )
189- endif ()
190- endfunction ()
0 commit comments