[Interest] Locale detection of Qt application hosted via WASM

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


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

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() <<
if (QLocale::system().name().startsWith("de_")) {
if (translator.load(":/language/.qm/cme_de.qm")) {
} else {
std::cerr << "ERROR: Translation failure to load" << std::endl;

CMEForm cme;

    return app.exec();


Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
-------------- 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