Changeset 91392 in vbox
- Timestamp:
- Sep 27, 2021 12:33:40 PM (3 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/QMTranslator.h
r90828 r91392 33 33 * Gets translation from loaded QM file 34 34 * 35 * @param pszContext QM context to look for translation 36 * @param pszSource Source string in one-byte encoding 37 * @param pszDisamb Disambiguationg comment, empty by default 38 * @param iNum Plural form indicator. 35 * @param pszContext QM context to look for translation 36 * @param pszSource Source string in one-byte encoding 37 * @param ppszSafeSource Where to return pointer to a safe copy of @a 38 * pszSource for the purpose of reverse translation. 39 * Will be set to NULL if @a pszSource is returned. 40 * @param pszDisamb Disambiguationg comment, empty by default 41 * @param iNum Plural form indicator. 39 42 * 40 43 * @returns Pointer to a translation (UTF-8 encoding), source string on failure. 41 44 */ 42 const char *translate(const char *pszContext, const char *pszSource, 45 const char *translate(const char *pszContext, const char *pszSource, const char **ppszSafeSource, 43 46 const char *pszDisamb = NULL, const int iNum = -1) const RT_NOEXCEPT; 44 47 -
trunk/src/VBox/Main/src-all/QMTranslatorImpl.cpp
r90929 r91392 414 414 const char *pszSource, 415 415 const char *pszDisamb, 416 const int aNum) const 416 const int aNum, 417 const char **ppszSafeSource) const 417 418 { 418 419 QMHashSetConstIter lowerIter, upperIter; … … 442 443 && (!apszDisabm[i] || !*apszDisabm[i] || RTStrCmp(message.pszComment, apszDisabm[i]) == 0 )) 443 444 { 445 *ppszSafeSource = message.pszSource; 444 446 const std::vector<const char *> &vecTranslations = m_messageArray[iter->offset].vecTranslations; 445 447 size_t const idxPlural = plural(aNum); … … 449 451 } 450 452 453 *ppszSafeSource = NULL; 451 454 return pszSource; 452 455 } … … 608 611 QMTranslator::~QMTranslator() { delete m_impl; } 609 612 610 const char *QMTranslator::translate(const char *pszContext, const char *pszSource, 611 const char *pszDisamb, const int aNum) const RT_NOEXCEPT 613 const char *QMTranslator::translate(const char *pszContext, const char *pszSource, const char **ppszSafeSource, 614 const char *pszDisamb /*== NULL*/, const int aNum /*= -1*/) const RT_NOEXCEPT 615 612 616 { 613 return m_impl->translate(pszContext, pszSource, pszDisamb, aNum );617 return m_impl->translate(pszContext, pszSource, pszDisamb, aNum, ppszSafeSource); 614 618 } 615 619 -
trunk/src/VBox/Main/src-all/VirtualBoxTranslator.cpp
r91391 r91392 437 437 if (pCurrInstance != NULL) 438 438 { 439 pszTranslation = pCurrInstance->i_translate(aComponent, aContext, 440 aSourceText, aComment, aNum); 439 pszTranslation = pCurrInstance->i_translate(aComponent, aContext, aSourceText, aComment, aNum); 441 440 pCurrInstance->release(); 442 441 } … … 486 485 return aSourceText; 487 486 488 const char *pszTranslation = aComponent->pTranslator->translate(aContext, aSourceText, aComment, aNum); 489 490 LastTranslation *pEntry = getTlsEntry(); 491 if (pEntry) 492 { 493 pEntry->first = pszTranslation; 494 /** @todo r=bird: This is not technically threadsafe. Move this down to the 495 * above translator call. */ 496 pEntry->second = m_hStrCache != NIL_RTSTRCACHE ? RTStrCacheEnter(m_hStrCache, aSourceText) : aSourceText; 487 const char *pszSafeSource = NULL; 488 const char *pszTranslation = aComponent->pTranslator->translate(aContext, aSourceText, &pszSafeSource, aComment, aNum); 489 if (pszSafeSource) 490 { 491 LastTranslation *pEntry = getTlsEntry(); 492 if (pEntry) 493 { 494 pEntry->first = pszTranslation; 495 pEntry->second = pszSafeSource; 496 } 497 497 } 498 498
Note:
See TracChangeset
for help on using the changeset viewer.