Results 1 to 3 of 3

Thread: language translation

  1. #1
    Join Date
    Mar 2007
    Posts
    69
    Thanks
    14
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X

    Question language translation

    hi guys
    i m working on qt4.2 on Mac OS X Platform
    can anyone tell me how can convert my .app to another languages like japnese ,spanish,italino etc.

    thanks in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: language translation

    Hi

    Please, start with reading Internationalization with Qt.
    J-P Nurmi

  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: language translation

    Quote Originally Posted by jpn View Post
    Hi
    Please, start with reading Internationalization with Qt.

    Correct ... next if you have the language file tell main.cpp to find its...

    Qt Code:
    1. /* mac osx bundle path resolver */
    2. static inline QString UserLanguage()
    3. {
    4. QString languser,languagesistem,langqt;
    5. QLocale loci = QLocale::system();
    6. languser = getenv("LANG");
    7. languser = languser.toLower();
    8. languagesistem = loci.name();
    9. languagesistem = languagesistem.toLower();
    10. languagesistem = languagesistem.left(2);
    11. /* Window XP Prof MUI Multiuser Multilanguage == stay only "c" language && user setting setenv !!! */
    12. /* if not XP MUI BUG! return ... */
    13. if (languagesistem == "c") {
    14. if (languser.size() > 2 && languser.contains("_")) {
    15. languagesistem = languser.left(2); /* grep from LANG if QLocale having C*/
    16. }
    17. }
    18. return languagesistem;
    19. /* return de or en,it,fr .. first two from language*/
    20. }
    21.  
    22. int main(int argc, char *argv[]) {
    23. QApplication a( argc, argv );
    24.  
    25. /* qsetting */
    26. QCoreApplication::setOrganizationName(_ORGANIZATION_NAME_);
    27. QCoreApplication::setOrganizationDomain(_PROGRAM_NAME_DOMAINE_);
    28. QCoreApplication::setApplicationName(_PROGRAM_NAME_);
    29.  
    30. /* bundle mac paths */
    31. #if defined Q_WS_MAC
    32. path.append(QApplication::applicationDirPath());
    33. QDir dir(QApplication::applicationDirPath());
    34. dir.cdUp();
    35. path.append(dir.absolutePath());
    36. dir.cd("plugins");
    37. path.append(dir.absolutePath());
    38. dir.cdUp();
    39. path.append(dir.absolutePath());
    40. QApplication::setLibraryPaths(path);
    41. QDir::setCurrent(dir.absolutePath()); /* here down -> Frameworks locale plugin */
    42. #endif
    43.  
    44. #if defined Q_WS_MAC
    45. localedirfile = QString("%1/locale/edit_%2.qm").arg(QDir::currentPath()).arg(UserLanguage());
    46. #endif
    47. #if defined Q_WS_WIN
    48. localedirfile = QString("%1/locale/edit_%2.qm").arg(QCoreApplication::applicationDirPath()).arg(UserLanguage());
    49. #endif
    50. #if defined Q_WS_X11
    51. localedirfile = QString("%1/locale/edit_%2.qm").arg(WORK_CACHEDIR).arg(UserLanguage()); /* /home/user/.appname/ */
    52. #endif
    53.  
    54. QTranslator translator;
    55. translator.load(localedirfile);
    56. a.installTranslator(&translator);
    57.  
    58. /* next class main to start ....*/
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Discovery correct Language on all OS
    By patrik08 in forum Qt Programming
    Replies: 5
    Last Post: 25th February 2007, 19:27
  2. Translation without HTML
    By Marco812 in forum Qt Tools
    Replies: 4
    Last Post: 25th November 2006, 16:08
  3. Replies: 5
    Last Post: 22nd September 2006, 08:04
  4. 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
  5. Splitting Translation Files
    By Jimmy2775 in forum Qt Programming
    Replies: 9
    Last Post: 3rd February 2006, 19:23

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.