VirtualBox

Changeset 2178 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Apr 18, 2007 1:50:16 PM (18 years ago)
Author:
vboxsync
Message:

FE/Qt: Added Qt translation sources from the Qt distribution; created untranslated sources for existing languages; added code to load Qt translations on language change.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
13 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile

    r1733 r2178  
    5151VirtualBox_SDKS.win = WINPSDK DXSDK
    5252VirtualBox_SDKS.linux = LIBSDL
     53
     54# Each nls/VirtualBox_xx_YY.ts file must have a qt_xx_YY.ts counterpart
     55VirtualBox_QT_TRANSLATIONS_QT := \
     56        $(patsubst nls/VirtualBox_%.ts,nls/qt_%.ts,\
     57                $(filter nls/VirtualBox_%.ts,$(VirtualBox_QT_TRANSLATIONS)))
    5358
    5459# QDesigner UI sources are imported from VBoxUI.pro as VirtualBox_QT_UISRC
     
    247252
    248253VirtualBox.nls_INST = $(INST_BIN)nls/
    249 VirtualBox.nls_SOURCES = $(patsubst %.ts,$(PATH_VirtualBox)/nls/%.qm,$(notdir $(VirtualBox_QT_TRANSLATIONS)))
     254VirtualBox.nls_SOURCES =  $(patsubst %.ts,$(PATH_VirtualBox)/nls/%.qm,$(notdir $(VirtualBox_QT_TRANSLATIONS)))
     255VirtualBox.nls_SOURCES += $(patsubst %.ts,$(PATH_VirtualBox)/nls/%.qm,$(notdir $(VirtualBox_QT_TRANSLATIONS_QT)))
    250256VirtualBox.nls_MODE = 644
    251257
     
    378384# NLS files
    379385$(foreach tsfile,$($(target)_QT_TRANSLATIONS),$(eval $(def_qt_gen_nls)))
     386$(foreach tsfile,$($(target)_QT_TRANSLATIONS_QT),$(eval $(def_qt_gen_nls)))
    380387# dirs
    381388$$(call DIRDEP,$(PATH_$(target))/ui/) \
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r2170 r2178  
    19121912    QString selectedLangId = gVBoxBuiltInLangName;
    19131913
     1914    QString nlsPath = qApp->applicationDirPath() + gVBoxLangSubDir;
     1915    QDir nlsDir (nlsPath);
     1916
    19141917    Assert (!langId.isEmpty());
    19151918    if (!langId.isEmpty() && langId != gVBoxBuiltInLangName)
     
    19221925        QString lang = regExp.cap (2);
    19231926
    1924         QString nlsPath = qApp->applicationDirPath() + gVBoxLangSubDir;
    1925         QDir nlsDir (nlsPath);
    19261927        if (nlsDir.exists (gVBoxLangFileBase + langId + gVBoxLangFileExt))
    19271928        {
     
    19781979        vboxProblem().cannotLoadLanguage (languageFileName);
    19791980        sLoadedLangId = gVBoxBuiltInLangName;
     1981    }
     1982
     1983    /* Try to load the corresponding Qt translation */
     1984    QTranslator *qtTr = new QTranslator (sTranslator);
     1985    Assert (qtTr);
     1986    if (sLoadedLangId != gVBoxBuiltInLangName)
     1987    {
     1988#ifdef Q_OS_UNIX
     1989        /* We use system installations of Qt on Linux systems, so first, try
     1990         * to load the Qt translation from the system location. */
     1991        languageFileName = QString (qInstallPathTranslations()) + "/qt_" +
     1992                           sLoadedLangId + gVBoxLangFileExt;
     1993        loadOk = qtTr->load (languageFileName);
     1994        if (!loadOk)
     1995#endif
     1996        {
     1997            languageFileName =  nlsDir.absFilePath (QString ("qt_") +
     1998                                                    sLoadedLangId +
     1999                                                    gVBoxLangFileExt);
     2000            loadOk = qtTr->load (languageFileName);
     2001        }
     2002        qApp->installTranslator (qtTr);
     2003        /* The below message doesn't fit 100% (because it's an additonal
     2004         * language and the main one won't be reset to built-in on failure)
     2005         * but the load failure is so rare here that it's not worth a separate
     2006         * message (but still, having something is better than having none) */
     2007        if (!loadOk && !aLangId.isNull())
     2008            vboxProblem().cannotLoadLanguage (languageFileName);
    19802009    }
    19812010}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette