Commit bf4ac1e6 authored by Csaba Kertesz's avatar Csaba Kertesz
Browse files

Use localization for KStars Lite

parent 5cec0578
......@@ -13,6 +13,9 @@ string(TIMESTAMP KSTARS_BUILD_TS UTC)
if(BUILD_KSTARS_LITE)
set (QT_MIN_VERSION "5.7.0") #QtQuickControls 2 is available only in the Qt 5.7.0
# Download the translations if KStars Lite is built
SET(KDE_L10N_AUTO_TRANSLATIONS ON)
SET(KDE_L10N_BRANCH "trunk")
else()
set (QT_MIN_VERSION "5.4.0")
endif()
......@@ -446,15 +449,26 @@ if ("${CMAKE_TOOLCHAIN_FILE}" MATCHES "android.toolchain.cmake$")
configure_file("${CMAKE_SOURCE_DIR}/android/deployment-file.json.in" "${CMAKE_BINARY_DIR}/android/kstars-deployment.json.in")
add_custom_target(create-apk-kstars
add_custom_target(create-apk-debug-kstars
COMMAND cmake -E echo "Generating $<TARGET_NAME:kstars> with $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt"
COMMAND cmake -E remove_directory "${EXPORT_DIR}"
COMMAND cmake -E copy_directory "${CMAKE_SOURCE_DIR}/android/apk" "${EXPORT_DIR}"
COMMAND cmake -E copy "$<TARGET_FILE:kstars>" "${EXECUTABLE_DESTINATION_PATH}"
COMMAND cmake -DINPUT_FILE="${CMAKE_BINARY_DIR}/android/kstars-deployment.json.in" -DOUTPUT_FILE="${CMAKE_BINARY_DIR}/android/kstars-deployment.json" "-DTARGET_DIR=${CMAKE_BINARY_DIR}/kstars" "-DTARGET_NAME=kstars" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" -P ${CMAKE_SOURCE_DIR}/android/specifydependencies.cmake
COMMAND $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt --input "${CMAKE_BINARY_DIR}/android/kstars-deployment.json" --output "${EXPORT_DIR}" --android-platform android-${ANDROID_API_LEVEL} --debug --deployment bundled "\\$(ARGS)"
)
add_custom_target(create-apk-release-kstars
COMMAND cmake -E echo "Generating $<TARGET_NAME:kstars> with $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt"
COMMAND cmake -E remove_directory "${EXPORT_DIR}"
COMMAND cmake -E copy_directory "${CMAKE_SOURCE_DIR}/android/apk" "${EXPORT_DIR}"
COMMAND cmake -E copy "$<TARGET_FILE:kstars>" "${EXECUTABLE_DESTINATION_PATH}"
COMMAND cmake -DINPUT_FILE="${CMAKE_BINARY_DIR}/android/kstars-deployment.json.in" -DOUTPUT_FILE="${CMAKE_BINARY_DIR}/android/kstars-deployment.json" "-DTARGET_DIR=${CMAKE_BINARY_DIR}/kstars" "-DTARGET_NAME=kstars" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" -P ${CMAKE_SOURCE_DIR}/android/specifydependencies.cmake
COMMAND $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt --input "${CMAKE_BINARY_DIR}/android/kstars-deployment.json" --output "${EXPORT_DIR}" --android-platform android-${ANDROID_API_LEVEL} --release --deployment bundled "\\$(ARGS)"
)
add_custom_target(install-apk-debug-kstars
COMMAND adb install -r ${CMAKE_BINARY_DIR}/android/kstars_build_apk//bin/QtApp-debug.apk
)
if (ANDROID_KEYSTORE AND ANDROID_KEYSTORE_ALIAS)
add_custom_target(sign-apk-kstars
COMMAND jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ${ANDROID_KEYSTORE} ${CMAKE_BINARY_DIR}/android/kstars_build_apk/bin/QtApp-release-unsigned.apk ${ANDROID_KEYSTORE_ALIAS}
......
......@@ -44,6 +44,17 @@ cmake -B. -H$KSTARS_ROOT -DBUILD_KSTARS_LITE=ON -DCMAKE_TOOLCHAIN_FILE=$CMAKE_AN
make -j4
- Download and convert the translations:
make convert_translations_to_android
If the above command dies with the error message:
releaseme/lib/releaseme/l10n.rb:195:in `verify_pot': l10n pot appears to be a variable. cannot resolve $potfile.pot (RuntimeError)
...then comment out this line in the Ruby script and the execution will be fine next time.
- Install:
make -j4 install
......@@ -54,15 +65,23 @@ make -j4 install
Basically, download https://dl.google.com/android/repository/tools_r25.2.5-linux.zip and replace the ANDROID_SDK_DIR/tools directory or
just use the Android SDK download tool to use this version.
- Generate the Android debug and release packages:
- Generate the Android debug package:
make create-apk-debug-kstars
- Install the Android debug package to your phone:
make install-apk-debug-kstars
- Generate the Android release package:
make create-apk-kstars
make create-apk-release-kstars
- To sign a release package:
make sign-apk-kstars
- The debug package location: android/kstars_build_apk/bin/QtApp-debug.apk
Install: adb install android/kstars_build_apk/bin/QtApp-debug.apk
Manual installation: adb install android/kstars_build_apk/bin/QtApp-debug.apk
- The release package location: android/kstars_build_apk/bin/kstars-release-signed.apk
Install: adb install android/kstars_build_apk/bin/kstars-signed.apk
Manual installation: adb install android/kstars_build_apk/bin/kstars-signed.apk
......@@ -48,9 +48,8 @@ sed -i -- 's/target_link_libraries(ktranscript PRIVATE Qt5::Script Qt5::Core)/ta
./kdesrc-build libintl-lite extra-cmake-modules frameworks-android
# Fix some config files
sed -i '/find_package(PythonInterp/ s/^/#/' kde/install/lib/cmake/KF5I18n/KF5I18NMacros.cmake
sed -i '/find_package(PythonInterp/ s/^/#/' kde/install/lib/cmake/KF5I18n/KF5I18nMacros.cmake
sed -i '/find_dependency(Qt5Xml/ s/^/#/' kde/install/lib/cmake/KF5Config/KF5ConfigConfig.cmake
#sed -i '/cxx_decltype/ s/^/#/' ${QT_ANDROID}/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake
cp /usr/lib/x86_64-linux-gnu/libexec/kf5/kconfig_compiler_kf5 $CURDIR/kf5/kde/install/lib/libexec/kf5/kconfig_compiler_kf5
......
......@@ -785,6 +785,17 @@ set(kstarslite_libtess_SRC
libtess/tess.c
)
IF (BUILD_KSTARS_LITE)
ADD_CUSTOM_TARGET(convert_translations ${CMAKE_SOURCE_DIR}/tools/convert_translations.sh ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
ADD_DEPENDENCIES(convert_translations fetch-translations)
IF (ANDROID)
ADD_CUSTOM_TARGET(convert_translations_to_android ${CMAKE_SOURCE_DIR}/tools/convert_translations.sh ${CMAKE_BINARY_DIR}/android/export/share/kstars
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
ADD_DEPENDENCIES(convert_translations_to_android fetch-translations)
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_SOURCE_FILES_PROPERTIES(${kstarslite_libtess_SRC} PROPERTIES COMPILE_FLAGS "-Wno-error")
ENDIF ()
......
......@@ -15,47 +15,46 @@
* *
***************************************************************************/
#include <QDebug>
#include <QPixmap>
#include <QApplication>
#include <QScreen>
#include <QtGlobal>
#ifdef KSTARS_LITE
#include "ksnumbers.h"
#include "kspaths.h"
#include "kstars_debug.h"
#include "kstarsdata.h"
#include "kstarsdatetime.h"
#if defined(KSTARS_LITE)
#include "kstarslite.h"
#include <KLocalizedString>
#else
#include <QCommandLineParser>
#include <QCommandLineOption>
#endif
#include "ksutils.h"
#include "Options.h"
#include "simclock.h"
#include "version.h"
#if !defined(KSTARS_LITE)
#include "kstars.h"
#include "skymap.h"
#endif
#if !defined(KSTARS_LITE)
#include <KAboutData>
#include <KCrash>
#endif
#include <KLocalizedString>
#include "kstars.h"
#include "skymap.h"
#include <QApplication>
#if !defined(KSTARS_LITE)
#include <QCommandLineParser>
#include <QCommandLineOption>
#endif
//DELETE!
#include "projections/projector.h"
#include <QDebug>
#include <QPixmap>
#include <QScreen>
#include <QtGlobal>
#include <QTranslator>
#include "kspaths.h"
#include "kstarsdata.h"
#include "ksutils.h"
#include "kstarsdatetime.h"
#include "simclock.h"
#include "ksnumbers.h"
#include "version.h"
#include "Options.h"
#include "kstars_debug.h"
#ifndef KSTARS_LITE
static const char description[] = I18N_NOOP("Desktop Planetarium");
static const char notice[] = I18N_NOOP("Some images in KStars are for non-commercial use only. See README.images.");
#endif
#if defined(Q_OS_ANDROID)
// __attribute__ is needed because clang-based linking removes the main() symbol from the shared library on Android
Q_DECL_EXPORT
......@@ -83,7 +82,16 @@ int main(int argc, char *argv[])
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
KLocalizedString::setApplicationDomain("kstars");
#if defined(KSTARS_LITE)
#if defined(__ANDROID__)
KLocalizedString::addDomainLocaleDir("kstars", "/data/data/org.kde.kstars.lite/qt-reserved-files/share/kstars/locale");
#else
KLocalizedString::addDomainLocaleDir("kstars", "locale");
#endif
#endif
#ifndef KSTARS_LITE
KCrash::initialize();
KAboutData aboutData("kstars", i18n("KStars"), KSTARS_VERSION, i18n(description), KAboutLicense::GPL,
......
#!/bin/bash
if [ $# -lt 1 ] ; then
echo Usage: convert_translations.sh install_dir
echo
echo The script finds the downloaded translation files \(\*.po\) from the po subdirectory and it converts to
echo mo format what can be loaded on Android directly.
echo
exit 1
fi
mkdir -p $1/locale
DIRS=$(ls -1 po)
echo Convert translations...
for dir in $DIRS; do
NEW_DIR=$1/locale/$dir/LC_MESSAGES
mkdir -p $NEW_DIR
echo Convert po/$dir/kstars.po to $NEW_DIR/kstars.mo
msgfmt po/$dir/kstars.po -o $NEW_DIR/kstars.mo
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment