[Interest] Locale detection of Qt application hosted via WASM

Nicholas Yue yue.nicholas at gmail.com
Wed Apr 28 18:41:01 CEST 2021


Hi,

I have the following code (part of a small project) which is being built
both as a standalone executable and a wasm web application.

They both work except the locale determination.

On my Linux console, I can set the LANGUAGE environment to de and the
executable will load the correct labels

However, when I run it wasm web app and connect to it via a German language
OS web browser, it keeps thinking that the locale is still "C" and not
"de_DE"

I am new to locale handling in general and definitely new to locale on the
web browser.

I am developing with Qt 5.14.0

Code ===================
#include <QApplication>
#include <QPushButton>
#include <QTranslator>
#include <QLocale>
#include <iostream>
#include "CMEForm.h"

int main(int argc, char *argv[]) {

QApplication app(argc, argv);
    QTranslator translator;


std::cout << "Locale is " << QLocale::system().name().toStdString() <<
std::endl;
if (QLocale::system().name().startsWith("de_")) {
if (translator.load(":/language/.qm/cme_de.qm")) {
app.installTranslator(&translator);
} else {
std::cerr << "ERROR: Translation failure to load" << std::endl;
}
}

CMEForm cme;
cme.show();

    return app.exec();

}

-- 
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210428/70df697b/attachment.html>


More information about the Interest mailing list