1 |
// qsampler.cpp |
// qsampler.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2013, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
42 |
#define CONFIG_DATADIR CONFIG_PREFIX "/share" |
#define CONFIG_DATADIR CONFIG_PREFIX "/share" |
43 |
#endif |
#endif |
44 |
|
|
|
#if defined(LOCALEDIR) |
|
|
#define CONFIG_LOCALEDIR CONFIG_QUOTED(LOCALEDIR) |
|
|
#else |
|
|
#define CONFIG_LOCALEDIR CONFIG_DATADIR "/locale" |
|
|
#endif |
|
|
|
|
45 |
#if WIN32 |
#if WIN32 |
46 |
#define RELATIVE_LOCALE_DIR "/share/locale" |
#define RELATIVE_LOCALE_DIR "/share/locale" |
47 |
#elif defined(__APPLE__) |
#elif defined(__APPLE__) |
82 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
83 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
84 |
} else { |
} else { |
85 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
86 |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
87 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
88 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
89 |
} else { |
} else { |
90 |
#endif |
#endif |
91 |
delete m_pQtTranslator; |
delete m_pQtTranslator; |
92 |
m_pQtTranslator = 0; |
m_pQtTranslator = 0; |
93 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
94 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
95 |
loc.name().toUtf8().constData(), |
loc.name().toUtf8().constData(), |
96 |
sLocPath.toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
97 |
sLocName.toUtf8().constData()); |
sLocName.toUtf8().constData()); |
98 |
#endif |
#endif |
99 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
100 |
} |
} |
101 |
#endif |
#endif |
102 |
} |
} |
103 |
// Try own application translation... |
// Try own application translation... |
104 |
m_pMyTranslator = new QTranslator(this); |
m_pMyTranslator = new QTranslator(this); |
106 |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
107 |
QApplication::installTranslator(m_pMyTranslator); |
QApplication::installTranslator(m_pMyTranslator); |
108 |
} else { |
} else { |
109 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
110 |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
111 |
#else |
#else |
112 |
sLocPath = CONFIG_LOCALEDIR; |
sLocPath = CONFIG_DATADIR "/qsampler/translations"; |
113 |
#endif |
#endif |
114 |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
115 |
QApplication::installTranslator(m_pMyTranslator); |
QApplication::installTranslator(m_pMyTranslator); |
116 |
} else { |
} else { |
117 |
delete m_pMyTranslator; |
delete m_pMyTranslator; |
118 |
m_pMyTranslator = 0; |
m_pMyTranslator = 0; |
119 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
120 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
121 |
loc.name().toUtf8().constData(), |
loc.name().toUtf8().constData(), |
122 |
sLocPath.toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
123 |
sLocName.toUtf8().constData()); |
sLocName.toUtf8().constData()); |
124 |
#endif |
#endif |
125 |
} |
} |
126 |
} |
} |
127 |
} |
} |