Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
46a1bf4f
Commit
46a1bf4f
authored
Nov 28, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app/App): use own translator
parent
85b3c816
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
28 deletions
+61
-28
CMakeLists.txt
tests/CMakeLists.txt
+2
-0
en.ts
tests/assets/languages/en.ts
+6
-18
App.cpp
tests/src/app/App.cpp
+11
-8
App.hpp
tests/src/app/App.hpp
+5
-2
DefaultTranslator.cpp
tests/src/app/DefaultTranslator.cpp
+20
-0
DefaultTranslator.hpp
tests/src/app/DefaultTranslator.hpp
+17
-0
No files found.
tests/CMakeLists.txt
View file @
46a1bf4f
...
@@ -32,6 +32,7 @@ list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/liblinphone++.so")
...
@@ -32,6 +32,7 @@ list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/liblinphone++.so")
set
(
SOURCES
set
(
SOURCES
src/app/App.cpp
src/app/App.cpp
src/app/Database.cpp
src/app/Database.cpp
src/app/DefaultTranslator.cpp
src/app/Logger.cpp
src/app/Logger.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatProxyModel.cpp
src/components/chat/ChatProxyModel.cpp
...
@@ -51,6 +52,7 @@ set(SOURCES
...
@@ -51,6 +52,7 @@ set(SOURCES
set
(
HEADERS
set
(
HEADERS
src/app/App.hpp
src/app/App.hpp
src/app/Database.hpp
src/app/Database.hpp
src/app/DefaultTranslator.hpp
src/app/Logger.hpp
src/app/Logger.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
src/components/chat/ChatProxyModel.hpp
...
...
tests/assets/languages/en.ts
View file @
46a1bf4f
...
@@ -178,41 +178,29 @@
...
@@ -178,41 +178,29 @@
<
source
>
incomingCall
<
/source
>
<
source
>
incomingCall
<
/source
>
<
translation
>
Incoming
call
<
/translation
>
<
translation
>
Incoming
call
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
source
>
hangup
<
/source
>
<
translation
type
=
"
vanished
"
>
End
call
<
/translation
>
<
/message
>
<
message
>
<
source
>
lostIncomingCall
<
/source
>
<
translation
type
=
"
vanished
"
>
Lost
incoming
call
<
/translation
>
<
/message
>
<
message
>
<
source
>
lostOutgoingCall
<
/source
>
<
translation
type
=
"
vanished
"
>
Lost
outgoing
call
<
/translation
>
<
/message
>
<
message
>
<
message
>
<
source
>
outgoingCall
<
/source
>
<
source
>
outgoingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Outgoing
call
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
source
>
declinedIncomingCall
<
/source
>
<
source
>
declinedIncomingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Declined
incoming
call
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
source
>
declinedOutgoingCall
<
/source
>
<
source
>
declinedOutgoingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Declined
outgoing
call
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
source
>
endedCall
<
/source
>
<
source
>
endedCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Ended
call
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
source
>
missedIncomingCall
<
/source
>
<
source
>
missedIncomingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Missed
incoming
call
<
/translation
>
<
/message
>
<
/message
>
<
message
>
<
message
>
<
source
>
missedOutgoingCall
<
/source
>
<
source
>
missedOutgoingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Missed
outgoing
call
<
/translation
>
<
/message
>
<
/message
>
<
/context
>
<
/context
>
<
context
>
<
context
>
...
...
tests/src/app/App.cpp
View file @
46a1bf4f
...
@@ -29,15 +29,18 @@ App *App::m_instance = nullptr;
...
@@ -29,15 +29,18 @@ App *App::m_instance = nullptr;
App
::
App
(
int
&
argc
,
char
**
argv
)
:
QApplication
(
argc
,
argv
)
{
App
::
App
(
int
&
argc
,
char
**
argv
)
:
QApplication
(
argc
,
argv
)
{
QString
current_locale
=
QLocale
::
system
().
name
();
QString
current_locale
=
QLocale
::
system
().
name
();
// Try to use default locale. Otherwise use english.
if
(
m_english_translator
.
load
(
LANGUAGES_PATH
"en"
))
if
(
m_translator
.
load
(
QString
(
LANGUAGES_PATH
)
+
current_locale
))
{
installTranslator
(
&
m_english_translator
);
installTranslator
(
&
m_translator
);
else
qWarning
(
"Unable to install english translator."
);
// Try to use default locale.
if
(
m_default_translator
.
load
(
QString
(
LANGUAGES_PATH
)
+
current_locale
))
{
installTranslator
(
&
m_default_translator
);
m_locale
=
current_locale
;
m_locale
=
current_locale
;
}
else
if
(
m_translator
.
load
(
LANGUAGES_PATH
"en"
))
{
}
else
installTranslator
(
&
m_translator
);
qWarning
()
<<
QStringLiteral
(
"Unable to found translations for locale: %1."
)
}
else
{
.
arg
(
current_locale
);
qFatal
(
"No translation found."
);
}
setWindowIcon
(
QIcon
(
WINDOW_ICON_PATH
));
setWindowIcon
(
QIcon
(
WINDOW_ICON_PATH
));
...
...
tests/src/app/App.hpp
View file @
46a1bf4f
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
#include <QQmlApplicationEngine>
#include <QQmlApplicationEngine>
#include <QQmlFileSelector>
#include <QQmlFileSelector>
#include <QSystemTrayIcon>
#include <QSystemTrayIcon>
#include <QTranslator>
#include "DefaultTranslator.hpp"
class
Notifier
;
class
Notifier
;
...
@@ -47,7 +48,9 @@ private:
...
@@ -47,7 +48,9 @@ private:
QQmlApplicationEngine
m_engine
;
QQmlApplicationEngine
m_engine
;
QQmlFileSelector
*
m_file_selector
=
nullptr
;
QQmlFileSelector
*
m_file_selector
=
nullptr
;
QSystemTrayIcon
*
m_system_tray_icon
=
nullptr
;
QSystemTrayIcon
*
m_system_tray_icon
=
nullptr
;
QTranslator
m_translator
;
DefaultTranslator
m_default_translator
;
QTranslator
m_english_translator
;
Notifier
*
m_notifier
=
nullptr
;
Notifier
*
m_notifier
=
nullptr
;
QString
m_locale
=
"en"
;
QString
m_locale
=
"en"
;
...
...
tests/src/app/DefaultTranslator.cpp
0 → 100644
View file @
46a1bf4f
#include <QtDebug>
#include "DefaultTranslator.hpp"
// ===================================================================
QString
DefaultTranslator
::
translate
(
const
char
*
context
,
const
char
*
source_text
,
const
char
*
disambiguation
,
int
n
)
const
{
QString
translation
=
QTranslator
::
translate
(
context
,
source_text
,
disambiguation
,
n
);
if
(
translation
.
length
()
==
0
)
qWarning
()
<<
QStringLiteral
(
"Unable to found a translation. (context=%1, label=%2)"
)
.
arg
(
context
).
arg
(
source_text
);
return
translation
;
}
tests/src/app/DefaultTranslator.hpp
0 → 100644
View file @
46a1bf4f
#ifndef DEFAULT_TRANSLATOR_H_
#define DEFAULT_TRANSLATOR_H_
#include <QTranslator>
// ===================================================================
class
DefaultTranslator
:
public
QTranslator
{
QString
translate
(
const
char
*
context
,
const
char
*
source_text
,
const
char
*
disambiguation
=
Q_NULLPTR
,
int
n
=
-
1
)
const
override
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment