Commit 46dc0c3f authored by Alexandre Lision's avatar Alexandre Lision Committed by Guillaume Roguez

i18n: add lrc translation

We package what is found in the cmake install prefix for LRC translation
files. All .qm files are place in the final app Bundle under
Resources/QtTranslations.

When app starts a QTranslator loads matching .qm file based on system
language.

Issue: #80347
Change-Id: I078d058b961ce35ecd16a03411e4d19fa2a50173
parent 1183b0f4
......@@ -187,17 +187,40 @@ SET_SOURCE_FILES_PROPERTIES(${ring_ICONS} PROPERTIES
SET_SOURCE_FILES_PROPERTIES(Credits.rtf PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
# Check which translations are found for LRC
SET(LRC_TRANSLATIONS_PATH ${CMAKE_INSTALL_PREFIX}/share/libringclient/translations)
FILE(GLOB QM_LIST ${LRC_TRANSLATIONS_PATH}/*.qm)
FOREACH(QM_FILE ${QM_LIST})
# Extract country code from filename
GET_FILENAME_COMPONENT(FILENAME ${QM_FILE} NAME_WE)
STRING(REGEX REPLACE "^lrc_" "" LANG ${FILENAME})
SET_SOURCE_FILES_PROPERTIES(${LRC_TRANSLATIONS_PATH}/lrc_${LANG}.qm
PROPERTIES MACOSX_PACKAGE_LOCATION Resources/QtTranslations)
SET(LOCALIZED_${LANG} ${LOCALIZED_${LANG}}
"${LRC_TRANSLATIONS_PATH}/lrc_${LANG}.qm")
# Regroup those files under a .lproj folder
SOURCE_GROUP("Resources\\${LANG}.lproj" FILES
${LOCALIZED_${LANG}})
# Add them to the list of files to package
SET(LOCALIZABLE_FILES ${LOCALIZABLE_FILES} ${LOCALIZED_${LANG}})
ENDFOREACH()
# append '.xib' extension before linking xib files in executable
FOREACH(xib ${ringclient_XIBS})
SET(ringclient_XIBS_FOR_EXECUTABLE ${ringclient_XIBS_FOR_EXECUTABLE} ui/${xib}.xib)
ENDFOREACH()
SET(TO_ADD
SET(TO_ADD
${ringclient_CONTROLLERS}
${ringclient_BACKENDS}
${ringclient_VIEWS}
${ringclient_OTHERS}
${ringclient_XIBS_FOR_EXECUTABLE}
${LOCALIZABLE_FILES}
${myApp_ICON}
Credits.rtf
${ring_ICONS})
......@@ -213,7 +236,8 @@ SOURCE_GROUP("Controllers" FILES ${ringclient_CONTROLLERS})
SOURCE_GROUP("Backends" FILES ${ringclient_BACKENDS})
SOURCE_GROUP("CustomViews" FILES ${ringclient_VIEWS})
SOURCE_GROUP("Classes" FILES ${ringclient_OTHERS})
SOURCE_GROUP("Resources\\Interface Builder" FILES ${ringclient_XIBS_FOR_EXECUTABLE})
SOURCE_GROUP("Resources\\Interface Builder" FILES
${ringclient_XIBS_FOR_EXECUTABLE})
IF(ENABLE_SPARKLE)
SOURCE_GROUP("Frameworks" FILES ${SPARKLE_FRAMEWORK})
......
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -27,13 +27,18 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import <AppKit/NSApplication.h> // NSApplicationMain
#import <AppKit/NSApplication.h>
//Qt
#import <qapplication.h>
#import <globalinstances.h>
#import <memory>
#import <QDebug>
#import <QDir>
#import <QTranslator>
#import <QLocale>
#import "backends/AddressBookBackend.h"
#import "delegates/ImageManipulationDelegate.h"
int main(int argc, const char *argv[]) {
......@@ -48,6 +53,12 @@ int main(int argc, const char *argv[]) {
QApplication* app = new QApplication(argc, const_cast<char**>(argv));
app->setAttribute(Qt::AA_MacPluginApplication);
dir.cdUp();
QTranslator translator;
if (translator.load(QLocale::system(), "lrc", "_", dir.absolutePath()+"/Resources/QtTranslations")) {
app->installTranslator(&translator);
}
GlobalInstances::setPixmapManipulator(std::unique_ptr<Interfaces::ImageManipulationDelegate>(new Interfaces::ImageManipulationDelegate()));
......
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