10 changes: 10 additions & 0 deletions Messages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash
# Adapted from the Messages.sh file in trojita
# xgettext-generated .po files use different context than QObject::tr.
# The generated files use something like a file name while QObject::tr expects
# class names. This approach works.

rm -f "${podir}/kst.ts"
lupdate -silent -recursive src/ -ts "${podir}/kst.ts"
lconvert "${podir}/kst.ts" --sort-contexts --output-format pot -o "${podir}/kst_common.pot"
rm "${podir}/kst.ts"
35 changes: 34 additions & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,17 @@ else()
endif()
endif()

message(STATUS)
#linguist tools
if(WITH_QT5)
find_package(Qt5LinguistTools)
if(Qt5LinguistTools_FOUND)
find_package(Qt5LinguistForKst)
endif()
else()
find_package(LinguistForKst)
endif()

message(STATUS)


# React on options
Expand Down Expand Up @@ -363,6 +372,30 @@ if(WIN32)
set(CPACK_BINARY_ZIP 1)
endif()

#adapted from [trojita.git] / CMakeLists.txt
if(LinguistForKst_FOUND OR Qt5LinguistForKst_FOUND)
file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/kst_common_*.po")
if(WITH_QT5)
qt5_wrap_po(trojita_QM ${lang_PO})
else()
qt4_wrap_po(trojita_QM ${lang_PO})
endif()
set(language_summary "")
foreach(po ${lang_PO})
string(REGEX REPLACE "^(.*)/kst_common_(.*).po" "\\2" lang ${po})
list(APPEND language_summary ${lang})
endforeach()
list(SORT language_summary)
list(LENGTH language_summary num_languages)
if(num_languages)
message(STATUS "Available languages: ${language_summary}")
install(DIRECTORY ${CMAKE_BINARY_DIR}/locale/ DESTINATION share/kst/locale FILES_MATCHING PATTERN *.qm)
else()
message(STATUS "No .po files found, will not install any languages")
endif()
else()
message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
endif()

if(kst_install_prefix)
if(WIN32)
Expand Down
142 changes: 142 additions & 0 deletions cmake/modules/FindLinguistForKst.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Adapted from [trojita.git] / cmake / FindLinguistForTrojita.cmake
# check for lupdate and lrelease: we can't
# do it using qmake as it doesn't have
# QMAKE_LUPDATE and QMAKE_LRELEASE variables :(
#
# I18N_LANGUAGE - if not empty, wraps only chosen language
#

# One problem is that FindQt4.cmake will look for these and cache the results
# If users have lrelease from Qt3 (e.g., Debian, Ubuntu)
# then we will fail.

# First remove these from cache
set(QT_LUPDATE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
set(QT_LRELEASE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
set(QT_LCONVERT_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)

FIND_PROGRAM(QT_LUPDATE_EXECUTABLE NAMES lupdate-qt4 lupdate PATHS
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
$ENV{QTDIR}/bin
)

if(QT_LUPDATE_EXECUTABLE)
message(STATUS "Found lupdate: ${QT_LUPDATE_EXECUTABLE}")
else(QT_LUPDATE_EXECUTABLE)
if(LinguistForKst_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find lupdate")
endif(LinguistForKst_FIND_REQUIRED)
endif(QT_LUPDATE_EXECUTABLE)

FIND_PROGRAM(QT_LRELEASE_EXECUTABLE NAMES lrelease-qt4 lrelease PATHS
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
$ENV{QTDIR}/bin
)

if(QT_LRELEASE_EXECUTABLE)
message(STATUS "Found lrelease: ${QT_LRELEASE_EXECUTABLE}")
else(QT_LRELEASE_EXECUTABLE)
if(LinguistForKst_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find lrelease")
endif(LinguistForKst_FIND_REQUIRED)
endif(QT_LRELEASE_EXECUTABLE)

FIND_PROGRAM(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt4 lconvert PATHS
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
$ENV{QTDIR}/bin
)

if(QT_LCONVERT_EXECUTABLE)
message(STATUS "Found lconvert: ${QT_LCONVERT_EXECUTABLE}")
else(QT_LCONVERT_EXECUTABLE)
if(LinguistForKst_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find lconvert")
endif(LinguistForKst_FIND_REQUIRED)
endif(QT_LCONVERT_EXECUTABLE)

mark_as_advanced(QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_LCONVERT_EXECUTABLE)

if(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE)
set(LinguistForKst_FOUND TRUE)

# QT4_WRAP_TS(outfiles infiles ...)
# outfiles receives .qm generated files from
# .ts files in arguments
# a target lupdate is created for you
# update/generate your translations files
# example: QT4_WRAP_TS(foo_QM ${foo_TS})
MACRO (QT4_WRAP_TS outfiles)
# a target to manually run lupdate
#ADD_CUSTOM_TARGET(lupdate
#COMMAND ${QT_LUPDATE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} -ts ${ARGN}
#WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
#)
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)

SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.qm)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_LRELEASE_EXECUTABLE}
ARGS -compress -removeidentical -silent ${it} -qm ${outfile}
DEPENDS ${it}
)

SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_TS)

# QT_WRAP_PO(outfiles infiles ...)
# outfiles receives .qm generated files from
# .po files in arguments
# example: QT4_WRAP_PO(foo_TS ${foo_PO})
MACRO (QT4_WRAP_PO outfiles)
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
# PO files are foo-en_GB.po not foo_en_GB.po like Qt expects
GET_FILENAME_COMPONENT(fileWithDash ${it} NAME_WE)
if(NOT I18N_LANGUAGE)
set(do_wrap ON)
else(NOT I18N_LANGUAGE)
string(REGEX MATCH "${I18N_LANGUAGE}" ln ${fileWithDash})
if(ln)
set(do_wrap ON)
else(ln)
set(do_wrap OFF)
endif(ln)
endif(NOT I18N_LANGUAGE)
if(do_wrap)
STRING(REPLACE "-" "_" filenameBase "${fileWithDash}")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale)
SET(tsfile ${CMAKE_CURRENT_BINARY_DIR}/locale/${filenameBase}.ts)
SET(qmfile ${CMAKE_CURRENT_BINARY_DIR}/locale/${filenameBase}.qm)

if (NOT EXISTS "${it}")
GET_FILENAME_COMPONENT(path ${it} PATH)
STRING(REGEX MATCH "[^-]+$" lang "${fileWithDash}")
set (it "${path}/${lang}.po")
endif (NOT EXISTS "${it}")

# lconvert from PO to TS and then run lupdate to generate the correct strings
# finally run lrelease as used above
ADD_CUSTOM_COMMAND(OUTPUT ${qmfile}
COMMAND ${QT_LCONVERT_EXECUTABLE}
ARGS -i ${it} -o ${tsfile}
COMMAND ${QT_LUPDATE_EXECUTABLE}
ARGS ${CMAKE_CURRENT_SOURCE_DIR} -silent -noobsolete -ts ${tsfile}
COMMAND ${QT_LRELEASE_EXECUTABLE}
ARGS -compress -removeidentical -silent ${tsfile} -qm ${qmfile}
DEPENDS ${it}
)

SET(${outfiles} ${${outfiles}} ${qmfile})
endif(do_wrap)
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_PO)

else(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE)
set(LinguistForKst_FOUND FALSE)
endif(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE)
135 changes: 135 additions & 0 deletions cmake/modules/FindQt5LinguistForTrojita.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# adapted from [trojita.git] / cmake / FindQt5LinguistForKst.cmake
# check for lupdate and lrelease: we can't
# do it using qmake as it doesn't have
# QMAKE_LUPDATE and QMAKE_LRELEASE variables :(
#
# I18N_LANGUAGE - if not empty, wraps only chosen language
#

get_filename_component(LINGUIST_PATH ${Qt5LinguistTools_DIR} PATH)
get_filename_component(LINGUIST_PATH ${LINGUIST_PATH} PATH)
get_filename_component(LINGUIST_PATH ${LINGUIST_PATH} PATH)
set(LINGUIST_PATH ${LINGUIST_PATH}/bin)

FIND_PROGRAM(QT_LUPDATE_EXECUTABLE NAMES lupdate-qt5 lupdate PATHS
${LINGUIST_PATH}
NO_DEFAULT_PATH
)

if(QT_LUPDATE_EXECUTABLE)
message(STATUS "Found lupdate: ${QT_LUPDATE_EXECUTABLE}")
else(QT_LUPDATE_EXECUTABLE)
if(Qt5LinguistForKst_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find lupdate")
endif(Qt5LinguistForKst_FIND_REQUIRED)
endif(QT_LUPDATE_EXECUTABLE)

FIND_PROGRAM(QT_LRELEASE_EXECUTABLE NAMES lrelease-qt5 lrelease PATHS
${LINGUIST_PATH}
NO_DEFAULT_PATH
)

if(QT_LRELEASE_EXECUTABLE)
message(STATUS "Found lrelease: ${QT_LRELEASE_EXECUTABLE}")
else(QT_LRELEASE_EXECUTABLE)
if(Qt5LinguistForKst_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find lrelease")
endif(Qt5LinguistForKst_FIND_REQUIRED)
endif(QT_LRELEASE_EXECUTABLE)

FIND_PROGRAM(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt5 lconvert PATHS
${LINGUIST_PATH}
NO_DEFAULT_PATH
)

if(QT_LCONVERT_EXECUTABLE)
message(STATUS "Found lconvert: ${QT_LCONVERT_EXECUTABLE}")
else(QT_LCONVERT_EXECUTABLE)
if(Qt5LinguistForKst_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find lconvert")
endif(Qt5LinguistForKst_FIND_REQUIRED)
endif(QT_LCONVERT_EXECUTABLE)

mark_as_advanced(QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_LCONVERT_EXECUTABLE)

if(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE)
set(Qt5LinguistForKst_FOUND TRUE)

# QT5_WRAP_TS(outfiles infiles ...)
# outfiles receives .qm generated files from
# .ts files in arguments
# a target lupdate is created for you
# update/generate your translations files
# example: QT5_WRAP_TS(foo_QM ${foo_TS})
MACRO (QT5_WRAP_TS outfiles)
# a target to manually run lupdate
#ADD_CUSTOM_TARGET(lupdate
#COMMAND ${QT_LUPDATE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} -ts ${ARGN}
#WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
#)
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)

SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.qm)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_LRELEASE_EXECUTABLE}
ARGS -compress -removeidentical -silent ${it} -qm ${outfile}
DEPENDS ${it}
)

SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT5_WRAP_TS)

# QT_WRAP_PO(outfiles infiles ...)
# outfiles receives .qm generated files from
# .po files in arguments
# example: QT5_WRAP_PO(foo_TS ${foo_PO})
MACRO (QT5_WRAP_PO outfiles)
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
# PO files are foo-en_GB.po not foo_en_GB.po like Qt expects
GET_FILENAME_COMPONENT(fileWithDash ${it} NAME_WE)
if(NOT I18N_LANGUAGE)
set(do_wrap ON)
else(NOT I18N_LANGUAGE)
string(REGEX MATCH "${I18N_LANGUAGE}" ln ${fileWithDash})
if(ln)
set(do_wrap ON)
else(ln)
set(do_wrap OFF)
endif(ln)
endif(NOT I18N_LANGUAGE)
if(do_wrap)
STRING(REPLACE "-" "_" filenameBase "${fileWithDash}")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale)
SET(tsfile ${CMAKE_CURRENT_BINARY_DIR}/locale/${filenameBase}.ts)
SET(qmfile ${CMAKE_CURRENT_BINARY_DIR}/locale/${filenameBase}.qm)

if (NOT EXISTS "${it}")
GET_FILENAME_COMPONENT(path ${it} PATH)
STRING(REGEX MATCH "[^-]+$" lang "${fileWithDash}")
set (it "${path}/${lang}.po")
endif (NOT EXISTS "${it}")

# lconvert from PO to TS and then run lupdate to generate the correct strings
# finally run lrelease as used above
ADD_CUSTOM_COMMAND(OUTPUT ${qmfile}
COMMAND ${QT_LCONVERT_EXECUTABLE}
ARGS -i ${it} -o ${tsfile}
COMMAND ${QT_LUPDATE_EXECUTABLE}
ARGS ${CMAKE_CURRENT_SOURCE_DIR} -silent -noobsolete -ts ${tsfile}
COMMAND ${QT_LRELEASE_EXECUTABLE}
ARGS -compress -removeidentical -silent ${tsfile} -qm ${qmfile}
DEPENDS ${it}
)

SET(${outfiles} ${${outfiles}} ${qmfile})
endif(do_wrap)
ENDFOREACH (it)
ENDMACRO (QT5_WRAP_PO)

else(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE)
set(Qt5LinguistForKst_FOUND FALSE)
endif(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE)
4 changes: 2 additions & 2 deletions src/datasources/ascii/asciiconfigwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* *
***************************************************************************/

#ifndef ASCII_CONFIG_WINDGET_H
#define ASCII_CONFIG_WINDGET_H
#ifndef ASCIICONFIGWINDGET_H
#define ASCIICONFIGWINDGET_H

#include "asciisource.h"
#include "dataplugin.h"
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/ascii/asciidatainterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* *
***************************************************************************/

#ifndef KST_ASCII_DATA_INTERFACE_H
#define KST_ASCII_DATA_INTERFACE_H
#ifndef ASCIIDATAINTERFACES_H
#define ASCIIDATAINTERFACES_H

#include "datasource.h"
#include "dataplugin.h"
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/ascii/asciifiledata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* *
***************************************************************************/

#include "asciifiledata.h"

#ifndef QT5
// needed to track memeory usage
#include "qplatformdefs.h"
Expand All @@ -27,14 +29,12 @@ void fileBufferFree(void* ptr);
#undef qFree
#endif

#include "asciifiledata.h"
#include "debug.h"

#include <QFile>
#include <QDebug>
#include <QByteArray>


int MB = 1024*1024;

// Simulate out of memory scenario
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/netcdf/netcdfplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* *
***************************************************************************/

#ifndef KST_NETCDF_H
#define KST_NETCDF_PLUGIN_H
#ifndef NETCDFPLUGIN_H
#define NETCDFPLUGIN_H

#include "dataplugin.h"

Expand Down
Loading