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
Hide 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")
set
(
SOURCES
src/app/App.cpp
src/app/Database.cpp
src/app/DefaultTranslator.cpp
src/app/Logger.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatProxyModel.cpp
...
...
@@ -51,6 +52,7 @@ set(SOURCES
set
(
HEADERS
src/app/App.hpp
src/app/Database.hpp
src/app/DefaultTranslator.hpp
src/app/Logger.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
...
...
tests/assets/languages/en.ts
View file @
46a1bf4f
...
...
@@ -178,41 +178,29 @@
<
source
>
incomingCall
<
/source
>
<
translation
>
Incoming
call
<
/translation
>
<
/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
>
<
source
>
outgoingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Outgoing
call
<
/translation
>
<
/message
>
<
message
>
<
source
>
declinedIncomingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Declined
incoming
call
<
/translation
>
<
/message
>
<
message
>
<
source
>
declinedOutgoingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Declined
outgoing
call
<
/translation
>
<
/message
>
<
message
>
<
source
>
endedCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Ended
call
<
/translation
>
<
/message
>
<
message
>
<
source
>
missedIncomingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Missed
incoming
call
<
/translation
>
<
/message
>
<
message
>
<
source
>
missedOutgoingCall
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
Missed
outgoing
call
<
/translation
>
<
/message
>
<
/context
>
<
context
>
...
...
tests/src/app/App.cpp
View file @
46a1bf4f
...
...
@@ -29,15 +29,18 @@ App *App::m_instance = nullptr;
App
::
App
(
int
&
argc
,
char
**
argv
)
:
QApplication
(
argc
,
argv
)
{
QString
current_locale
=
QLocale
::
system
().
name
();
// Try to use default locale. Otherwise use english.
if
(
m_translator
.
load
(
QString
(
LANGUAGES_PATH
)
+
current_locale
))
{
installTranslator
(
&
m_translator
);
if
(
m_english_translator
.
load
(
LANGUAGES_PATH
"en"
))
installTranslator
(
&
m_english_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
;
}
else
if
(
m_translator
.
load
(
LANGUAGES_PATH
"en"
))
{
installTranslator
(
&
m_translator
);
}
else
{
qFatal
(
"No translation found."
);
}
}
else
qWarning
()
<<
QStringLiteral
(
"Unable to found translations for locale: %1."
)
.
arg
(
current_locale
);
setWindowIcon
(
QIcon
(
WINDOW_ICON_PATH
));
...
...
tests/src/app/App.hpp
View file @
46a1bf4f
...
...
@@ -5,7 +5,8 @@
#include <QQmlApplicationEngine>
#include <QQmlFileSelector>
#include <QSystemTrayIcon>
#include <QTranslator>
#include "DefaultTranslator.hpp"
class
Notifier
;
...
...
@@ -47,7 +48,9 @@ private:
QQmlApplicationEngine
m_engine
;
QQmlFileSelector
*
m_file_selector
=
nullptr
;
QSystemTrayIcon
*
m_system_tray_icon
=
nullptr
;
QTranslator
m_translator
;
DefaultTranslator
m_default_translator
;
QTranslator
m_english_translator
;
Notifier
*
m_notifier
=
nullptr
;
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