PDA

View Full Version : Discovery correct Language on all OS



patrik08
23rd February 2007, 08:20
I observe on Window XP MUI .... Multilanguage

QLocale::languageToString( QLocale::system().language())

stay evrytime = C ... !!!

I dont say if a bug or no....

I can only discover language on this way....



QSettings setter;
QString languser,languagesistem,langqt;
languser = getenv("LANG");
languser = languser.toLower();
languagesistem = QLocale::languageToString( QLocale::system().language());
languagesistem = languagesistem.toLower();
/* Window XP Prof MUI Multiuser == stay only "c" language && user setting setenv !!! */
if (languagesistem == "c") {
if (languser.size() > 2 && languser.contains("_")) {
languagesistem = languser.left(2);
}
}
setter.setValue("userlanguage",languagesistem);
qDebug() << "### save to qsetting " << languagesistem;
qDebug() << "### QT grep language " << QLocale::languageToString( QLocale::system().language());
qDebug() << "### User setenv " << getenv("LANG");




if this running on other system ? waht you think?....

jacek
23rd February 2007, 11:35
QLocale::languageToString( QLocale::system().language())
stay evrytime = C ... !!!
It says "Polish" on my system. Do you create QApplication or QCoreApplication before accessing QLocale?

patrik08
23rd February 2007, 11:57
It says "Polish" on my system. Do you create QApplication or QCoreApplication before accessing QLocale?

Sure.....

on linux running return it corect ....... on my window return c...
if i set Lang IT_CH envoirment coming corect.....
Only http://www.nextag.com/Microsoft-Windows-XP-Pro-509812402/prices-html
Microsoft Windows XP Pro SP2B English 1 PK W/MULTIPLE MUI.

return c each user can set other language .......




#include <QFile>

#include <QApplication>

#include <QtGui>

#include <QtCore>

#include <QTextCodec>

#include <QCoreApplication>

#include <QApplication>

#include <QtGui>

#include "main.h"

#include "edit_html.h"

#include "base_modul.h"





static inline QString UserLanguage()

{

/////////////QSettings setter;

QString languser,languagesistem,langqt;

QLocale loci = QLocale::system();


languser = getenv("LANG");

languser = languser.toLower();

languagesistem = loci.name();

languagesistem = languagesistem.toLower();
languagesistem = languagesistem.left(2);

/* Window XP Prof MUI Multiuser == stay only "c" language && user setting setenv !!! */

if (languagesistem == "c") {

if (languser.size() > 2 && languser.contains("_")) {

languagesistem = languser.left(2);

}

}

////////////setter.setValue("userlanguage",languagesistem);

///////////qDebug() << "### save to qsetting " << languagesistem;

///////// qDebug() << "### QT grep language " << QLocale::languageToString( QLocale::system().language());

/////////qDebug() << "### User setenv " << getenv("LANG");

return languagesistem;

}





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

QApplication a( argc, argv );


qDebug() << "### arg1 " << argv[1];



QCoreApplication::setOrganizationName(_ORGANIZATIO N_NAME_);

QCoreApplication::setOrganizationDomain(_PROGRAM_N AME_DOMAINE_);

QCoreApplication::setApplicationName(_PROGRAM_NAME _);





QString localedirfile = QString("%1/locale/edit_%2.qm").arg(QDir::currentPath()).arg(UserLanguage());

qDebug() << "#### localedirfile ->" << localedirfile;

QTranslator translator;

translator.load(localedirfile);

a.installTranslator(&translator);





Edit_html w;

w.setWindowTitle( _PROGRAM_TITLE_ );

w.set_Cache(IMM_BUILD);

if ( argc >= 1 ) {
w.SetFileBase( argv[1] );

} else {

w.SetFileBase("index.html");

}

w.show();



a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );

return a.exec();

}





Note to forum admin:
if i paste on window on code tag line break correct .....
on linux firefox 2. linux ubuntu each break line comming \n\n
now is paste from linux.....

jacek
23rd February 2007, 12:43
on linux running return it corect ....... on my window return c...
As I said, it works on my copy of windows. Maybe your system is configured in such way that it doesn't inform Qt about the current user's locale?



on linux firefox 2. linux ubuntu each break line comming \n\n
Where are you pasting it from?

patrik08
23rd February 2007, 16:11
. Maybe your system is configured in such way that it doesn't inform Qt about the current user's locale?
?

I set my own setenv LANG -> IT_ch



Where are you pasting it from?
Scite text editor.... gedit same result...... maybe svn??? all my file are committet from mac or win or ubuntu....

jacek
25th February 2007, 19:27
I set my own setenv LANG -> IT_ch
Does windows know that it should take LANG variable into consideration?


Scite text editor.... gedit same result...... maybe svn??? all my file are committet from mac or win or ubuntu....
Maybe the problem is that lines end with \r\n? What about pasting other text files? How do the other sites behave?