Results 1 to 6 of 6

Thread: Discovery correct Language on all OS

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Discovery correct Language on all OS

    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....

    Qt Code:
    1. QSettings setter;
    2. QString languser,languagesistem,langqt;
    3. languser = getenv("LANG");
    4. languser = languser.toLower();
    5. languagesistem = QLocale::languageToString( QLocale::system().language());
    6. languagesistem = languagesistem.toLower();
    7. /* Window XP Prof MUI Multiuser == stay only "c" language && user setting setenv !!! */
    8. if (languagesistem == "c") {
    9. if (languser.size() > 2 && languser.contains("_")) {
    10. languagesistem = languser.left(2);
    11. }
    12. }
    13. setter.setValue("userlanguage",languagesistem);
    14. qDebug() << "### save to qsetting " << languagesistem;
    15. qDebug() << "### QT grep language " << QLocale::languageToString( QLocale::system().language());
    16. qDebug() << "### User setenv " << getenv("LANG");
    To copy to clipboard, switch view to plain text mode 


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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Discovery correct Language on all OS

    Quote Originally Posted by patrik08 View Post
    QLocale::languageToString( QLocale::system().language())
    stay evrytime = C ... !!!
    It says "Polish" on my system. Do you create QApplication or QCoreApplication before accessing QLocale?

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Discovery correct Language on all OS

    Quote Originally Posted by jacek View Post
    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-Wind...02/prices-html
    Microsoft Windows XP Pro SP2B English 1 PK W/MULTIPLE MUI.

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


    Qt Code:
    1. #include <QFile>
    2.  
    3. #include <QApplication>
    4.  
    5. #include <QtGui>
    6.  
    7. #include <QtCore>
    8.  
    9. #include <QTextCodec>
    10.  
    11. #include <QCoreApplication>
    12.  
    13. #include <QApplication>
    14.  
    15. #include <QtGui>
    16.  
    17. #include "main.h"
    18.  
    19. #include "edit_html.h"
    20.  
    21. #include "base_modul.h"
    22.  
    23.  
    24.  
    25.  
    26.  
    27. static inline QString UserLanguage()
    28.  
    29. {
    30.  
    31. /////////////QSettings setter;
    32.  
    33. QString languser,languagesistem,langqt;
    34.  
    35. QLocale loci = QLocale::system();
    36.  
    37.  
    38. languser = getenv("LANG");
    39.  
    40. languser = languser.toLower();
    41.  
    42. languagesistem = loci.name();
    43.  
    44. languagesistem = languagesistem.toLower();
    45. languagesistem = languagesistem.left(2);
    46.  
    47. /* Window XP Prof MUI Multiuser == stay only "c" language && user setting setenv !!! */
    48.  
    49. if (languagesistem == "c") {
    50.  
    51. if (languser.size() > 2 && languser.contains("_")) {
    52.  
    53. languagesistem = languser.left(2);
    54.  
    55. }
    56.  
    57. }
    58.  
    59. ////////////setter.setValue("userlanguage",languagesistem);
    60.  
    61. ///////////qDebug() << "### save to qsetting " << languagesistem;
    62.  
    63. ///////// qDebug() << "### QT grep language " << QLocale::languageToString( QLocale::system().language());
    64.  
    65. /////////qDebug() << "### User setenv " << getenv("LANG");
    66.  
    67. return languagesistem;
    68.  
    69. }
    70.  
    71.  
    72.  
    73.  
    74.  
    75. int main(int argc, char *argv[]) {
    76.  
    77. QApplication a( argc, argv );
    78.  
    79.  
    80. qDebug() << "### arg1 " << argv[1];
    81.  
    82.  
    83.  
    84. QCoreApplication::setOrganizationName(_ORGANIZATION_NAME_);
    85.  
    86. QCoreApplication::setOrganizationDomain(_PROGRAM_NAME_DOMAINE_);
    87.  
    88. QCoreApplication::setApplicationName(_PROGRAM_NAME_);
    89.  
    90.  
    91.  
    92.  
    93.  
    94. QString localedirfile = QString("%1/locale/edit_%2.qm").arg(QDir::currentPath()).arg(UserLanguage());
    95.  
    96. qDebug() << "#### localedirfile ->" << localedirfile;
    97.  
    98. QTranslator translator;
    99.  
    100. translator.load(localedirfile);
    101.  
    102. a.installTranslator(&translator);
    103.  
    104.  
    105.  
    106.  
    107.  
    108. Edit_html w;
    109.  
    110. w.setWindowTitle( _PROGRAM_TITLE_ );
    111.  
    112. w.set_Cache(IMM_BUILD);
    113.  
    114. if ( argc >= 1 ) {
    115. w.SetFileBase( argv[1] );
    116.  
    117. } else {
    118.  
    119. w.SetFileBase("index.html");
    120.  
    121. }
    122.  
    123. w.show();
    124.  
    125.  
    126.  
    127. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    128.  
    129. return a.exec();
    130.  
    131. }
    To copy to clipboard, switch view to plain text mode 


    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.....

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Discovery correct Language on all OS

    Quote Originally Posted by patrik08 View Post
    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?


    Quote Originally Posted by patrik08 View Post
    on linux firefox 2. linux ubuntu each break line comming \n\n
    Where are you pasting it from?

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Discovery correct Language on all OS

    Quote Originally Posted by jacek View Post
    . 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

    Quote Originally Posted by jacek View Post
    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....

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Discovery correct Language on all OS

    Quote Originally Posted by patrik08 View Post
    I set my own setenv LANG -> IT_ch
    Does windows know that it should take LANG variable into consideration?

    Quote Originally Posted by patrik08 View Post
    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?

Similar Threads

  1. how to integrate qt into kdevelop correct way
    By amit_pansuria in forum KDE Forum
    Replies: 1
    Last Post: 25th November 2006, 08:58
  2. QLineEdit - Float number not displayed correct
    By morty in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2006, 00:47
  3. How can I add any other language
    By ethos0714 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 22nd February 2006, 02:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.