Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
lifo
Nicolas Ollinger
OpenBoard
Commits
a07b09ec
Commit
a07b09ec
authored
Sep 03, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/claudio-dev' into develop
parents
81c42f53
a495f5f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
44 deletions
+62
-44
UBApplication.cpp
src/core/UBApplication.cpp
+60
-42
UBApplication.h
src/core/UBApplication.h
+2
-2
No files found.
src/core/UBApplication.cpp
View file @
a07b09ec
...
...
@@ -139,15 +139,7 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
UBSettings
*
settings
=
UBSettings
::
settings
();
QString
forcedLanguage
(
""
);
if
(
args
.
contains
(
"-lang"
))
forcedLanguage
=
args
.
at
(
args
.
indexOf
(
"-lang"
)
+
1
);
else
{
QString
setLanguage
=
settings
->
appPreferredLanguage
->
get
().
toString
();
if
(
!
setLanguage
.
isEmpty
())
forcedLanguage
=
setLanguage
;
}
setupTranslator
(
forcedLanguage
);
setupTranslators
(
args
);
connect
(
settings
->
appToolBarPositionedAtTop
,
SIGNAL
(
changed
(
QVariant
)),
this
,
SLOT
(
toolBarPositionChanged
(
QVariant
)));
connect
(
settings
->
appToolBarDisplayText
,
SIGNAL
(
changed
(
QVariant
)),
this
,
SLOT
(
toolBarDisplayTextChanged
(
QVariant
)));
...
...
@@ -207,45 +199,71 @@ UBApplication::~UBApplication()
staticMemoryCleaner
=
0
;
}
void
UBApplication
::
setupTranslator
(
QString
forcedL
anguage
)
QString
UBApplication
::
checkLanguageAvailabilityForSankore
(
QString
&
l
anguage
)
{
QStringList
availablesTranslations
=
UBPlatformUtils
::
availableTranslations
();
QString
language
(
""
);
if
(
!
forcedLanguage
.
isEmpty
()){
if
(
availablesTranslations
.
contains
(
forcedLanguage
,
Qt
::
CaseInsensitive
))
language
=
forcedLanguage
;
else
qDebug
()
<<
"forced language "
<<
forcedLanguage
<<
" not available"
;
}
else
{
QString
systemLanguage
=
UBPlatformUtils
::
systemLanguage
();
if
(
availablesTranslations
.
contains
(
systemLanguage
,
Qt
::
CaseInsensitive
))
language
=
systemLanguage
;
else
qDebug
()
<<
"translation for system language "
<<
systemLanguage
<<
" not found"
;
}
if
(
language
.
isEmpty
()){
language
=
"en_US"
;
//fallback if no translation are available
}
else
{
mApplicationTranslator
=
new
QTranslator
(
this
);
mQtGuiTranslator
=
new
QTranslator
(
this
);
QStringList
availableTranslations
=
UBPlatformUtils
::
availableTranslations
();
if
(
availableTranslations
.
contains
(
language
,
Qt
::
CaseInsensitive
))
return
language
;
else
{
if
(
language
.
length
()
>
2
){
QString
shortLanguageCode
=
language
.
left
(
2
);
if
(
availableTranslations
.
contains
(
shortLanguageCode
,
Qt
::
CaseInsensitive
))
return
shortLanguageCode
;
}
}
return
QString
(
""
);
}
void
UBApplication
::
setupTranslators
(
QStringList
args
)
{
QString
forcedLanguage
;
if
(
args
.
contains
(
"-lang"
))
forcedLanguage
=
args
.
at
(
args
.
indexOf
(
"-lang"
)
+
1
);
else
{
QString
setLanguage
=
UBSettings
::
settings
()
->
appPreferredLanguage
->
get
().
toString
();
if
(
!
setLanguage
.
isEmpty
())
forcedLanguage
=
setLanguage
;
}
QStringList
availablesTranslations
=
UBPlatformUtils
::
availableTranslations
();
QString
language
(
""
);
if
(
!
forcedLanguage
.
isEmpty
())
language
=
checkLanguageAvailabilityForSankore
(
forcedLanguage
);
if
(
language
.
isEmpty
()){
QString
systemLanguage
=
UBPlatformUtils
::
systemLanguage
();
language
=
checkLanguageAvailabilityForSankore
(
systemLanguage
);
}
if
(
language
.
isEmpty
()){
language
=
"en_US"
;
//fallback if no translation are available
}
else
{
mApplicationTranslator
=
new
QTranslator
(
this
);
mQtGuiTranslator
=
new
QTranslator
(
this
);
mApplicationTranslator
->
load
(
UBPlatformUtils
::
translationPath
(
QString
(
"sankore_"
),
language
));
installTranslator
(
mApplicationTranslator
);
installTranslator
(
mApplicationTranslator
);
QString
qtGuiTranslationPath
=
UBPlatformUtils
::
translationPath
(
"qt_"
,
language
);
mQtGuiTranslator
->
load
(
UBPlatformUtils
::
translationPath
(
QString
(
"qt_"
),
language
));
if
(
!
mQtGuiTranslator
->
isEmpty
()){
// checked because this translation could be not available
installTranslator
(
mQtGuiTranslator
);
}
else
qDebug
()
<<
"Qt gui translation in "
<<
language
<<
" are not available"
;
}
if
(
!
QFile
(
qtGuiTranslationPath
).
exists
()){
qtGuiTranslationPath
=
UBPlatformUtils
::
translationPath
(
"qt_"
,
language
.
left
(
2
));
if
(
!
QFile
(
qtGuiTranslationPath
).
exists
())
qtGuiTranslationPath
=
""
;
}
if
(
!
qtGuiTranslationPath
.
isEmpty
()){
qDebug
()
<<
"qtGuiTranslationPath "
<<
qtGuiTranslationPath
;
mQtGuiTranslator
->
load
(
qtGuiTranslationPath
);
installTranslator
(
mQtGuiTranslator
);
}
else
qDebug
()
<<
"Qt gui translation in "
<<
language
<<
" is not available"
;
}
QLocale
::
setDefault
(
QLocale
(
language
));
qDebug
()
<<
"Running application in:"
<<
language
;
...
...
src/core/UBApplication.h
View file @
a07b09ec
...
...
@@ -119,10 +119,10 @@ class UBApplication : public QtSingleApplication
private
:
void
updateProtoActionsState
();
void
setupTranslator
(
QString
forcedLanguage
);
void
setupTranslator
s
(
QStringList
args
);
QList
<
QMenu
*>
mProtoMenus
;
bool
mIsVerbose
;
QString
checkLanguageAvailabilityForSankore
(
QString
&
language
);
protected
:
#if defined(Q_WS_MACX) && !defined(QT_MAC_USE_COCOA)
...
...
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