Attempt to mimic Shotcut's locale handling

Related to #780
parent 56d54a5c
......@@ -39,6 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "projectclip.h"
#include "projectfolder.h"
#include "projectsubclip.h"
#include "lib/localeHandling.h"
#include "xml/xml.hpp"
#include <KLocalizedString>
......@@ -996,8 +997,8 @@ void ProjectItemModel::loadBinPlaylist(Mlt::Tractor *documentTractor, Mlt::Tract
pCore->loadingMessageUpdated(i18n("Loading project clips..."));
}
// Load bin clips
auto currentLocale = strdup(setlocale(LC_ALL, nullptr));
qDebug() << "Init bin; Current LC_ALL" << currentLocale;
auto currentLocale = strdup(setlocale(MLT_LC_CATEGORY, nullptr));
qDebug() << "Init bin; Current LC" << currentLocale;
// Load folders
Mlt::Properties folderProperties;
Mlt::Properties playlistProps(playlist.get_properties());
......
......@@ -21,12 +21,12 @@ auto LocaleHandling::setLocale(const QString &lcName) -> QString
localesToTest << lcName << lcName + ".utf-8" << lcName + ".UTF-8" << lcName + ".utf8" << lcName + ".UTF8";
for (const auto &locale : localesToTest) {
#ifdef Q_OS_FREEBSD
auto *result = setlocale(LC_NUMERIC, locale.toStdString().c_str());
auto *result = setlocale(MLT_LC_CATEGORY, locale.toStdString().c_str());
#else
auto *result = std::setlocale(LC_NUMERIC, locale.toStdString().c_str());
auto *result = std::setlocale(MLT_LC_CATEGORY, locale.toStdString().c_str());
#endif
if (result != nullptr) {
::qputenv("LC_NUMERIC", locale.toStdString().c_str());
::qputenv(MLT_LC_NAME, locale.toStdString().c_str());
newLocale = locale;
break;
}
......@@ -40,11 +40,11 @@ auto LocaleHandling::setLocale(const QString &lcName) -> QString
void LocaleHandling::resetLocale()
{
#ifdef Q_OS_FREEBSD
setlocale(LC_NUMERIC, "C");
setlocale(MLT_LC_CATEGORY, "C");
#else
std::setlocale(LC_NUMERIC, "C");
std::setlocale(MLT_LC_CATEGORY, "C");
#endif
::qputenv("LC_NUMERIC", "C");
::qputenv(MLT_LC_NAME, "C");
qDebug() << "LC_NUMERIC reset to C";
}
......
......@@ -13,6 +13,15 @@ the Free Software Foundation, either version 3 of the License, or
#include <QtCore/QLocale>
#include <QtCore/QString>
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
# define MLT_LC_CATEGORY LC_NUMERIC
# define MLT_LC_NAME "LC_NUMERIC"
#else
# define MLT_LC_CATEGORY LC_ALL
# define MLT_LC_NAME "LC_ALL"
#endif
class LocaleHandling
{
public:
......
......@@ -94,6 +94,7 @@ int main(int argc, char *argv[])
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true);
}
#endif
qputenv("LANG", QLocale().name().toUtf8());
QApplication app(argc, argv);
app.setApplicationName(QStringLiteral("kdenlive"));
app.setOrganizationDomain(QStringLiteral("kde.org"));
......
......@@ -89,9 +89,9 @@ MltConnection::MltConnection(const QString &mltPath)
LocaleHandling::resetLocale();
#ifdef Q_OS_FREEBSD
auto locale = strdup(setlocale(LC_ALL, nullptr));
auto locale = strdup(setlocale(MLT_LC_CATEGORY, nullptr));
#else
auto locale = strdup(std::setlocale(LC_ALL, nullptr));
auto locale = strdup(std::setlocale(MLT_LC_CATEGORY, nullptr));
#endif
qDebug() << "NEW LC_ALL" << locale;
......
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