VirtualBox

Changeset 91312 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Sep 20, 2021 11:06:57 AM (3 years ago)
Author:
vboxsync
Message:

Main: bugref:1909: Prepared the API translation engine to using in ExtPacks and VBoxManage. Added using API translation engine in ExtPacks. Allowed VBox compilation with NLS enabled and GUI disabled. Allowed ExtPacks only compilation with NLS translation enabled.

Location:
trunk/src/VBox/Main/include
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r90828 r91312  
    102102    do { \
    103103        if (!!(drv)) {} \
    104         else return setError(E_ACCESSDENIED, tr("The console is not powered up (%Rfn)"), __FUNCTION__); \
     104        else return setError(E_ACCESSDENIED, Console::tr("The console is not powered up (%Rfn)"), __FUNCTION__); \
    105105    } while (0)
    106106
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r90828 r91312  
    6161
    6262/* Member of Console. Helper class for VRDP server management. Not a COM class. */
    63 class ConsoleVRDPServer : public VirtualBoxTranslatable
     63class ConsoleVRDPServer
    6464{
    6565public:
  • trunk/src/VBox/Main/include/DHCPConfigImpl.h

    r90828 r91312  
    4141 * can call setError and such on.
    4242 */
    43 class DHCPConfig : public VirtualBoxTranslatable
     43class DHCPConfig
    4444{
    4545protected:
  • trunk/src/VBox/Main/include/ExtPackManagerImpl.h

    r90828 r91312  
    182182                                                       /* VBoxEventType_T */ uint32_t aType,
    183183                                                       VBOXEXTPACK_IF_CS(IVetoEvent) **ppEventOut);
    184     static DECLCALLBACK(int)    i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
     184    static DECLCALLBACK(const char *) i_hlpTranslate(PCVBOXEXTPACKHLP pHlp,
     185                                                     const char *pszComponent,
     186                                                     const char *pszSourceText,
     187                                                     const char *pszComment = NULL,
     188                                                     const int   iNum = -1);
     189    static DECLCALLBACK(int)      i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
    185190    /** @}  */
    186191
  • trunk/src/VBox/Main/include/GuestDnDPrivate.h

    r90828 r91312  
    800800 * Class for keeping a DnD guest state around.
    801801 */
    802 class GuestDnDState : public VirtualBoxTranslatable
     802class GuestDnDState
    803803{
    804804
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r90828 r91312  
    214214 * information extraction and maintaining the overall status.
    215215 */
    216 class GuestProcessTool : public VirtualBoxTranslatable
     216class GuestProcessTool
    217217{
    218218public:
  • trunk/src/VBox/Main/include/GuestSessionImplTasks.h

    r90828 r91312  
    156156class GuestSessionTask
    157157    : public ThreadTask
    158     , public VirtualBoxTranslatable
    159158{
    160159public:
  • trunk/src/VBox/Main/include/MachineImplCloneVM.h

    r90828 r91312  
    2828struct MachineCloneVMPrivate;
    2929
    30 class MachineCloneVM : public VirtualBoxTranslatable
     30class MachineCloneVM
    3131{
    3232public:
  • trunk/src/VBox/Main/include/MachineImplMoveVM.h

    r90828 r91312  
    6464struct fileList_t;
    6565
    66 class MachineMoveVM : public ThreadTask, public VirtualBoxTranslatable
     66class MachineMoveVM : public ThreadTask
    6767{
    6868    std::vector<ComObjPtr<Machine> >        machineList;
  • trunk/src/VBox/Main/include/TextScript.h

    r90828 r91312  
    3434class AbstractScript
    3535    : public RTCNonCopyable
    36     , public VirtualBoxTranslatable
    3736{
    3837protected:
  • trunk/src/VBox/Main/include/USBProxyService.h

    r90828 r91312  
    4343 */
    4444class USBProxyService
    45     : public VirtualBoxTranslatable
    46     , public Lockable
     45    : public Lockable
    4746{
    4847public:
  • trunk/src/VBox/Main/include/UnattendedInstaller.h

    r90828 r91312  
    3636 * execute an unattended installation
    3737 */
    38 class UnattendedInstaller : public RTCNonCopyable, public VirtualBoxTranslatable
     38class UnattendedInstaller : public RTCNonCopyable
    3939{
    4040/*data*/
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r90841 r91312  
    364364        { /* likely */ }\
    365365        else \
    366             return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \
     366            return setError(E_INVALIDARG, VirtualBoxBase::tr("Argument %s is NULL"), #arg); \
    367367    } while (0)
    368368
     
    377377        { /* likely */ }\
    378378        else \
    379             return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #arg); \
     379            return setError(E_INVALIDARG, \
     380                            VirtualBoxBase::tr("Argument %s is an invalid pointer"), #arg); \
    380381    } while (0)
    381382
     
    391392        else \
    392393            return setError(E_POINTER, \
    393                 tr("Argument %s points to invalid memory location (%p)"), \
     394                VirtualBoxBase::tr("Argument %s points to invalid memory location (%p)"), \
    394395                #arg, (void *)(arg)); \
    395396    } while (0)
     
    405406        { /* likely */ }\
    406407        else \
    407             return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \
     408            return setError(E_INVALIDARG, \
     409                            VirtualBoxBase::tr("Argument %s is NULL"), #arg); \
    408410    } while (0)
    409411
     
    419421        { /* likely */ }\
    420422        else \
    421             return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #a_bstrIn); \
     423            return setError(E_INVALIDARG, \
     424                            VirtualBoxBase::tr("Argument %s is an invalid pointer"), #a_bstrIn); \
    422425    } while (0)
    423426/**
     
    432435        { /* likely */ }\
    433436        else \
    434             return setError(E_INVALIDARG, tr("Argument %s is empty or an invalid pointer"), #a_bstrIn); \
     437            return setError(E_INVALIDARG, \
     438                            VirtualBoxBase::tr("Argument %s is empty or an invalid pointer"), \
     439                            #a_bstrIn); \
    435440    } while (0)
    436441
     
    450455        else \
    451456            return setError(E_INVALIDARG, \
    452                 tr("GUID argument %s is not valid (\"%ls\")"), #a_Arg, Bstr(a_Arg).raw()); \
     457                            VirtualBoxBase::tr("GUID argument %s is not valid (\"%ls\")"), \
     458                            #a_Arg, Bstr(a_Arg).raw()); \
    453459    } while (0)
    454460
     
    465471        else \
    466472            return setError(E_INVALIDARG, \
    467                 tr("Argument %s is invalid (must be %s)"), #arg, #expr); \
     473                            VirtualBoxBase::tr("Argument %s is invalid (must be %s)"), \
     474                            #arg, #expr); \
    468475    } while (0)
    469476
     
    482489        { /* likely */ }\
    483490        else \
    484             return setError(E_INVALIDARG, tr("Argument %s %s"), \
     491            return setError(E_INVALIDARG, VirtualBoxBase::tr("Argument %s %s"), \
    485492                            #arg, Utf8StrFmt msg .c_str()); \
    486493    } while (0)
     
    497504        else \
    498505            return setError(E_POINTER, \
    499                 tr("Output argument %s points to invalid memory location (%p)"), \
    500                 #arg, (void *)(arg)); \
     506                            VirtualBoxBase::tr("Output argument %s points to invalid memory location (%p)"), \
     507                            #arg, (void *)(arg)); \
    501508    } while (0)
    502509
     
    512519        else \
    513520            return setError(E_POINTER, \
    514                             tr("Output argument %s points to invalid memory location (%p)"), \
     521                            VirtualBoxBase::tr("Output argument %s points to invalid memory location (%p)"), \
    515522                            #arg, (void*)(arg)); \
    516523    } while (0)
     
    521528#define ReturnComNotImplemented() \
    522529    do { \
    523         return setError(E_NOTIMPL, tr("Method %s is not implemented"), __FUNCTION__); \
     530        return setError(E_NOTIMPL, VirtualBoxBase::tr("Method %s is not implemented"), __FUNCTION__); \
    524531    } while (0)
    525532
     
    562569#endif
    563570
    564 /**
    565  * Parent class of VirtualBoxBase which enables translation support (which
    566  * Main doesn't have yet, but this provides the tr() function which will one
    567  * day provide translations).
    568  *
    569  * This class sits in between Lockable and VirtualBoxBase only for the one
    570  * reason that the USBProxyService wants translation support but is not
    571  * implemented as a COM object, which VirtualBoxBase implies.
    572  */
    573 class ATL_NO_VTABLE VirtualBoxTranslatable
    574 {
    575 public:
    576     /**
    577      * Returns translated text.
    578      *
    579      * @param aComponent    Translation context e.g. class name
    580      * @param aSourceText   String to translate.
    581      * @param aComment      Comment to the string to resolve possible ambiguities
    582      *                      (NULL means no comment). Used by translation tool only.
    583      * @param aNum          Number used to define plural form of the translation.
    584      *
    585      * @return Translated text.
    586      */
    587     static const char *translate(const char *aComponent,
    588                                  const char *aSourceText,
    589                                  const char *aComment = NULL,
    590                                  const int   aNum = -1)
    591     {
    592 #ifdef VBOX_WITH_MAIN_NLS
    593         return VirtualBoxTranslator::translate(aComponent, aSourceText, aComment, aNum);
    594 #else
    595         RT_NOREF(aComponent, aComment, aNum);
    596         return aSourceText;
    597 #endif
    598     }
    599 
    600     /**
    601      * Returns source text stored in the cache if exists.
    602      * Otherwise, the @a aTranslation itself returned.
    603      */
    604     static const char *trSource(const char *aTranslation)
    605     {
    606 #ifdef VBOX_WITH_MAIN_NLS
    607         return VirtualBoxTranslator::trSource(aTranslation);
    608 #else
    609         return aTranslation;
    610 #endif
    611     }
    612 };
    613 
    614571////////////////////////////////////////////////////////////////////////////////
    615572//
     
    624581                                 const int   aNum = -1) \
    625582    { \
    626         return VirtualBoxTranslatable::translate(#cls, aSourceText, aComment, aNum); \
     583        return VirtualBoxTranslator::translate(NULL, #cls, aSourceText, aComment, aNum); \
    627584    }
    628585#else
     
    718675 */
    719676class ATL_NO_VTABLE VirtualBoxBase
    720     : public VirtualBoxTranslatable
    721     , public Lockable
     677    : public Lockable
    722678    , public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>
    723679#if !defined (VBOX_WITH_XPCOM)
     
    873829 * Dummy macro that is used to shut down Qt's lupdate tool warnings in some
    874830 * situations. This macro needs to be present inside (better at the very
    875  * beginning) of the declaration of the class that inherits from
    876  * VirtualBoxTranslatable, to make lupdate happy.
     831 * beginning) of the declaration of the class that uses translation, to make
     832 * lupdate happy.
    877833 */
    878834#define Q_OBJECT
  • trunk/src/VBox/Main/include/VirtualBoxClientImpl.h

    r90879 r91312  
    106106#ifdef VBOX_WITH_MAIN_NLS
    107107        VirtualBoxTranslator *m_pVBoxTranslator;
     108        TRCOMPONENT           m_pTrComponent;
    108109#endif
    109110    };
  • trunk/src/VBox/Main/include/VirtualBoxErrorInfoImpl.h

    r90828 r91312  
    3131#ifndef VBOX_WITH_XPCOM /* IErrorInfo doesn't inherit from IDispatch, ugly 3am hack: */
    3232    , public IDispatch
    33     , public VirtualBoxTranslatable
    3433#endif
    3534{
  • trunk/src/VBox/Main/include/VirtualBoxTranslator.h

    r90881 r91312  
    2727#include <VBox/com/AutoLock.h>
    2828
     29typedef void *TRCOMPONENT;
    2930
    3031class QMTranslator;
     
    4647
    4748    /**
     49     * Adds path containing translation files into list of known paths.
     50     * Path should include translation file prefix.
     51     *
     52     * @returns VBox status code
     53     * @param aTranslationPath   Path to translation files including file prefix
     54     * @param aDefault           Use as default translation component, i.e.
     55     *                           Use this path for translation if component
     56     *                           is NULL
     57     * @param aComponent         Where is the pointer to component returned
     58     */
     59    static int registerTranslation(const char *aTranslationPath,
     60                                   bool aDefault,
     61                                   TRCOMPONENT *aComponent);
     62
     63    /**
     64     * Removes the path from list of known paths.
     65     * Does not remove already loaded translation from string cache.
     66     */
     67    static int unregisterTranslation(TRCOMPONENT aComponent);
     68
     69    /**
    4870     * Translates @a aSourceText to user language.
     71     * Uses component marked as default if @a aTranslationComponent is NULL
    4972     *
    50      * @returns Translated string or @a aSourceText.  The returned string is
    51      *          valid only during lifetime of the this translator instance.
     73     * @returns Translated string or @a aSourceText. The returned string is
     74     *          valid only during lifetime of the translator instance.
    5275     */
    53     static const char *translate(const char *aContext,
     76    static const char *translate(TRCOMPONENT aComponent,
     77                                 const char *aContext,
    5478                                 const char *aSourceText,
    5579                                 const char *aComment = NULL,
     
    6488    /* Convenience function used by VirtualBox::init */
    6589    int i_loadLanguage(const char *pszLang);
    66     int i_setLanguageFile(const char *aFileName);
    67     com::Utf8Str i_languageFile();
    68 
    6990
    7091    static int32_t initCritSect();
     
    7697    uint32_t m_cInstanceRefs;
    7798
    78     com::Utf8Str  m_strLangFileName;
    79     QMTranslator *m_pTranslator;
     99    struct TranslatorComponent
     100    {
     101        QMTranslator *pTranslator;
     102        /* Path to translation files. It includes file prefix, i.e
     103         * /path/to/folder/file_prefix */
     104        com::Utf8Str  strPath;
     105
     106        TranslatorComponent() : pTranslator(NULL) {}
     107    };
     108    typedef std::list<TranslatorComponent> TranslatorList;
     109    TranslatorList  m_lTranslators;
     110    TranslatorComponent *m_pDefaultComponent;
     111
     112    /* keep the language code for registration */
     113    com::Utf8Str m_strLanguage;
     114
    80115    /** String cache that all translation strings are stored in.
    81116     * This is a add-only cache, which allows translate() to return C-strings w/o
     
    87122    VirtualBoxTranslator();
    88123
    89     const char *i_translate(const char *aContext,
     124    int i_loadLanguageForComponent(TranslatorComponent *aComponent, const char *aLang);
     125
     126    int i_setLanguageFile(TranslatorComponent *aComponent, const char *aFileName);
     127
     128    int i_registerTranslation(const char *aTranslationPath,
     129                              bool aDefault,
     130                              TRCOMPONENT *aComponent);
     131
     132    int i_unregisterTranslation(TRCOMPONENT aComponent);
     133
     134    const char *i_translate(TRCOMPONENT aComponent,
     135                            const char *aContext,
    90136                            const char *aSourceText,
    91137                            const char *aComment = NULL,
    92138                            const int   aNum = -1);
    93 
    94139};
    95140
  • trunk/src/VBox/Main/include/Wrapper.h

    r82968 r91312  
    4040        else \
    4141            throw setError(E_POINTER, \
    42                 tr("Output argument %s points to invalid memory location (%p)"), \
     42                /* Had to define VirtualBoxBase as context switcher for translation. \
     43                 * Otherwise, lupdate complains about unknown context and doesn't \
     44                 * include the string into translation file */ \
     45                VirtualBoxBase::tr("Output argument %s points to invalid memory location (%p)"), \
    4346                #arg, (void *)(arg)); \
    4447    } while (0)
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