Commit d7e131f0 authored by Stéphane Albert's avatar Stéphane Albert

ENH: Namespace support for Qt lupdate translations (ref. MVDX-15).

TRANS: First t:ry merging (MERGE_TS:BOOL=ON) translations.
parent d2bd8870
......@@ -29,6 +29,7 @@
#include <QLibraryInfo>
#include <QLocale>
#include <QMessageBox>
#include <QTextCodec>
#include <QTranslator>
//
......@@ -38,13 +39,17 @@
// Monteverdi includes (sorted by alphabetic order)
#include "ConfigureMonteverdi2.h"
//
// Class pre-declaration.
//
// Class implementation.
namespace mvd
{
/*
TRANSLATOR mvd::Application
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*******************************************************************************/
Application
......@@ -73,6 +78,10 @@ void
Application
::InitializeCore()
{
//
//
QTextCodec::setCodecForTr( QTextCodec::codecForName( "utf8" ) );
//
// Setup application tags.
QCoreApplication::setApplicationName(
......@@ -85,7 +94,7 @@ Application
//
// Setup organization tags.
QCoreApplication::setOrganizationName(
"Centre National d'Etudes Spatiales (CNES)"
tr( "Centre National d'Etudes Spatiales (CNES)" )
);
QCoreApplication::setOrganizationDomain(
"orfeo-toolbox.org"
......@@ -107,11 +116,18 @@ Application
//
// 1. default UI language is en-US (no translation).
QLocale sys_lc( QLocale::system() );
QLocale en_US_lc( QLocale::English, QLocale::UnitedStates );
if( sys_lc.language()==en_US_lc.language()
&& sys_lc.country()==en_US_lc.country()
QLocale ui_lc(
#if 1
QLocale::English, QLocale::UnitedStates
#else
QLocale::C, QLocale::AnyCountry
#endif
);
if( sys_lc.language()==ui_lc.language()
&& sys_lc.country()==ui_lc.country()
#if QT_VERSION>=0x040800
&& sys_lc.script()==en_US_lc.script()
&& sys_lc.script()==ui_lc.script()
#endif
)
{
......@@ -135,7 +151,7 @@ Application
// TODO: Use log system to trace message.
qDebug()
<< tr( "Running from build directory '%1'" ).arg( bin_dir.path() );
<< tr( "Running from build directory '%1'." ).arg( bin_dir.path() );
}
// Otherwise...
else
......@@ -151,7 +167,7 @@ Application
// TODO: Use log system to trace message.
qDebug()
<< tr( "Running from install directory '%1'" ).arg( Monteverdi2_INSTALL_BIN_DIR );
<< tr( "Running from install directory '%1'." ).arg( Monteverdi2_INSTALL_BIN_DIR );
}
// Otherwise
else
......@@ -166,7 +182,7 @@ Application
qDebug() << message;
// TODO: morph into better HMI design.
QMessageBox::critical( NULL, "Critical...", message );
QMessageBox::critical( NULL, tr( "Critical error!" ), message );
return;
}
......@@ -208,7 +224,7 @@ Application
if( !lc_translator.load( filename, directory, searchDelimiters, suffix ) )
{
QString message(
tr( "Failed to load '%1' translation file in '%2'." )
tr( "Failed to load '%1' translation file from '%2'." )
.arg( filename_ext )
.arg( directory )
);
......@@ -218,7 +234,7 @@ Application
qDebug() << message;
// TODO: morph into better HMI design.
QMessageBox::warning( NULL, "Warning", message );
QMessageBox::warning( NULL, tr( "Warning!" ), message );
return false;
}
......@@ -227,7 +243,7 @@ Application
QCoreApplication::installTranslator( &lc_translator );
QString message(
tr( "Successfully loaded '%1' translation file in '%2'." )
tr( "Successfully loaded '%1' translation file from '%2'." )
.arg( filename_ext )
.arg( directory )
);
......
......@@ -45,12 +45,19 @@
namespace mvd
{
/*
TRANSLATOR mvd::MainWindow
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
MainWindow
::MainWindow( QWidget* parent, Qt::WindowFlags flags ) :
QMainWindow( parent, flags ),
m_UI( new Ui::MainWindow() )
m_UI( new mvd::Ui::MainWindow() )
{
m_UI->setupUi( this );
......
......@@ -36,19 +36,22 @@
//
// Monteverdi includes (sorted by alphabetic order)
// Warning! it's generally not a good idea to use namespaces in header files.
using namespace otb;
using namespace itk;
//
// Class pre-declaration.
// External class pre-declaration.
namespace mvd
{
//
// Internal class pre-declaration.
namespace Ui
{
class MainWindow;
}
namespace mvd
{
/** \class MainWindow
*
*/
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<class>mvd::MainWindow</class>
<widget class="QMainWindow" name="mvd::MainWindow">
<property name="geometry">
<rect>
<x>0</x>
......@@ -11,7 +11,10 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>Main window</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<widget class="QWidget" name="m_CentralWidget"/>
<widget class="QMenuBar" name="m_MenuBar">
......@@ -49,13 +52,22 @@
<property name="text">
<string>&amp;Quit</string>
</property>
<property name="toolTip">
<string>Quit application.</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="action_Open">
<property name="text">
<string>&amp;Open</string>
<string>&amp;Open...</string>
</property>
<property name="iconText">
<string>Open...</string>
</property>
<property name="toolTip">
<string>Open file.</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
......
......@@ -3,7 +3,7 @@
#----------------------------------------------------------------------------
# Locale human-readable translation files.
set( Monteverdi2_TS_TRANSLATIONS
# en_US.ts
# en_US.ts
fr_FR.ts
)
#
......
......@@ -2,76 +2,99 @@
<!DOCTYPE TS>
<TS version="2.0" language="fr_FR">
<context>
<name>MainWindow</name>
<name>mvd::Application</name>
<message>
<source>MainWindow</source>
<translation>Fenêtre principale</translation>
<source>Running from build directory &apos;%1&apos;.</source>
<translation>Exécution depuis le répertoire de compilation &apos;%1&apos;.</translation>
</message>
<message>
<source>&amp;File</source>
<translation>&amp;Fichier</translation>
<source>Running from install directory &apos;%1&apos;.</source>
<translation>Exécution depuis le répertoire d&apos;installation &apos;%1&apos;.</translation>
</message>
<message>
<source>toolBar</source>
<translation type="unfinished">Barre d&apos;outils</translation>
<source>Failed to access translation-files directory &apos;%1&apos;.</source>
<translation>Échec d&apos;accès au répertoire &apos;%1&apos; contenant les fichiers de traduction.</translation>
</message>
<message>
<source>&amp;Quit</source>
<translation>&amp;Quitter</translation>
<source>Critical error!</source>
<translation>Erreur critique !</translation>
</message>
<message>
<source>Ctrl+Q</source>
<translation type="unfinished"></translation>
<source>Warning!</source>
<translation>Avertissement !</translation>
</message>
<message>
<source>&amp;Open</source>
<translation>&amp;Ouvrir</translation>
<source>&gt;DEBUG&gt; mvd::Application::OnAboutToQuit().</source>
<translation></translation>
</message>
<message>
<source>Ctrl+O</source>
<translation type="unfinished"></translation>
<source>Failed to load &apos;%1&apos; translation file from &apos;%2&apos;.</source>
<translation>Échec de chargement du fichier de traduction &apos;%1&apos; depuis &apos;%2&apos;.</translation>
</message>
<message>
<source>Successfully loaded &apos;%1&apos; translation file from &apos;%2&apos;.</source>
<translation>Chargement réussi du fichier de traduction &apos;%1&apos; depuis &apos;%2&apos;.</translation>
</message>
<message>
<source></source>
<comment>Necessary for lupdate to be aware of C++ namespaces. Context comment for translator.</comment>
<translation></translation>
</message>
<message>
<source>Centre National d&apos;Etudes Spatiales (CNES)</source>
<translation>Centre National d&apos;Études Spatiales (CNES)</translation>
</message>
</context>
<context>
<name>mvd::Application</name>
<name>mvd::MainWindow</name>
<message>
<source>Open file...</source>
<translation>Ouvrir fichier...</translation>
</message>
<message>
<source>Running from build directory &apos;%1&apos;</source>
<translation>Exécution depuis le répertoire de compilation &apos;%1&apos;</translation>
<source>Main window</source>
<translation>Fenêtre principale</translation>
</message>
<message>
<source>Running from install directory &apos;%1&apos;</source>
<translation>Exécution depuis le répertoire d&apos;installation &apos;%1&apos;</translation>
<source>&amp;File</source>
<translation>&amp;Fichier</translation>
</message>
<message>
<source>Failed to access translation-files directory &apos;%1&apos;.</source>
<translation>Échec d&apos;accès au répertoire &apos;%1&apos; contenant les fichiers de traduction.</translation>
<source>Main toolbar</source>
<translation>Barre d&apos;outils principale</translation>
</message>
<message>
<source>Failed to load &apos;%1&apos; translation file in &apos;%2&apos;.</source>
<translation>Échec de chargement du fichier traduction &apos;%1&apos; depuis le répertoire &apos;%2&apos;.</translation>
<source>&amp;Quit</source>
<translation>&amp;Quitter</translation>
</message>
<message>
<source>Successfully loaded &apos;%1&apos; translation file in &apos;%2&apos;.</source>
<translation>Fichier de traduction &apos;%1&apos; chargé avec succès depuis le répertoire &apos;%2&apos;.</translation>
<source>Quit application.</source>
<translation>Quitter l&apos;application.</translation>
</message>
<message>
<source>&gt;DEBUG&gt; mvd::Application::OnAboutToQuit().</source>
<source>Ctrl+Q</source>
<translation></translation>
</message>
</context>
<context>
<name>mvd::MainWindow</name>
<message>
<source>&gt;DEBUG&gt; Failed to load &apos;%s&apos; translation file.</source>
<translation type="unfinished"></translation>
<source>&amp;Open...</source>
<translation>&amp;Ouvrir...</translation>
</message>
<message>
<source>&gt;DEBUG&gt; Loaded &apos;%s&apos; translation file.</source>
<translation type="unfinished"></translation>
<source>Open...</source>
<translation>Ouvrir...</translation>
</message>
<message>
<source>Open file...</source>
<translation>Ouvrir fichier...</translation>
<source>Open file.</source>
<translation>Ouvrir fichier.</translation>
</message>
<message>
<source>Ctrl+O</source>
<translation></translation>
</message>
<message>
<source></source>
<comment>Necessary for lupdate to be aware of C++ namespaces. Context comment for translator.</comment>
<translation></translation>
</message>
</context>
</TS>
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