Changeset 92403 in vbox
- Timestamp:
- Nov 12, 2021 3:59:12 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148257
- Location:
- trunk/src/VBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk
r92384 r92403 124 124 $(PATH_ROOT)/src/VBox/Main/src-all/QMTranslatorImpl.cpp \ 125 125 $(PATH_ROOT)/src/VBox/Main/src-all/GlobalStatusConversion.cpp 126 endif 126 127 # define qt5 tools for translation 128 USES += qt5 129 130 VBOX_PATH_VBOXMANAGE_SRC := $(PATH_SUB_CURRENT) 131 include $(PATH_SUB_CURRENT)/nls/ApprovedLanguages.kmk 132 133 PROGRAMS += VBoxManageNls 134 VBoxManageNls_TEMPLATE = VBoxNLS 135 VBoxManageNls_QT_TRANSLATIONS = $(addsuffix .ts,$(addprefix $(VBOX_PATH_VBOXMANAGE_SRC)/nls/VBoxManageNls_,$(VBOX_APPROVED_VBOXMANAGE_LANGUAGES))) 136 VBoxManageNls_VBOX_ALL_NLS_SOURCES = $(wildcard \ 137 $(VBOX_PATH_VBOXMANAGE_SRC)/*.h\ 138 $(VBOX_PATH_VBOXMANAGE_SRC)/*.cpp ) 139 140 updatenls:: makeallnls $(VBOX_PATH_VBOXMANAGE_SRC)/nls/VBoxManageNls_en.ts 141 142 makeallnls:: $(VBoxManageNls_VBOX_ALL_NLS_SOURCES) 143 $(call MSG_L1,lupdate all languages (nls/*.ts)) 144 $(QUIET)$(TOOL_QT5_LUPDATE) \ 145 $^ \ 146 -ts \ 147 $(filter-out nls/VBoxManageNls_en.ts, $(VBoxManageNls_QT_TRANSLATIONS)) \ 148 $(VBOX_PATH_VBOXMANAGE_SRC)/nls/VBoxManageNls_xx_YY.ts 149 150 # fake-main-nls: 151 # $(foreach file, $(VBoxManageNls_QT_TRANSLATIONS) \ 152 # ,$(NLTAB)$(SED) -i \ 153 # -e '/<source>.*<\/source>/h' \ 154 # -e '/<source>.*<\/source>/p' \ 155 # -e '/<translation type="unfinished"><\/translation>/{' \ 156 # -e 'x' \ 157 # -e 's/<source>\(.*\)<\/source>/<translation type="unfinished">$(notdir $(file)): \1<\/translation>/' \ 158 # -e '}' \ 159 # $(file) ) 160 161 162 # Create the English translation file. This is something special cause it will 163 # contain the plural forms only. 164 $(VBOX_PATH_VBOXMANAGE_SRC)/nls/VBoxManageNls_en.ts: $(VBoxManageNls_VBOX_ALL_NLS_SOURCES) 165 $(call MSG_L1,lupdate $@) 166 $(QUIET)$(TOOL_QT5_LUPDATE) \ 167 $^ \ 168 -ts \ 169 "$@" 170 $(QUIET)$(SED) -n -i \ 171 -e '/<context>/,/<\/context>/!p' \ 172 -e '/<context>/h' \ 173 -e '/<name>/H' \ 174 -e '/<message numerus="yes">/,/<\/message>/H' \ 175 -e '/<\/context>/{H;x;/<message/p}' \ 176 "$@" 177 178 endif # VBOX_WITH_VBOXMANAGE_NLS 127 179 128 180 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r92375 r92403 32 32 #endif /* !VBOX_ONLY_DOCS */ 33 33 34 #ifdef VBOX_WITH_VBOXMANAGE_NLS 35 # include <VBox/com/AutoLock.h> 36 # include <VBox/com/listeners.h> 37 #endif 38 34 39 #include <VBox/version.h> 35 40 … … 40 45 #include <iprt/getopt.h> 41 46 #include <iprt/initterm.h> 47 #include <iprt/log.h> 42 48 #include <iprt/path.h> 43 49 #include <iprt/stream.h> … … 85 91 DECLARE_TRANSLATION_CONTEXT(VBoxManage); 86 92 93 #ifdef VBOX_WITH_VBOXMANAGE_NLS 94 /* listener class for language updates */ 95 class VBoxEventListener 96 { 97 public: 98 VBoxEventListener() 99 {} 100 101 102 HRESULT init(void *) 103 { 104 return S_OK; 105 } 106 107 HRESULT init() 108 { 109 return S_OK; 110 } 111 112 void uninit() 113 { 114 } 115 116 virtual ~VBoxEventListener() 117 { 118 } 119 120 STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent) 121 { 122 switch(aType) 123 { 124 case VBoxEventType_OnLanguageChanged: 125 { 126 /* 127 * Proceed with uttmost care as we might be racing com::Shutdown() 128 * and have the ground open up beneath us. 129 */ 130 LogFunc(("VBoxEventType_OnLanguageChanged\n")); 131 VirtualBoxTranslator *pTranslator = VirtualBoxTranslator::tryInstance(); 132 if (pTranslator) 133 { 134 ComPtr<ILanguageChangedEvent> pEvent = aEvent; 135 Assert(pEvent); 136 137 /* This call may fail if we're racing COM shutdown. */ 138 com::Bstr bstrLanguageId; 139 HRESULT hrc = pEvent->COMGETTER(LanguageId)(bstrLanguageId.asOutParam()); 140 if (SUCCEEDED(hrc)) 141 { 142 try 143 { 144 com::Utf8Str strLanguageId(bstrLanguageId); 145 LogFunc(("New language ID: %s\n", strLanguageId.c_str())); 146 pTranslator->i_loadLanguage(strLanguageId.c_str()); 147 } 148 catch (std::bad_alloc &) 149 { 150 LogFunc(("Caught bad_alloc")); 151 } 152 } 153 else 154 LogFunc(("Failed to get new language ID: %Rhrc\n", hrc)); 155 156 pTranslator->release(); 157 } 158 break; 159 } 160 161 default: 162 AssertFailed(); 163 } 164 165 return S_OK; 166 } 167 }; 168 169 typedef ListenerImpl<VBoxEventListener> VBoxEventListenerImpl; 170 171 VBOX_LISTENER_DECLARE(VBoxEventListenerImpl) 172 #endif /* !VBOX_WITH_VBOXMANAGE_NLS */ 87 173 88 174 /********************************************************************************************************************************* … … 444 530 #endif 445 531 532 #ifdef VBOX_WITH_VBOXMANAGE_NLS 533 ComPtr<IEventListener> pEventListener; 534 PTRCOMPONENT pTrComponent = NULL; 535 util::InitAutoLockSystem(); 536 VirtualBoxTranslator *pTranslator = VirtualBoxTranslator::instance(); 537 if (pTranslator != NULL) 538 { 539 char szNlsPath[RTPATH_MAX]; 540 vrc = RTPathAppPrivateNoArch(szNlsPath, sizeof(szNlsPath)); 541 if (RT_SUCCESS(vrc)) 542 vrc = RTPathAppend(szNlsPath, sizeof(szNlsPath), "nls" RTPATH_SLASH_STR "VBoxManageNls"); 543 544 if (RT_SUCCESS(vrc)) 545 { 546 vrc = pTranslator->registerTranslation(szNlsPath, true, &pTrComponent); 547 if (RT_SUCCESS(vrc)) 548 { 549 vrc = pTranslator->i_loadLanguage(NULL); 550 if (RT_FAILURE(vrc)) 551 LogRelFunc(("Load language failed: %Rrc\n", vrc)); 552 } 553 else 554 LogRelFunc(("Register translation failed: %Rrc\n", vrc)); 555 } 556 else 557 LogRelFunc(("Path constructing failed: %Rrc\n", vrc)); 558 559 } 560 #endif 561 446 562 for (int i = 1; i < argc || argc <= iCmd; i++) 447 563 { … … 644 760 if (SUCCEEDED(hrc)) 645 761 { 762 #ifdef VBOX_WITH_VBOXMANAGE_NLS 763 if (pTranslator != NULL) 764 { 765 HRESULT hrc1 = pTranslator->loadLanguage(virtualBox); 766 if (FAILED(hrc1)) 767 { 768 /* Just log and ignore the language error */ 769 LogRel(("Failed to load API language, %Rhrc", hrc1)); 770 } 771 /* VirtualBox language events registration. */ 772 ComPtr<IEventSource> pES; 773 hrc1 = virtualBox->COMGETTER(EventSource)(pES.asOutParam()); 774 if (SUCCEEDED(hrc1)) 775 { 776 ComObjPtr<VBoxEventListenerImpl> listener; 777 listener.createObject(); 778 listener->init(new VBoxEventListener()); 779 pEventListener = listener; 780 com::SafeArray<VBoxEventType_T> eventTypes; 781 eventTypes.push_back(VBoxEventType_OnLanguageChanged); 782 hrc1 = pES->RegisterListener(pEventListener, ComSafeArrayAsInParam(eventTypes), true); 783 if (FAILED(hrc1)) 784 { 785 pEventListener.setNull(); 786 LogRel(("Failed to register event listener, %Rhrc", hrc1)); 787 } 788 } 789 } 790 #endif 791 646 792 ComPtr<ISession> session; 647 793 hrc = session.createInprocObject(CLSID_Session); … … 696 842 } 697 843 844 #ifdef VBOX_WITH_VBOXMANAGE_NLS 845 /* VirtualBox event callback unregistration. */ 846 if (pEventListener.isNotNull()) 847 { 848 ComPtr<IEventSource> pES; 849 HRESULT hrc1 = virtualBox->COMGETTER(EventSource)(pES.asOutParam()); 850 if (pES.isNotNull()) 851 { 852 hrc1 = pES->UnregisterListener(pEventListener); 853 if (FAILED(hrc1)) 854 LogRel(("Failed to unregister listener, %Rhrc", hrc1)); 855 } 856 pEventListener.setNull(); 857 } 858 #endif 698 859 /* 699 860 * Terminate COM, make sure the virtualBox object has been released. … … 715 876 } 716 877 878 #ifdef VBOX_WITH_VBOXMANAGE_NLS 879 if (pTranslator != NULL) 880 { 881 pTranslator->release(); 882 pTranslator = NULL; 883 pTrComponent = NULL; 884 } 885 #endif 886 717 887 if (papszResponseFileArgs) 718 888 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r92375 r92403 2931 2931 SHOW_UTF8_STRING("GuestAdditionsVersion", GuestCtrl::tr("Additions version:"), szValue); 2932 2932 } 2933 } 2933 2934 #endif 2934 2935 -
trunk/src/VBox/Main/glue/AutoLock.cpp
r82968 r92403 87 87 { LOCKCLASS_OTHEROBJECT, "10-OTHEROBJECT" }, 88 88 { LOCKCLASS_PROGRESSLIST, "11-PROGRESSLIST" }, 89 { LOCKCLASS_OBJECTSTATE, "12-OBJECTSTATE" } 89 { LOCKCLASS_OBJECTSTATE, "12-OBJECTSTATE" }, 90 { LOCKCLASS_TRANSLATOR, "13-TRANSLATOR" } 90 91 }; 91 92 -
trunk/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
r92144 r92403 131 131 typedef ListenerImpl<VBoxEventListener> VBoxEventListenerImpl; 132 132 133 VBOX_LISTENER_DECLARE(VBox TrEventListenerImpl)133 VBOX_LISTENER_DECLARE(VBoxEventListenerImpl) 134 134 135 135 #endif /* VBOX_WITH_MAIN_NLS */
Note:
See TracChangeset
for help on using the changeset viewer.